コード例 #1
0
        public void ReadFromFileStream(StreamReader sr, List <ServiceNode> nodeList)
        {
            string str = sr.ReadLine();

            Title = str.Substring(str.IndexOf(":") + 1).Trim();
            str   = sr.ReadLine();
            int num = Convert.ToInt32(str.Substring(str.IndexOf(":") + 1).Trim());

            ItineraryItems.Clear();
            for (int i = 0; i < num; i++)
            {
                str = sr.ReadLine();
                string      nodeName = str.Substring(str.IndexOf(":") + 1).Trim();
                ServiceNode node     = null;
                foreach (ServiceNode sn in nodeList)
                {
                    if (sn.Name == nodeName)
                    {
                        node = sn;
                        break;
                    }
                }
                if (node == null)
                {
                    throw new Exception($"Node with name {nodeName} is not found");
                }
                ItineraryItem item = new ItineraryItem(node);
                str = sr.ReadLine();
                str = str.Substring(str.IndexOf(":") + 1).Trim(); // get service time generator type
                if (str != "Null")
                {
                    item.ServiceTimeGenerator = RandomVariateGenerator.CreateRVGbyType(str);
                    if (item.ServiceTimeGenerator != null)
                    {
                        item.ServiceTimeGenerator.ReadFromFileStream(sr);
                    }
                }
                ItineraryItems.Add(item);
            }
        }
コード例 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ItineraryItem item = new ItineraryItem((ServiceNode)cbxNodes.SelectedItem);

            switch (cbxRVGTypes.SelectedIndex)
            {
            case 0:     // None
                break;

            case 1:     // Exp
                item.ServiceTimeGenerator = new ExponentialRVG(1.0);
                break;

            case 2:     // Uni
                item.ServiceTimeGenerator = new UniformRVG(1.0, 3.0);
                break;

            case 3:     // Normal
                // mean = 2.0, std = 0.5
                // lb = 0.01
                break;
            }
            lsbItem.Items.Add(item);
        }