예제 #1
0
        private void Communitypage_Calc_supply_demand_radio_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < TimeMatrix_Car.Count / Hospital_Capacity.Count; i++)
            {
                subDistrict temp = new subDistrict();;
                temp.id         = i + 1;
                temp.population = (double)PopulationList[i];

                for (int j = i * Hospital_Capacity.Count; j < (i + 1) * Hospital_Capacity.Count; j++)
                {
                    temp.CartravelTimes.Add(TimeMatrix_Car[j]);
                    //temp.TransittravelTimes.Add(TimeMatrix_Transit[j]);
                }
                populationCell_List.Add(temp);
            }


            //////计算供需比
            for (int i = 0; i < Hospital_Capacity.Count; i++)
            {
                ServiceFacility temp = new ServiceFacility();
                temp.capacity = (double)Hospital_Capacity[i];
                double demands_Sum = 0;
                for (int j = 0; j < populationCell_List.Count; j++)
                {
                    subDistrict subD = (subDistrict)populationCell_List[j];
                    if ((double)subD.CartravelTimes[i] <= double.Parse(Gadecay_timeThreshold.Text))
                    {
                        //demands_Sum += subD.population * double.Parse(Prob_car_Text.Text) * Calc_decayValue((double)subD.CartravelTimes[i], Alpha_car, Beta_car,
                        //    Car_minTime, Car_maxTime);
                        demands_Sum += subD.population * calc_GadecayValue((double)subD.CartravelTimes[i], double.Parse(Gadecay_timeThreshold.Text));
                    }
                    //if ((double)subD.TransittravelTimes[i] <= Transit_maxTime)
                    //{
                    //    demands_Sum += subD.population * double.Parse(Prob_transit_Text.Text) * Calc_decayValue((double)subD.TransittravelTimes[i], Alpha_transit, Beta_transit,
                    //        Transit_minTime, Transit_maxTime);
                    //}
                }
                temp.Supply_demand_ratio = (double)temp.capacity / demands_Sum;
                Facalityclass_List.Add(temp);
            }
            MessageBox.Show("计算完成");
        }
예제 #2
0
        private void Car_ClacAccessibility_AndSave_Btn_Click(object sender, EventArgs e)
        {
            if (bIsloadcarTimematrix == false || bIsloadPopulation == false || bIsloadServiceFacality == false || bIsloadtransitTimematrix == false)
            {
                MessageBox.Show("数据输入不完整,无法计算可达性!");
                return;
            }
            if (TimeMatrix_Car.Count % Hospital_Capacity.Count != 0)
            {
                MessageBox.Show("时间矩阵数据输入有误 或 设施数据输入有误!");
                return;
            }
            Alpha_car       = double.Parse(Alpha_car_Text.Text);
            Beta_car        = double.Parse(Beta_car_Text.Text);
            Alpha_transit   = double.Parse(Alpha_transit_text.Text);
            Beta_transit    = double.Parse(Beta_transit_text.Text);
            Car_minTime     = double.Parse(Tmin_car_Text.Text);
            Car_maxTime     = double.Parse(Tmax_car_Text.Text);
            Transit_minTime = double.Parse(Tmin_transit_text.Text);
            Transit_maxTime = double.Parse(Tmax_transit_text.Text);

            ArrayList subDistrict_List     = new ArrayList();
            ArrayList ServiceFacility_List = new ArrayList();

            for (int i = 0; i < TimeMatrix_Car.Count / Hospital_Capacity.Count; i++)
            {
                subDistrict temp = new subDistrict();;
                temp.id         = i + 1;
                temp.population = (double)PopulationList[i];

                for (int j = i * Hospital_Capacity.Count; j < (i + 1) * Hospital_Capacity.Count; j++)
                {
                    temp.CartravelTimes.Add(TimeMatrix_Car[j]);
                    temp.TransittravelTimes.Add(TimeMatrix_Transit[j]);
                }
                subDistrict_List.Add(temp);
            }
            //////计算供需比
            for (int i = 0; i < Hospital_Capacity.Count; i++)
            {
                ServiceFacility temp = new ServiceFacility();
                temp.capacity = (double)Hospital_Capacity[i];
                double demands_Sum = 0;
                for (int j = 0; j < subDistrict_List.Count; j++)
                {
                    subDistrict subD = (subDistrict)subDistrict_List[j];
                    if ((double)subD.CartravelTimes[i] <= Car_maxTime)
                    {
                        demands_Sum += subD.population * double.Parse(Prob_car_Text.Text) * Calc_decayValue((double)subD.CartravelTimes[i], Alpha_car, Beta_car,
                                                                                                            Car_minTime, Car_maxTime);
                    }
                    if ((double)subD.TransittravelTimes[i] <= Transit_maxTime)
                    {
                        demands_Sum += subD.population * double.Parse(Prob_transit_Text.Text) * Calc_decayValue((double)subD.TransittravelTimes[i], Alpha_transit, Beta_transit,
                                                                                                                Transit_minTime, Transit_maxTime);
                    }
                }
                temp.Supply_demand_ratio = (double)temp.capacity / demands_Sum;
                ServiceFacility_List.Add(temp);
            }
            //计算可达性
            for (int i = 0; i < subDistrict_List.Count; i++)
            {
                subDistrict subD = (subDistrict)subDistrict_List[i];
                for (int j = 0; j < ServiceFacility_List.Count; j++)
                {
                    if ((double)subD.CartravelTimes[j] <= Car_maxTime)
                    {
                        ServiceFacility sf = (ServiceFacility)ServiceFacility_List[j];
                        subD.car_Accessibility += (sf.Supply_demand_ratio * Calc_decayValue((double)subD.CartravelTimes[j], Alpha_car, Beta_car, Car_minTime, Car_maxTime));
                    }
                    if ((double)subD.TransittravelTimes[j] <= Transit_maxTime)
                    {
                        ServiceFacility sf = (ServiceFacility)ServiceFacility_List[j];
                        subD.transit_Accessibility += (sf.Supply_demand_ratio * Calc_decayValue((double)subD.TransittravelTimes[j], Alpha_transit, Beta_transit, Transit_minTime, Transit_maxTime));
                    }
                }
                subD.multiModal_Accessibility = double.Parse(Prob_car_Text.Text) * subD.car_Accessibility + double.Parse(Prob_transit_Text.Text) * subD.transit_Accessibility;
                subD.multiModal_Accessibility = double.Parse(Prob_car_Text.Text) * subD.car_Accessibility + double.Parse(Prob_transit_Text.Text) * subD.transit_Accessibility;
                subDistrict_List[i]           = subD;
            }
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter = "CSV|*.csv";
            saveFileDialog1.Title  = "Save an csv File";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();
                StreamWriter         sw = new StreamWriter(fs, Encoding.UTF8);
                for (int i = 0; i < subDistrict_List.Count; i++)
                {
                    subDistrict temp = (subDistrict)subDistrict_List[i];
                    sw.Write(temp.car_Accessibility.ToString() + "," + temp.transit_Accessibility + "," + temp.multiModal_Accessibility + "\n");
                }
                sw.Close();
                fs.Close();
            }
            MessageBox.Show("导出完成!");
        }
