public void Lexi_Cost_Soft([Values(
                                        ITC_Comp01,
                                        ITC_Comp05,
                                        ITC_Comp06,
                                        ITC_Comp08,
                                        ITC_Comp12,
                                        ITC_Comp11,
                                        ITC_Comp18,
                                        //more
                                        ITC_Comp02,
                                        ITC_Comp03,
                                        ITC_Comp04,
                                        ITC_Comp07

                                        )] string filename, [Values(false)] bool SpecificQual)
        {
            var algoname = nameof(Lexi_Cost_Soft) + $"_SpecQual_{SpecificQual}";
            //   if (ConsoleToFile)
            //        SetConsoleOutputToFile(@"c:\temp\multiobjective\\logs\\" + filename + "\\" + algoname + ".log");

            var data = Data.ReadXml(dataPath + filename, "120", "4");
            // var newrooms = CreateRooms(data);
            var newrooms = CreateRoomsFixedSize(data, 25, 1);

            data.SetRoomList(newrooms);

            var mipModelParameters = new CCTModel.MIPModelParameters()
            {
                TuneGurobi     = true,
                UseStageIandII = false,
                // UseStageIandII = true,
                UseHallsConditions    = true,
                UseRoomHallConditions = true,
                ConstraintPenalty     = null,
                UseRoomsAsTypes       = true,
            };
            var solver = new MultiObjectiveSolver(data, _problemFormulation, mipModelParameters)
            {
                Timelimit = Timelimit,
                ExtraTimeOnCornerPointsMultiplier = 8,
                UseSpecificObjConstraints         = SpecificQual,
            };

            Console.WriteLine("Algorithm: " + algoname);
            DisplayParameterObject(_problemFormulation);
            DisplayParameterObject(solver);
            DisplayParameterObject(solver.MipParameters);

            double minCost;
            int    maxSoftConsViol;
            int    minCostBound;

            solver.CalcLexMinCostMaxSoft(out minCost, out maxSoftConsViol, out minCostBound);
            Console.WriteLine($"MaxSoft: {maxSoftConsViol} MinCost: {minCost}");
        }
        //   [TestCaseSource(nameof(TestMultiObjTestBed))]
        public void WeightedSumTest([Values(
                                         ITC_Comp05,
                                         ITC_Comp18)] string filename)
        {
            var algoname = nameof(WeightedSumTest);

            if (ConsoleToFile)
            {
                SetConsoleOutputToFile(@"c:\temp\multiobjective\\logs\\" + filename + "\\" + algoname + ".log");
            }

            var data = Data.ReadXml(dataPath + filename, "120", "4");
            // var newrooms = CreateRooms(data);
            var newrooms = CreateRoomsFixedSize(data, 25, 1);

            data.SetRoomList(newrooms);

            var mipModelParameters = new CCTModel.MIPModelParameters()
            {
                TuneGurobi     = true,
                UseStageIandII = false,
                // UseStageIandII = true,
                UseRoomsAsTypes = true,
            };
            //var problemFormulation = ProblemFormulation.EverythingZero;
            //problemFormulation.BadTimeslotsWeight = 1;
            var solver = new MultiObjectiveSolver(data, _problemFormulation, mipModelParameters)
            {
                Timelimit = 120,//Timelimit,
                ExtraTimeOnCornerPointsMultiplier = 1,
                UseEpsilonMethod = false,
                Steps            = 3
            };

            Console.WriteLine("Algorithm: " + algoname);
            DisplayParameterObject(_problemFormulation);
            DisplayParameterObject(solver);
            DisplayParameterObject(solver.MipParameters);

            var pareto = solver.Run();

            WriteSol(@"c:\temp\multiobjective\", filename, data, _problemFormulation, algoname, DateTime.Now.ToString(), pareto);
        }
예제 #3
0
        //   [TestCaseSource(nameof(TestMultiObjTestBed))]
        public void MultiObj3index([Values(
                                        ITC_Comp02)] string filename)
        {
            var algoname = nameof(MultiObj3index) + "3idx";

            if (ConsoleToFile)
            {
                SetConsoleOutputToFile(@"c:\temp\multiobjective\\logs\\" + filename + "\\" + algoname + ".log");
            }

            var data = Data.ReadXml(dataPath + filename, "120", "4");
            // var newrooms = CreateRooms(data);
            var newrooms = CreateRoomsFixedSize(data, 25, 1);

            data.SetRoomList(newrooms);

            var mipModelParameters = new CCTModel.MIPModelParameters()
            {
                TuneGurobi = false, //notice
                //UseStageIandII = false,
                UseStageIandII        = true,
                UseHallsConditions    = true,
                UseRoomHallConditions = true,
                ConstraintPenalty     = null,
                UseRoomsAsTypes       = true,
            };
            var solver = new MultiObjectiveSolver(data, ProblemFormulation.UD2, mipModelParameters)
            {
                Timelimit        = 60,
                EpsilonOnQuality = false,
                ExtraTimeOnCornerPointsMultiplier = 1,
            };

            Console.WriteLine("Algorithm: " + algoname);
            DisplayParameterObject(_problemFormulation);
            DisplayParameterObject(solver);
            DisplayParameterObject(solver.MipParameters);

            var pareto = solver.RunExhaustiveMethod();

            WriteSol(@"c:\temp\multiobjective\", filename, data, _problemFormulation, algoname, DateTime.Now.ToString(), pareto);
        }
예제 #4
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            InitGlobalValue();


            Assembly             assembly = Assembly.GetExecutingAssembly();
            MultiObjectiveSolver impl     = (MultiObjectiveSolver)assembly.CreateInstance("MOEAPlat.Algorithms." + GlobalValue.AlgName);

            impl.div           = GlobalValue.Popsize;
            impl.TotalItrNum   = GlobalValue.MaxGeneration;
            impl.neighbourSize = 20;

            //if ((string)this.combDimension.SelectedItem == "") this.txtObjDimension.Text = "0";
            int obj = GlobalValue.Dimension;

            object[] parameters = null;
            if (obj != 0)
            {
                parameters    = new object[1];
                parameters[0] = obj;
            }

            Type t = Type.GetType("MOEAPlat.Problems." + GlobalValue.MOPName, true);

            MultiObjectiveProblem problem;

            try
            {
                problem = (MultiObjectiveProblem)t.InvokeMember("GetInstance", BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod,
                                                                null, null, parameters);
            }
            catch (Exception ex)
            {
                problem = (MultiObjectiveProblem)t.InvokeMember("GetInstance", BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod,
                                                                null, null, null);
            }

            //if(problem.getObjectiveSpaceDimension() > 3 && problem.getName().IndexOf("DTLZ") == -1)
            //{
            //    MessageBox.Show("only support 2-objective problems");
            //    return;
            //}

            //MultiObjectiveProblem problem = (MultiObjectiveProblem)assembly.CreateInstance("MOEAPlat.Problems."+this.comBoxMOP.SelectedItem,
            //    true, BindingFlags.Default, null, parameters, null, null); ;

            //MultiObjectiveProblem problem = Problems.WFG4_M.GetInstance(15);
            impl.Solve(problem);

            List <double[]> list = FileTool.ReadData("obj");

            if (problem.GetObjectiveSpaceDimension() == 2)
            {
                List <double[]> pof = POF.POF.GetPOF(problem.GetName());
                plot(pof, 0);
                plot(list, 1);
            }
            else
            {
                Mchart.Legends.Clear();
                coordinateplot(list);
            }

            IGDCurve(FileTool.ReadIndicatorData("igdCurve"));
            table(list);
            list.Clear();
        }
예제 #5
0
        //   [TestCaseSource(nameof(TestMultiObjTestBed))]
        public void MultiObjSolveWeighted([Values(
                                               ITC_Comp01,
                                               ITC_Comp02,
                                               ITC_Comp03,
                                               ITC_Comp04,
                                               ITC_Comp05,
                                               ITC_Comp06,
                                               ITC_Comp07,
                                               ITC_Comp08,
                                               ITC_Comp09,
                                               ITC_Comp10,
                                               ITC_Comp11,
                                               ITC_Comp12,
                                               ITC_Comp13,
                                               ITC_Comp14,
                                               ITC_Comp15,
                                               ITC_Comp16,
                                               ITC_Comp17,
                                               ITC_Comp18,
                                               ITC_Comp19,
                                               ITC_Comp20,
                                               ITC_Comp21)] string filename,
                                          [Values(false)] bool classSizeWeightedPenalty)
        {
            var algoname = nameof(MultiObjSolveEpsilon) + $"Weighted_classsizepenalty_{classSizeWeightedPenalty}";

            if (ConsoleToFile)
            {
                SetConsoleOutputToFile(@"c:\temp\multiobjective\\logs\\" + filename + "\\" + algoname + ".log");
            }

            var data = Data.ReadXml(dataPath + filename, "120", "4");
            // var newrooms = CreateRooms(data);
            var newrooms = CreateRoomsFixedSize(data, 25, 1);

            data.SetRoomList(newrooms);

            var mipModelParameters = new CCTModel.MIPModelParameters()
            {
                TuneGurobi     = true,
                UseStageIandII = false,
                // UseStageIandII = true,
                UseHallsConditions         = true,
                UseRoomHallConditions      = true,
                ConstraintPenalty          = 50,
                UseRoomsAsTypes            = true,
                ScalePenaltyWithCourseSize = classSizeWeightedPenalty,
            };
            var solver = new MultiObjectiveSolver(data, _problemFormulation, mipModelParameters)
            {
                Timelimit        = Timelimit,
                UseEpsilonMethod = false,
                ExtraTimeOnCornerPointsMultiplier = 2,
                DoubleSweep = false,
            };

            Console.WriteLine("Algorithm: " + algoname);
            DisplayParameterObject(_problemFormulation);
            DisplayParameterObject(solver);
            DisplayParameterObject(solver.MipParameters);

            var pareto = solver.Run();

            WriteSol(@"c:\temp\multiobjective\", filename, data, _problemFormulation, algoname, DateTime.Now.ToString(), pareto);
        }
예제 #6
0
        //   [TestCaseSource(nameof(TestMultiObjTestBed))]
        public void MultiObjSolveEpsilon([Values(
                                              ITC_Comp01,
                                              ITC_Comp02,
                                              ITC_Comp03,
                                              ITC_Comp04,
                                              ITC_Comp05,
                                              ITC_Comp06,
                                              ITC_Comp07,
                                              ITC_Comp08,
                                              ITC_Comp09,
                                              ITC_Comp10,
                                              ITC_Comp11,
                                              ITC_Comp12,
                                              ITC_Comp13,
                                              ITC_Comp14,
                                              ITC_Comp15,
                                              ITC_Comp16,
                                              ITC_Comp17,
                                              ITC_Comp18,
                                              ITC_Comp19,
                                              ITC_Comp20,
                                              ITC_Comp21
                                              )] string filename,
                                         [Values(false, true)] bool EpsilonOnQuality,
                                         [Values(false)] bool EpsilonRelaxing,
                                         [Values(false)] bool DoubleSweep)
        {
            var algoname = nameof(MultiObjSolveEpsilon) + $"EpsOnQual_{EpsilonOnQuality}_EpsRelax_{EpsilonRelaxing}_doublesweep_{DoubleSweep}";

            if (ConsoleToFile)
            {
                SetConsoleOutputToFile(@"c:\temp\multiobjective\\logs\\" + filename + "\\" + algoname + ".log");
            }

            var data = Data.ReadXml(dataPath + filename, "120", "4");
            // var newrooms = CreateRooms(data);
            var newrooms = CreateRoomsFixedSize(data, 25, 1);

            data.SetRoomList(newrooms);

            var mipModelParameters = new CCTModel.MIPModelParameters()
            {
                TuneGurobi     = true,
                UseStageIandII = false,
                // UseStageIandII = true,
                UseHallsConditions         = true,
                UseRoomHallConditions      = true,
                ConstraintPenalty          = 50,
                UseRoomsAsTypes            = true,
                ScalePenaltyWithCourseSize = false,
            };
            var solver = new MultiObjectiveSolver(data, _problemFormulation, mipModelParameters)
            {
                Timelimit        = (DoubleSweep ? Timelimit / 2 : Timelimit),
                EpsilonOnQuality = EpsilonOnQuality,
                EpsilonRelaxing  = EpsilonRelaxing,
                ExtraTimeOnCornerPointsMultiplier = 2,
                DoubleSweep = DoubleSweep,
                Steps       = 10, //TODO: only zero steps
            };

            Console.WriteLine("Algorithm: " + algoname);
            DisplayParameterObject(_problemFormulation);
            DisplayParameterObject(solver);
            DisplayParameterObject(solver.MipParameters);

            var pareto = solver.Run();

            WriteSol(@"c:\temp\multiobjective\", filename, data, _problemFormulation, algoname, DateTime.Now.ToString(), pareto);
        }
        public void MultiObjectiveRoomStabilityFixedTime(string filename)
        {
            var algoname = nameof(MultiObjectiveRoomStabilityFixedTime);

            if (ConsoleToFile)
            {
                SetConsoleOutputToFile(@"c:\temp\multiobjective\\logs\\" + filename + "\\" + algoname + ".log");
            }


            var data = Data.ReadXml(dataPath + filename, "120", "4");

            var newrooms = CreateRoomsFixedSize(data, 25, 3);

            data.SetRoomList(newrooms);

            var formulation = ProblemFormulation.MinimizeRoomCost;
            // formulation.OverbookingAllowed = 0.25;

            var startmodel = new CCTModel(data, formulation, new CCTModel.MIPModelParameters()
            {
                UseStageIandII        = false,
                TuneGurobi            = true,
                UseHallsConditions    = true,
                UseRoomHallConditions = true,
            });

            startmodel.Optimize(300);
            var fixedTimeSlotAssignments = startmodel.GetAssignments();

            var stageIsol = new Solution(data, formulation);

            stageIsol.SetAssignments(fixedTimeSlotAssignments);
            Console.WriteLine("Assignments of timeslots:");
            Console.WriteLine(stageIsol.AnalyzeSolution());

            //  var newrooms = CreateRooms(data,5);
            // var newrooms = CreateRoomsFixedSize(data, 20);fr


            var problemFormulation = ProblemFormulation.EverythingZero;

            problemFormulation.RoomStabilityWeight = 1;
            //problemFormulation.OverbookingAllowed = 1;
            var mipModelParameters = new CCTModel.MIPModelParameters()
            {
                TuneGurobi     = true,
                UseStageIandII = true,
                // UseStageIandII = true,
                UseHallsConditions    = false,
                UseRoomHallConditions = false,
                NSols             = 100,
                ConstraintPenalty = 50,
                UseRoomsAsTypes   = false,
            };
            var solver = new MultiObjectiveSolver(data, problemFormulation, mipModelParameters)
            {
                Timelimit                = Timelimit,
                MIPGap                   = 0.0,
                Steps                    = 10,
                LocalBranching           = 0,
                EpsilonOnQuality         = false,
                FixedTimeSlotAssignments = fixedTimeSlotAssignments
            };

            Console.WriteLine("Algorithm: " + algoname);
            DisplayParameterObject(problemFormulation);
            DisplayParameterObject(solver);
            DisplayParameterObject(solver.MipParameters);

            var pareto = solver.Run();

            WriteSol(@"c:\temp\multiobjective\", filename, data, problemFormulation, algoname, DateTime.Now.ToString(), pareto);
        }
        public void MultiObjOneObjetive([Values(
                                             ITC_Comp01,
                                             ITC_Comp02,
                                             ITC_Comp03,
                                             ITC_Comp04,
                                             ITC_Comp05,
                                             ITC_Comp06,
                                             ITC_Comp07,
                                             ITC_Comp08,
                                             ITC_Comp09,
                                             ITC_Comp10,
                                             ITC_Comp11,
                                             ITC_Comp12,
                                             ITC_Comp13,
                                             ITC_Comp14,
                                             ITC_Comp15,
                                             ITC_Comp16,
                                             ITC_Comp17,
                                             ITC_Comp18,
                                             ITC_Comp19,
                                             ITC_Comp20,
                                             ITC_Comp21
                                             )]
                                        string filename,
                                        [Values(ProblemFormulation.Objective.MinimumWorkingDaysWeight,
                                                ProblemFormulation.Objective.CurriculumCompactnessWeight,
                                                ProblemFormulation.Objective.BadTimeslots,
                                                ProblemFormulation.Objective.StudentMinMaxLoadWeight)]
                                        ProblemFormulation.Objective objective)
        {
            //ProblemFormulation.Objective objective = ProblemFormulation.Objective.BadTimeslots;

            var algoname = nameof(MultiObjOneObjetive) + "_" + Enum.GetName(objective.GetType(), objective);

            if (ConsoleToFile)
            {
                SetConsoleOutputToFile(@"c:\temp\multiobjective\\logs\\" + filename + "\\" + algoname + ".log");
            }

            var data = Data.ReadXml(dataPath + filename, "120", "4");
            //var newrooms = CreateRooms(data);
            var newrooms = CreateRoomsFixedSize(data, 25, 1);

            data.SetRoomList(newrooms);

            var problemFormulation = ProblemFormulation.EverythingZero;

            problemFormulation.SetWeight(objective, 1);
            //problemFormulation.AvailabilityHardConstraint = false;

            var mipModelParameters = new CCTModel.MIPModelParameters()
            {
                TuneGurobi     = true,
                UseStageIandII = false,
                // UseStageIandII = true,
                UseHallsConditions    = true,
                UseRoomHallConditions = true,
                //ConstraintPenalty = null, //1,
                ConstraintPenalty = 50,
                UseRoomsAsTypes   = true,
            };

            var solver = new MultiObjectiveSolver(data, problemFormulation, mipModelParameters)
            {
                Timelimit        = Timelimit,
                EpsilonOnQuality = true,
                EpsilonRelaxing  = false,
            };

            Console.WriteLine("Algorithm: " + algoname);
            DisplayParameterObject(problemFormulation);
            DisplayParameterObject(solver);
            DisplayParameterObject(solver.MipParameters);
            var pareto = solver.Run();

            WriteSol(@"c:\temp\multiobjective\", filename, data, problemFormulation, algoname, DateTime.Now.ToString(), pareto);
        }
        //   [TestCaseSource(nameof(TestMultiObjTestBed))]
        public void MultiCornerPointsTest([Values(

                                               /*  ITC_Comp01,
                                                * ITC_Comp05,
                                                * ITC_Comp06,
                                                * ITC_Comp08,
                                                * ITC_Comp12,
                                                *   ITC_Comp11,
                                                * ITC_Comp18
                                                */
                                               ITC_Comp01,
                                               ITC_Comp02,
                                               ITC_Comp03,
                                               ITC_Comp04,
                                               ITC_Comp05,
                                               ITC_Comp06,
                                               ITC_Comp07,
                                               ITC_Comp08,
                                               ITC_Comp09,
                                               ITC_Comp10,
                                               ITC_Comp11,
                                               ITC_Comp12,
                                               ITC_Comp13,
                                               ITC_Comp14,
                                               ITC_Comp15,
                                               ITC_Comp16,
                                               ITC_Comp17,
                                               ITC_Comp18,
                                               ITC_Comp19,
                                               ITC_Comp20,
                                               ITC_Comp21
                                               )] string filename,
                                          [Values(true)] bool EpsilonOnQuality,
                                          [Values(true)] bool SpecificQual)
        {
            var algoname = nameof(MultiCornerPointsTest) + $"EpsOnQual_{EpsilonOnQuality}_SpecQual_{SpecificQual}_4timeinstart";

            if (ConsoleToFile)
            {
                SetConsoleOutputToFile(@"c:\temp\multiobjective\\logs\\" + filename + "\\" + algoname + ".log");
            }

            var data = Data.ReadXml(dataPath + filename, "120", "4");
            // var newrooms = CreateRooms(data);
            var newrooms = CreateRoomsFixedSize(data, 25, 1);

            data.SetRoomList(newrooms);

            var mipModelParameters = new CCTModel.MIPModelParameters()
            {
                TuneGurobi     = true,
                UseStageIandII = false,
                // UseStageIandII = true,
                UseHallsConditions    = true,
                UseRoomHallConditions = true,
                ConstraintPenalty     = 50,
                UseRoomsAsTypes       = true,
            };
            var solver = new MultiObjectiveSolver(data, _problemFormulation, mipModelParameters)
            {
                Timelimit                         = Timelimit,
                Steps                             = 0,
                EpsilonOnQuality                  = EpsilonOnQuality,
                UseSpecificObjConstraints         = false,
                ExtraTimeOnCornerPointsMultiplier = 2,
            };

            Console.WriteLine("Algorithm: " + algoname);
            DisplayParameterObject(_problemFormulation);
            DisplayParameterObject(solver);
            DisplayParameterObject(solver.MipParameters);

            var pareto = solver.Run();

            WriteSol(@"c:\temp\multiobjective\", filename, data, _problemFormulation, algoname, DateTime.Now.ToString(), pareto);
        }