private void button2_Click(object sender, EventArgs e)
        {
            InventoryModels.SimulationSystem simsys = new InventoryModels.SimulationSystem();
            LeadTimeDis = new List <Distribution>();
            demandDis   = new List <Distribution>();

            Read_Demand_Distribution();
            Read_Lead_time_Distribution();
            Helper.Calc_Ranges(LeadTimeDis);
            Helper.Calc_Ranges(demandDis);
            simsys.DemandDistribution   = demandDis;
            simsys.LeadDaysDistribution = LeadTimeDis;
            // MessageBox.Show(LeadTimeDis.Count.ToString());

            simsys.NumberOfDays           = Int32.Parse(NumberOfDays.Text.ToString());
            simsys.OrderUpTo              = Int32.Parse(theOrderLevel.Text.ToString());
            simsys.ReviewPeriod           = Int32.Parse(TheReviewPeriod.Text.ToString());
            simsys.StartOrderQuantity     = Int32.Parse(FirstOrderQuantity.Text.ToString());
            simsys.StartLeadDays          = Int32.Parse(FirstOrderarrivesAfter.Text.ToString());
            simsys.StartInventoryQuantity = Int32.Parse(BeginningInventoryQuantity.Text.ToString());


            List <SimulationCase> simulation = Helper.simulate(simsys);

            simsys.SimulationCases = simulation;
            simsys.PerformanceMeasures.EndingInventoryAverage  = Helper.endingInvenoryAverage(simulation);
            simsys.PerformanceMeasures.ShortageQuantityAverage = Helper.shortageQuantityAverage(simulation);
            dataGridView3.DataSource = simulation;


            string testing = TestingManager.Test(simsys, Constants.FileNames.TestCase1);

            MessageBox.Show(testing);
        }
Exemplo n.º 2
0
        public static void ReadInput(string testCase, ref SimulationSystem simulationSystem)
        {
            string projectPath = System.IO.Directory.GetCurrentDirectory();

            projectPath = projectPath.Remove(projectPath.Length - 10);
            string[] lines = System.IO.File.ReadAllLines(projectPath + "\\TestCases\\" + testCase + ".txt");
            InputData(lines, ref simulationSystem);
        }
 public Inputs_Read()
 {
     system = new SimulationSystem();
 }
Exemplo n.º 4
0
        public static void InputData(string[] lines, ref SimulationSystem simulationSystem)
        {
            int stringType = 0;

            char[] delimiters = { ',', ' ' };
            foreach (string line in lines)
            {
                if (line == "\n" || line.Length == 0 || line[0] == ' ')
                {
                    continue;
                }
                switch (line)
                {
                case "OrderUpTo":
                    stringType = 1;
                    continue;

                case "ReviewPeriod":
                    stringType = 2;
                    continue;

                case "StartInventoryQuantity":
                    stringType = 3;
                    continue;

                case "StartLeadDays":
                    stringType = 4;
                    continue;

                case "StartOrderQuantity":
                    stringType = 5;
                    continue;

                case "NumberOfDays":
                    stringType = 6;
                    continue;

                case "DemandDistribution":
                    stringType = 7;
                    continue;

                case "LeadDaysDistribution":
                    stringType = 8;
                    continue;
                }

                switch (stringType)
                {
                case 1:
                    simulationSystem.OrderUpTo = int.Parse(line);
                    break;

                case 2:
                    simulationSystem.ReviewPeriod = int.Parse(line);
                    break;

                case 3:
                    simulationSystem.StartInventoryQuantity = int.Parse(line);
                    break;

                case 4:
                    simulationSystem.StartLeadDays = int.Parse(line);
                    break;

                case 5:
                    simulationSystem.StartOrderQuantity = int.Parse(line);
                    break;

                case 6:
                    simulationSystem.NumberOfDays = int.Parse(line);
                    break;

                default: {
                    string[] distributions = line.Split(delimiters);

                    if (distributions.Length > 2)
                    {
                        Distribution distribution = new Distribution();
                        distribution.Value       = int.Parse(distributions[0]);
                        distribution.Probability = decimal.Parse(distributions[2]);

                        switch (stringType)
                        {
                        case 7:
                            simulationSystem.DemandDistribution.Add(distribution);
                            break;

                        case 8:
                            simulationSystem.LeadDaysDistribution.Add(distribution);
                            break;
                        }
                    }
                    break;
                }
                }
            }
        }
Exemplo n.º 5
0
 public Simulator(SimulationSystem sys)
 {
     mysys = sys;
 }
 public Simulate(SimulationSystem s)
 {
     system = s;
 }
        public static List <SimulationCase> simulate(SimulationSystem simSys)
        {
            List <SimulationCase> simCase = new List <SimulationCase>();
            Random     random             = new Random();
            int        beginning          = simSys.StartInventoryQuantity;
            int        leadingday         = simSys.StartLeadDays;
            int        order    = simSys.StartOrderQuantity;
            int        shortage = 0;
            List <int> T        = new List <int> {
                26, 68, 33, 39, 86, 18, 64, 79, 55, 74, 21, 43, 49, 90, 35, 8, 98, 61, 85, 81, 53, 15, 94, 19, 44
            };
            List <int> R = new List <int> {
                0, 0, 0, 0, 8, 0, 0, 0, 0, 7, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1
            };
            int index = 1;

            for (int i = 0; i < simSys.NumberOfDays; ++i)
            {
                simCase.Add(new SimulationCase());
                simCase[i].Day                = i + 1;
                simCase[i].Cycle              = (i / simSys.ReviewPeriod) + 1;
                simCase[i].DayWithinCycle     = index;
                simCase[i].BeginningInventory = simSys.StartOrderQuantity;

                simCase[i].BeginningInventory = beginning;
                int randomNumber = random.Next(1, 100);
                // int randomNumber = T[i];
                simCase[i].RandomDemand = randomNumber;
                simCase[i].Demand       = demandAndLead(randomNumber, simSys.DemandDistribution);


                if (simCase[i].BeginningInventory - simCase[i].Demand - shortage > 0)
                {
                    simCase[i].EndingInventory = simCase[i].BeginningInventory - simCase[i].Demand - shortage; shortage = 0;
                }
                else
                {
                    simCase[i].EndingInventory = 0;
                    shortage += -1 * (simCase[i].BeginningInventory - simCase[i].Demand);
                    simCase[i].ShortageQuantity = shortage;
                }
                if (leadingday == 1)
                {
                    beginning = simCase[i].EndingInventory + order;
                }
                else
                {
                    beginning = simCase[i].EndingInventory;
                }

                --leadingday;
                if (index == simSys.ReviewPeriod)
                {
                    randomNumber = random.Next(1, 100);
                    // randomNumber = R[i];
                    simCase[i].RandomLeadDays = randomNumber;
                    simCase[i].LeadDays       = demandAndLead(randomNumber, simSys.LeadDaysDistribution);
                    leadingday = simCase[i].LeadDays;
                    simCase[i].OrderQuantity = (simSys.OrderUpTo) - (simCase[i].EndingInventory) + (shortage);
                    order = simCase[i].OrderQuantity;
                }

                ++index;

                if (index > simSys.ReviewPeriod)
                {
                    index = 1;
                }
            }



            return(simCase);
        }