예제 #1
0
        // 求解
        private void Solve(object parameter)
        {
            CurrentNodeIndex = -1;

            double[] x = new double[Record.Nodes.Count];
            double[] y = new double[Record.Nodes.Count];
            double[] d = new double[Record.Nodes.Count];
            for (int i = 0; i < Record.Nodes.Count; ++i)
            {
                x[i] = Record.Nodes[i].X;
                y[i] = Record.Nodes[i].Y;
                d[i] = Record.Nodes[i].Demand;
            }

            double[] c = new double[Record.Cars.Count];
            double[] m = new double[Record.Cars.Count];
            for (int i = 0; i < Record.Cars.Count; ++i)
            {
                c[i] = Record.Cars[i].WeightLimit;
                m[i] = Record.Cars[i].DisLimit;
            }

            // 弹出loading消息框
            Application.Current.Dispatcher.BeginInvoke(new Action(delegate
            {
                LoadingDialog.Begin("正在求解");
            }));

            // 开启计算线程
            new Thread(delegate()
            {
                //double actualCarSpeed = Record.CarSpeed * (1 - CongestionFactor);
                VRPSolver.Solve(x, y, d, c, m, WTime, WDis, WCar, GenerationCount, Record.CarSpeed, Record.NodeStayTime, OnSolveFinish, OnSolveError);
                Application.Current.Dispatcher.BeginInvoke(new Action(delegate
                {
                    LoadingDialog.End();
                }));
            }).Start();
        }