예제 #3
0
        private void Communitypage_calc_Accessibility_Click(object sender, EventArgs e)
        {
            ArrayList Community_List = new ArrayList();

            for (int i = 0; i < Community_TimeMatrix.Count / Hospital_Capacity.Count; i++)
            {
                subDistrict temp = new subDistrict();;
                temp.id = i + 1;
                //temp.population = (double)PopulationList[i];

                for (int j = i * Hospital_Capacity.Count; j < (i + 1) * Hospital_Capacity.Count; j++)
                {
                    temp.CartravelTimes.Add(Community_TimeMatrix[j]);
                }
                Community_List.Add(temp);
            }
            ////test
            //for(int i = 0; i < populationCell_List.Count;i++)
            //{
            //    subDistrict subD = (subDistrict)populationCell_List[i];
            //    for (int j = 0; j < Facalityclass_List.Count; j++)
            //    {
            //        if ((double)subD.CartravelTimes[j] <= double.Parse(Gadecay_timeThreshold.Text))
            //        {
            //            ServiceFacility sf = (ServiceFacility)Facalityclass_List[j];
            //            subD.car_Accessibility += (sf.Supply_demand_ratio * calc_GadecayValue((double)subD.CartravelTimes[j], double.Parse(Gadecay_timeThreshold.Text)));
            //        }
            //    }
            //    populationCell_List[i] = subD;'
            //}
            //计算可达性
            for (int i = 0; i < Community_List.Count; i++)
            {
                subDistrict subD = (subDistrict)Community_List[i];
                for (int j = 0; j < Facalityclass_List.Count; j++)
                {
                    if ((double)subD.CartravelTimes[j] <= double.Parse(Gadecay_timeThreshold.Text))
                    {
                        ServiceFacility sf = (ServiceFacility)Facalityclass_List[j];
                        //subD.car_Accessibility += (sf.Supply_demand_ratio * Calc_decayValue((double)subD.CartravelTimes[j], Alpha_car, Beta_car, Car_minTime, Car_maxTime));
                        subD.car_Accessibility += (sf.Supply_demand_ratio * calc_GadecayValue((double)subD.CartravelTimes[j], double.Parse(Gadecay_timeThreshold.Text)));
                    }
                    //if ((double)subD.TransittravelTimes[j] <= Transit_maxTime)
                    //{
                    //    ServiceFacility sf = (ServiceFacility)ServiceFacility_List[j];
                    //    subD.transit_Accessibility += (sf.Supply_demand_ratio * Calc_decayValue((double)subD.TransittravelTimes[j], Alpha_transit, Beta_transit, Transit_minTime, Transit_maxTime));
                    //}
                }
                //subD.multiModal_Accessibility = double.Parse(Prob_car_Text.Text) * subD.car_Accessibility + double.Parse(Prob_transit_Text.Text) * subD.transit_Accessibility;
                //subD.multiModal_Accessibility = double.Parse(Prob_car_Text.Text) * subD.car_Accessibility + double.Parse(Prob_transit_Text.Text) * subD.transit_Accessibility;
                Community_List[i] = subD;
            }
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter = "CSV|*.csv";
            saveFileDialog1.Title  = "Save an csv File";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();
                StreamWriter         sw = new StreamWriter(fs, Encoding.UTF8);
                for (int i = 0; i < Community_List.Count; i++)
                {
                    subDistrict temp = (subDistrict)Community_List[i];
                    sw.WriteLine(temp.car_Accessibility.ToString());
                    //sw.Write(temp.car_Accessibility.ToString() + "," + temp.transit_Accessibility + "," + temp.multiModal_Accessibility + "\n");
                }
                sw.Close();
                fs.Close();
            }
            MessageBox.Show("导出完成!");
        }