public void TestBudgetConstraintWithEnumeration(string filename, int budget, int seed) { var data = Data.ReadXml(dataPath + filename, "120", "4"); var formulation = ProblemFormulation.UD2NoOverbook; var comb = new RoomCombinations(data, 25); Console.WriteLine($"Minimum room is: {comb._minCost}"); var newrooms = CreateRoomsFixedSize(data, 25, 1); data.SetRoomList(newrooms); var model = new CCTModel(data, formulation, new CCTModel.MIPModelParameters() { UseRoomsAsTypes = true, UseStageIandII = false, TuneGurobi = true, Seed = seed, }); //model.WriteModel(@"c:\temp\model.lp"); //var budget = comb._minCost+0; Console.WriteLine($"Budget: {budget}"); model.SetPossibleRoomCombinations(budget); model.Optimize(900); var sol = new Solution(data, formulation); // sol.SetAssignments(model.GetAssignments()); // Console.WriteLine(sol.AnalyzeSolution()); Console.WriteLine($"Room Cost: {model.GetUsedRooms().Sum(kv => kv.Key.Cost*kv.Value)}"); File.AppendAllText(@"c:\temp\enumtest.txt", $"{nameof(TestBudgetConstraintWithEnumeration)};{filename};{seed};{model.Objective}\n"); }
public void PlotNodeSolsWeightedSum(string filename, int maxseats) { var data = Data.ReadXml(dataPath + filename, "120", "4"); var formulation = ProblemFormulation.UD2NoOverbook; var newrooms = CreateRoomsFixedSize(data, 25, 1); data.SetRoomList(newrooms); var model = new CCTModel(data, formulation, new CCTModel.MIPModelParameters() { UseRoomsAsTypes = true, UseStageIandII = false, // TuneGurobi = true, //TuneGurobi = false, SaveBoundInformation = true, //FocusOnlyOnBounds = true, }); // model.SetObjective(0, 1, 0); //model.Optimize(); model.SetObjective(4, 1, 0); // Weighted sum //model.SetObjective(1, 0, 0); //model.SetBudgetConstraint(maxseats); model.SetPossibleRoomCombinations(300, 325); // model.SetBudgetConstraint(325); // model.SetPossibleRoomCombinations(300); // model.SetPossibleRoomCombinations(325); model.Optimize(300); Console.WriteLine($"Cost: {model.ObjCost} Softobj: {model.ObjSoftCons}"); Console.WriteLine(); Console.WriteLine("time;MWD;CC;softobj;obj;cost;bnd;"); Console.WriteLine(String.Join("\n", model.bounds.Select(t => $"{t.Item6};{t.Item1};{t.Item2};{t.Item1+t.Item2};{t.Item3};{t.Item5};{t.Item4}"))); Console.WriteLine($"Last bound: {model.ObjBound}"); }