Beispiel #1
0
        private void Selected_service_dgv_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            Console.WriteLine(e.RowIndex + "_" + e.ColumnIndex);

            if (e.RowIndex == -1 || e.ColumnIndex == -1)
            {
            }
            else
            {
                Console.WriteLine(selected_services[e.RowIndex].Income);
                service_name.Text           = selected_services[e.RowIndex].Service_name;
                service_name.Visible        = true;
                stop_station.Text           = Service_algo.PrettyPrintArraysFormat(selected_services[e.RowIndex].StopStation);
                stop_station.Visible        = true;
                departure_time.Text         = selected_services[e.RowIndex].Departure_time[selected_services[e.RowIndex].indexOfFirstStation()].ToShortTimeString();
                departure_time.Visible      = true;
                served_demand.Text          = Service_algo.showarray_toStr(selected_services[e.RowIndex].Actual_serve_income);
                served_demand.Visible       = true;
                income.Text                 = selected_services[e.RowIndex].Income.ToString();
                income.Visible              = true;
                utilization_percent.Text    = selected_services[e.RowIndex].Utilization_percent.ToString();
                utilization_percent.Visible = true;
                profit.Text                 = selected_services[e.RowIndex].Profitability.ToString();
                profit.Visible              = true;
                operation_cost.Text         = ((double)(selected_services[e.RowIndex].operation_cost)).ToString();

                operation_cost.Visible = true;
                panel_summary.Refresh();
            }
        }
        public int getDistance(int[] StopStation)
        {
            Console.WriteLine("___GETDISTANT " + Service_algo.PrettyPrintArrays(StopStation));
            int source_index = 0, des_index = 0;

            for (var i = StopStation.Length - 1; i >= 0; i--)
            {
                if (StopStation[i] == 1)
                {
                    des_index = i;
                    break;
                }
            }
            for (var i = 0; i < StopStation.Length; i++)
            {
                if (StopStation[i] == 1)
                {
                    source_index = i;
                    break;
                }
            }
            Console.WriteLine("souce_index " + source_index + " Des_index " + des_index);
            var result = Math.Abs(PhysicalData.distance_meter[source_index] - PhysicalData.distance_meter[des_index]);

            return(result);
        }
        public (int, int) getSouceDesIndex()
        {
            Console.WriteLine("__GET SOURCE_DEST " + Service_algo.PrettyPrintArrays(StopStation));
            int source_index = 0, des_index = 0;

            for (var i = StopStation.Length - 1; i >= 0; i--)
            {
                if (StopStation[i] == 1)
                {
                    des_index = i;
                    break;
                }
            }
            for (var i = 0; i < StopStation.Length; i++)
            {
                if (StopStation[i] == 1)
                {
                    source_index = i;
                    break;
                }
            }
            Console.WriteLine("souce_index " + source_index + " Des_index " + des_index);
            return(source_index, des_index);
        }
Beispiel #4
0
        public void getService_dgv()
        {
            List <Service> services = new List <Service>();

            Service temp_service;
            int     dep_hour = 8; int dep_min = 0;
            int     counter = 0;

            foreach (DataGridViewRow row in dgvService.Rows)
            {
                if (dgvService.Rows.Count == counter)
                {
                    break;
                }
                temp_service = new Service(row.Cells[0].Value.ToString(), getStopStation(counter), dep_hour, dep_min);
                services.Add(temp_service);
                counter++;
            }
            service_list = services;
            var b = 0;

            selected_services.Clear();
            (selected_services, _) = Service_algo.genService(services);

            BindingSource bs = new BindingSource();

            bs.DataSource = typeof(Service_summary);
            for (var index = 0; index < selected_services.Count; index++)
            {
                bs.Add(selected_services[index]);
            }
            // bs.DataSource = typeof(Airplane);

            Selected_service_dgv.DataSource          = bs;
            Selected_service_dgv.AutoGenerateColumns = true;
            foreach (DataGridViewRow dgvr in Selected_service_dgv.Rows)//dgv is datagridview
            {
                var carry = ConvertToDouble(dgvr.Cells[2].Value.ToString());

                if (carry > 0)
                {
                    dgvr.DefaultCellStyle.BackColor = Color.FromArgb(222, 251, 184);
                }
                else
                {
                    dgvr.DefaultCellStyle.BackColor = Color.Firebrick;
                    dgvr.DefaultCellStyle.ForeColor = Color.Beige;
                }
            }

            richTextBox1.Text = ""; //reset
            var average_wait = 0.0;

            foreach (Station station in stations)
            {
                Console.WriteLine("Station : " + station.station_name);
                Console.WriteLine("sum_passenger : " + station.sum_passenger);
                Console.WriteLine("sum_waiting time : " + station.sum_waiting_time);
                Console.WriteLine("_____________________________________________________________ ");

                average_wait += Math.Round((station.sum_waiting_time / 400000 * 60), 2);
            }
            richTextBox1.Text += "Average plan waiting time  : " + average_wait / stations.Count + " miniutes\n\n";

            // get sum profit
            var sum_profit_all_selected = 0.0;

            foreach (Service_summary _sum in selected_services)
            {
                sum_profit_all_selected += _sum.Profitability;
            }
            richTextBox1.Text += "Profitablie of Plan : " + sum_profit_all_selected + "\n\n";

            var sum_utilize = 0.0;
            var max_util    = 0.0;
            var min_util    = 100.0;

            foreach (Service_summary _sum in selected_services)
            {
                sum_utilize += _sum.Utilization_percent;
                if (_sum.Utilization_percent >= max_util)
                {
                    max_util = _sum.Utilization_percent;
                }

                if (_sum.Utilization_percent <= min_util)
                {
                    min_util = _sum.Utilization_percent;
                }
            }
            var average_utilize = sum_utilize / selected_services.Count;

            richTextBox1.Text += "Avarage Utilization of Plan : " + Math.Round(Convert.ToDecimal(average_utilize), 2) + " \n\n";
            richTextBox1.Text += "MAX Utilization of Plan : " + Math.Round(Convert.ToDecimal(max_util), 2) + " \n\n";
            richTextBox1.Text += "MIN Utilization of Plan : " + Math.Round(Convert.ToDecimal(min_util), 2) + " \n\n";
            if (PhysicalData.Current_mode == 0)
            {
                richTextBox1.Text += "MODE : OUTBOUND\n\n";
            }
            if (PhysicalData.Current_mode == 1)
            {
                richTextBox1.Text += "MODE : INBOUND\n\n";
            }
            Console.WriteLine("DGV DONE " + bs.Count);
        }