public void TestCombinations(string filename) { var data = Data.ReadXml(dataPath + filename, "120", "4"); var comb = new RoomCombinations(data, 25); for (var i = 0; i < comb._minCost; i += 25) { var combinations = comb.GetCombinations(comb._minCost + i); var rooms = CreateRoomsFromIntList(data, combinations); if (combinations.Count == 0) { continue; } Console.WriteLine($"{i}: {combinations.Count}"); Console.WriteLine(rooms.Count); Console.WriteLine(string.Join(",", combinations.First().Keys)); foreach (var combination in combinations) { Console.WriteLine(string.Join(",", combination.Values)); } if (combinations.Count > 1000) { break; } } }
public void ThresholdBehvaiour(string filename) { 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, }); var seatscal = new RoomCombinations(data, 25); var CriticalSeats = seatscal._minCost; // model.SetObjective(0, 1, 0); //model.Optimize(); // model.SetObjective(8, 1, 0); // Weighted sum model.SetObjective(1, 0, 0); model.SetBudgetConstraint(CriticalSeats); model.Optimize(300); 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}"); }
public void MaximizeRoomUtilizationSimplemodel(string filename) { var data = Data.ReadXml(dataPath + filename, "120", "4"); Console.WriteLine($"Dataset: {data.Name}"); Console.WriteLine($"Courses: {data.Courses.Count} Lectures: {data.Courses.Sum(c => c.Lectures)}"); var formulation = ProblemFormulation.MinimizeRoomCost; var newrooms = CreateRooms(data); data.SetRoomList(newrooms); var model = new RoomChoose(data, formulation); model.Optimize(); var usedrooms = model.GetUsedRooms(); DisplayRoomStats("optimizedLowerBound", usedrooms, data); var roomcalc = new RoomCombinations(data); Assert.LessOrEqual(Math.Abs(roomcalc._minCost - usedrooms.Sum(r => r.Key.Cost * r.Value)), 1e-1, "something wrong"); }
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"); }