Пример #1
0
        public void Case1_Mix2()//5:5
        {
            DPNProblemContext ctx    = GenerateProblemContext1();
            DpnSolver         solver = new DpnSolver(ctx);

            ctx.SetParameter("ObjectiveType", "MinTotalCost_MaxRevenue_Mix");
            ctx.SetParameter("MinTotalCost_weight", 0.5m);
            ctx.SetParameter("MaxRevenue_weight", 0.5m);
            solver.Logger = Console.Out;
            Console.WriteLine($"旅客到达信息:");
            foreach (CustomerArrival arr in ctx.Pal)
            {
                Console.WriteLine($"旅客{arr.QueueOrder}:{arr.ArriveTime.ToLongTimeString()}(" +
                                  $"{ctx.Wor.Mar.ConvertToInttime(arr.ArriveTime)}),市场:{arr.Customer.MarSegID}");
            }

            solver.OnFeasibleSolutionGenerated = (a, b) =>
            {
                foreach (string str in a)
                {
                    Console.WriteLine(str);
                }
                foreach (string str in b)
                {
                    Console.WriteLine(str);
                }
            };
            solver.OnIterationFinished = (s) =>
            {
            };

            Console.WriteLine($"计算开始:");

            solver.Work();

            Assert.IsTrue(true);
        }
Пример #2
0
        public void Case0_MaxRev()
        {
            DPNProblemContext ctx = GenerateProblemContext0();

            ctx.SetParameter("ObjectiveType", "MaxRevenue");
            DpnSolver solver = new DpnSolver(ctx);

            solver.Logger = Console.Out;
            Console.WriteLine($"旅客到达信息:");
            foreach (CustomerArrival arr in ctx.Pal)
            {
                Console.WriteLine($"旅客{arr.QueueOrder}:{arr.ArriveTime.ToLongTimeString()}(" +
                                  $"{ctx.Wor.Mar.ConvertToInttime(arr.ArriveTime)}),市场:{arr.Customer.MarSegID}");
            }

            solver.OnFeasibleSolutionGenerated = (a, b) =>
            {
                foreach (string str in a)
                {
                    Console.WriteLine(str);
                }
                foreach (string str in b)
                {
                    Console.WriteLine(str);
                }
            };
            solver.OnIterationFinished = (s) =>
            {
            };

            Console.WriteLine($"计算开始:");

            solver.Work();

            Assert.AreEqual(-120 - 240m * 3, Math.Round(solver.ObjValue, 1));
        }