public void TestRoomUnsuitabilityConstraint() { var data = Data.ReadXml(dataPath + ITC_Comp05, "120", "4"); //var formulation = ProblemFormulation.UD2; var formulation = ProblemFormulation.UD2; formulation.UnsuitableRoomsWeight = 1; formulation.BadTimeslotsWeight = 1; // formulation.StudentMinMaxLoadWeight = 1; // formulation.OverbookingAllowed = 0.15; var model = new CCTModel(data, formulation); Console.WriteLine("Solving"); model.WriteModel(@"c:\temp\model.lp"); model.Optimize(900); model.WriteModel(@"c:\temp\solution.sol"); var sol = new Solution(data, formulation); sol.SetAssignments(model.GetAssignments()); Console.WriteLine(sol.AnalyzeSolution()); Assert.IsTrue(sol.IsFeasible, "solution should be feasible"); // Assert.AreEqual(5, sol.Objective); }
public void TestSolveComp01ToOptimalityUD2() { var data = Data.ReadXml(dataPath + ITC_Comp01, "120", "4"); var formulation = ProblemFormulation.UD2; var model = new CCTModel(data, formulation); Console.WriteLine("Solving"); model.WriteModel(@"c:\temp\model.lp"); model.Optimize(); model.WriteModel(@"c:\temp\solution.sol"); var sol = new Solution(data, formulation); sol.SetAssignments(model.GetAssignments()); Console.WriteLine(sol.AnalyzeSolution()); Assert.IsTrue(sol.IsFeasible, "solution should be feasible"); Assert.AreEqual(5, sol.Objective); }
public void WriteMPSForTwoIndex(string filename) { var data = Data.ReadXml(dataPath + filename, "120", "4"); var dataset = System.IO.Path.GetFileNameWithoutExtension(filename); var formulation = ProblemFormulation.UD2; var model = new CCTModel(data, formulation, new CCTModel.MIPModelParameters() { UseStageIandII = false, }); model.WriteModel(@"c:\temp\MPS\" + $"{dataset}_2idx.mps"); /* * model.Optimize(); * model.WriteModel(@"c:\temp\solution.sol"); * var sol = new Solution(data,formulation); * sol.SetAssignments(model.GetAssignments()); * Console.WriteLine(sol.AnalyzeSolution()); * Assert.IsTrue(sol.IsFeasible,"solution should be feasible"); * Assert.AreEqual(5,sol.Objective); */ }