Exemple #1
0
        private void DistributionsOfDemand()
        {
            for (int i = 0; i < 3; i++)
            {
                DemandDistributions.ElementAt(0).DayTypeDistributions.ElementAt(i).CummProbability = DemandDistributions.ElementAt(0).DayTypeDistributions.ElementAt(i).Probability;
                DemandDistributions.ElementAt(0).DayTypeDistributions.ElementAt(i).MinRange        = 0;
                DemandDistributions.ElementAt(0).DayTypeDistributions.ElementAt(i).MaxRange        = Convert.ToInt32(DemandDistributions.ElementAt(0).DayTypeDistributions.ElementAt(i).CummProbability * 100);

                for (int j = 1; j < DemandDistributions.Count; j++)
                {
                    if (DemandDistributions.ElementAt(j - 1).DayTypeDistributions.ElementAt(i).CummProbability == 1)
                    {
                        DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(i).CummProbability = 1;
                    }
                    else
                    {
                        DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(i).CummProbability = DemandDistributions.ElementAt(j - 1).DayTypeDistributions.ElementAt(i).CummProbability + DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(i).Probability;
                    }

                    if (DemandDistributions.ElementAt(j - 1).DayTypeDistributions.ElementAt(i).MaxRange == 100 || DemandDistributions.ElementAt(j - 1).DayTypeDistributions.ElementAt(i).MaxRange == 0)
                    {
                        DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(i).MaxRange = 0;
                        DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(i).MinRange = 0;
                    }
                    else
                    {
                        DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(i).MinRange = DemandDistributions.ElementAt(j - 1).DayTypeDistributions.ElementAt(i).MaxRange + 1;
                        DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(i).MaxRange = Convert.ToInt32(DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(i).CummProbability * 100);
                    }
                }
            }
        }
Exemple #2
0
        ///////////// SimulationTable ////////////////
        public void fillTable()
        {
            Random rand = new Random();

            for (int i = 1; i <= NumOfRecords; i++)
            {
                SimulationCase sc = new SimulationCase();
                sc.DayNo = i;

                sc.RandomNewsDayType = rand.Next(1, 101);
                sc.RandomDemand      = rand.Next(1, 101);

                if (sc.RandomNewsDayType >= DayTypeDistributions.ElementAt(0).MinRange&& sc.RandomNewsDayType <= DayTypeDistributions.ElementAt(0).MaxRange)
                {
                    sc.NewsDayType = Enums.DayType.Good;
                }
                else if (sc.RandomNewsDayType >= DayTypeDistributions.ElementAt(1).MinRange&& sc.RandomNewsDayType <= DayTypeDistributions.ElementAt(1).MaxRange)
                {
                    sc.NewsDayType = Enums.DayType.Fair;
                }
                else
                {
                    sc.NewsDayType = Enums.DayType.Poor;
                }


                if (sc.NewsDayType == Enums.DayType.Good)
                {
                    for (int j = 0; j < DemandDistributions.Count; j++)
                    {
                        if (sc.RandomDemand >= DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(0).MinRange&& sc.RandomDemand <= DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(0).MaxRange)
                        {
                            sc.Demand = DemandDistributions.ElementAt(j).Demand;
                        }
                    }
                }



                else if (sc.NewsDayType == Enums.DayType.Fair)
                {
                    for (int j = 0; j < DemandDistributions.Count; j++)
                    {
                        if (sc.RandomDemand >= DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(1).MinRange&& sc.RandomDemand <= DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(1).MaxRange)
                        {
                            sc.Demand = DemandDistributions.ElementAt(j).Demand;
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < DemandDistributions.Count; j++)
                    {
                        if (sc.RandomDemand >= DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(2).MinRange&& sc.RandomDemand <= DemandDistributions.ElementAt(j).DayTypeDistributions.ElementAt(2).MaxRange)
                        {
                            sc.Demand = DemandDistributions.ElementAt(j).Demand;
                        }
                    }
                }



                sc.DailyCost = NumOfNewspapers * PurchasePrice;
                if (sc.Demand >= NumOfNewspapers)
                {
                    sc.SalesProfit = NumOfNewspapers * SellingPrice;
                    sc.LostProfit  = (sc.Demand - NumOfNewspapers) * (SellingPrice - PurchasePrice);
                    sc.ScrapProfit = 0;
                }

                else if (NumOfNewspapers > sc.Demand)
                {
                    sc.SalesProfit = sc.Demand * SellingPrice;
                    sc.ScrapProfit = (NumOfNewspapers - sc.Demand) * ScrapPrice;
                    sc.LostProfit  = 0;
                }
                sc.DailyNetProfit = sc.SalesProfit - sc.DailyCost - sc.LostProfit + sc.ScrapProfit;
                SimulationTable.Add(sc);
            }
        }