public void Calculate_SimulationTable(ref SimulationSystem s) { s.PerformanceMeasures.TotalSalesProfit = 0; s.PerformanceMeasures.TotalLostProfit = 0; s.PerformanceMeasures.TotalScrapProfit = 0; s.PerformanceMeasures.TotalNetProfit = 0; s.PerformanceMeasures.DaysWithUnsoldPapers = 0; s.PerformanceMeasures.DaysWithMoreDemand = 0; s.PerformanceMeasures.TotalCost = s.NumOfRecords * s.NumOfNewspapers * s.PurchasePrice; s.UnitProfit = s.SellingPrice - s.PurchasePrice; int index = 0; for (int i = 0; i < s.NumOfRecords; i++) { SimulationCase SC = new SimulationCase(); SC.DayNo = i + 1; SC.DailyCost = s.NumOfNewspapers * s.PurchasePrice; SC.RandomNewsDayType = rnd.Next(1, 100); for (int j = 0; j < s.DayTypeDistributions.Count; j++) { if (SC.RandomNewsDayType >= s.DayTypeDistributions[j].MinRange && SC.RandomNewsDayType <= s.DayTypeDistributions[j].MaxRange) { SC.NewsDayType = s.DayTypeDistributions[j].DayType; } } SC.RandomDemand = rnd.Next(1, 100); index = (int)SC.NewsDayType; for (int j = 0; j < s.DemandDistributions.Count; j++) { if (SC.RandomDemand >= s.DemandDistributions[j].DayTypeDistributions[index].MinRange && SC.RandomDemand <= s.DemandDistributions[j].DayTypeDistributions[index].MaxRange) { SC.Demand = s.DemandDistributions[j].Demand; } } if (SC.Demand > s.NumOfNewspapers) { SC.SalesProfit = s.SellingPrice * s.NumOfNewspapers; SC.LostProfit = (SC.Demand - s.NumOfNewspapers) * s.UnitProfit; SC.ScrapProfit = 0; s.PerformanceMeasures.DaysWithMoreDemand += 1; } else { SC.SalesProfit = s.SellingPrice * SC.Demand; SC.LostProfit = 0; SC.ScrapProfit = (s.NumOfNewspapers - SC.Demand) * s.ScrapPrice; } if (SC.Demand < s.NumOfNewspapers) { s.PerformanceMeasures.DaysWithUnsoldPapers += 1; } SC.DailyNetProfit = SC.SalesProfit - SC.DailyCost - SC.LostProfit + SC.ScrapProfit; s.PerformanceMeasures.TotalSalesProfit += SC.SalesProfit; s.PerformanceMeasures.TotalLostProfit += SC.LostProfit; s.PerformanceMeasures.TotalScrapProfit += SC.ScrapProfit; s.PerformanceMeasures.TotalNetProfit += SC.DailyNetProfit; s.SimulationTable.Add(SC); } }
public object Clone() { SimulationSystem system = MemberwiseClone() as SimulationSystem; system.DayTypeDistributions = new List <DayTypeDistribution>(DayTypeDistributions); system.DemandDistributions = new List <DemandDistribution>(DemandDistributions); system.SimulationTable = new List <SimulationCase>(SimulationTable); system.PerformanceMeasures = PerformanceMeasures.Clone() as PerformanceMeasures; return(system); }
public void DayType_Disribution(ref SimulationSystem s) { for (int i = 0; i < DayTypeDistributions.Count; i++) { if (i == 0) { s.DayTypeDistributions[i].CummProbability = s.DayTypeDistributions[i].Probability; s.DayTypeDistributions[i].MinRange = 1; s.DayTypeDistributions[i].MaxRange = Convert.ToInt32(s.DayTypeDistributions[i].CummProbability * 100); } else { s.DayTypeDistributions[i].CummProbability = s.DayTypeDistributions[i - 1].CummProbability + s.DayTypeDistributions[i].Probability; s.DayTypeDistributions[i].MinRange = s.DayTypeDistributions[i - 1].MaxRange + 1; s.DayTypeDistributions[i].MaxRange = Convert.ToInt32(s.DayTypeDistributions[i].CummProbability * 100); } } }
public ManageSystem() { system = new SimulationSystem(); random = new Random(); }