static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); NewspaperSellerModels.System s = new NewspaperSellerModels.System(); }
private void btnReadData_Click(object sender, EventArgs e) { NewspaperSellerModels.System sys = new NewspaperSellerModels.System(); dayTypeDis = new List <DayTypeDistribution>(); demandDis = new List <DemandDistribution>(); //string test = TestingManager.Test(sys, Constants.FileNames.TestCase1); //MessageBox.Show(test); Read_Demand_Distribution(); Read_Day_Type_Distribution(); Helper.Calc_Ranges(dayTypeDis); Helper.Calc_Ranges_Of_Demand(demandDis); //test /*for (int i = 0; i < demandDis.Count; i++) { * MessageBox.Show(demandDis[i].DayTypeDistributions[0].MinRange.ToString()); * MessageBox.Show(demandDis[i].DayTypeDistributions[0].MaxRange.ToString()); * MessageBox.Show(demandDis[i].DayTypeDistributions[1].MinRange.ToString()); * MessageBox.Show(demandDis[i].DayTypeDistributions[1].MaxRange.ToString()); * MessageBox.Show(demandDis[i].DayTypeDistributions[2].MinRange.ToString()); * MessageBox.Show(demandDis[i].DayTypeDistributions[2].MaxRange.ToString()); * } * * for (int i = 0; i < dayTypeDis.Count; i++) * { * MessageBox.Show(dayTypeDis[i].CummProbability.ToString()); * MessageBox.Show(dayTypeDis[i].MinRange.ToString()); * MessageBox.Show(dayTypeDis[i].MaxRange.ToString()); * * } */ //sys.NumOfNewspapers = Int32.Parse( txtNumOfNewpapers.Text.ToString()); double max = 0, num = 0; // MessageBox.Show(dataGridView5.Rows.Count.ToString()); for (int i = 0; i < dataGridView5.Rows.Count - 1; ++i) { sys.NumOfNewspapers = Int32.Parse(dataGridView5.Rows[i].Cells[0].Value.ToString()); sys.NumOfRecords = Int32.Parse(txtNumOfDays.Text.ToString()); sys.PurchasePrice = Math.Round(float.Parse(txtPurchasePrice.Text.ToString()), 5); sys.ScrapPrice = Math.Round(float.Parse(txtScrapPrice.Text.ToString()), 5); sys.SellingPrice = Math.Round(float.Parse(txtSellingPrice.Text.ToString()), 5); sys.DayTypeDistributions = dayTypeDis; sys.DemandDistributions = demandDis; sys.UnitProfit = sys.PurchasePrice - sys.SellingPrice; List <SimulationCase> simulation = Helper.simulate(sys); dataGridView3.DataSource = simulation; sys.PerformanceMeasures.TotalSalesProfit = CalculatePerformance.totalSalesRevenue(simulation); sys.PerformanceMeasures.TotalCost = CalculatePerformance.totalCostOfNewspapers(simulation); sys.PerformanceMeasures.TotalLostProfit = CalculatePerformance.totalLostProfit(simulation); sys.PerformanceMeasures.TotalScrapProfit = CalculatePerformance.totalSalvage(simulation); sys.PerformanceMeasures.TotalNetProfit = CalculatePerformance.netProfit(simulation); sys.PerformanceMeasures.DaysWithMoreDemand = CalculatePerformance.excessDemand(simulation, sys.NumOfNewspapers); sys.PerformanceMeasures.DaysWithUnsoldPapers = CalculatePerformance.unsoldPapers(simulation, sys.NumOfNewspapers); List <PerformanceMeasures> result = new List <PerformanceMeasures>(); result.Add(sys.PerformanceMeasures); var source = new BindingSource(); source.DataSource = result; dataGridView4.DataSource = source; sys.SimulationCases = simulation; if (sys.PerformanceMeasures.TotalNetProfit > max) { max = sys.PerformanceMeasures.TotalNetProfit; num = Int32.Parse(dataGridView5.Rows[i].Cells[0].Value.ToString()); } } MessageBox.Show(num.ToString()); string testing = TestingManager.Test(sys, Constants.FileNames.TestCase3); MessageBox.Show(testing); }