public Solution Run() { var stopwatch = Stopwatch.StartNew(); var model = new CCTModel(data, formulation, MIPmodelParameters); model.Optimize(TimelimitStageI - Timetotighten); var userooms = model.GetUsedRooms(); Console.WriteLine($"Used rooms: {userooms.Sum(kv => kv.Value)} over {userooms.Count} "); Console.WriteLine($"OveruseOnTimeslots: {model.GetOverUseOfRooms()} "); // model.PenalizeRoomUsedMoreThanOnce(100); model.PenalizeRoomUsedMoreThanOnce(10, true); model.SetObjective(0, 0, 0.01); //model.SetObjective(0, 0, 0); //model.SetMipHintToCurrent(); model.SetProximityOrigin(); model.SetQualConstraint(model.ObjSoftCons); model.Fixsol(true); model.Optimize(); model.Fixsol(false); // model.Optimize(timetotighten+50,cutoff:500); model.ModelParameters.AbortSolverOnZeroPenalty = true; var tighttimer = Stopwatch.StartNew(); model.Optimize(Timetotighten + 300); tighttimer.Stop(); model.DisplayObjectives(); _solution = new Solution(data, formulation); _solution.SetAssignments(model.GetAssignments()); //timers stopwatch.Stop(); tighttimer.Stop(); totalseconds = (int)stopwatch.Elapsed.TotalSeconds; roomtightseconds = (int)tighttimer.Elapsed.TotalSeconds; return(_solution); }
public void Lex_soft_cost_withTimeslot(string filename) { var algname = nameof(Lex_soft_cost_withTimeslot); // formulation.AvailabilityHardConstraint = false; var data = Data.ReadXml(dataPath + filename, "120", "4"); var newrooms = CreateRoomsFixedSize(data, 25, 5); data.SetRoomList(newrooms); var par = new CCTModel.MIPModelParameters() { UseStageIandII = false, UseHallsConditions = true, UseRoomHallConditions = true, TuneGurobi = false, UseRoomsAsTypes = false, }; var costmodel = new CCTModel(data, ProblemFormulation.MinimizeRoomCost, par); costmodel.Optimize(); data.SetRoomList(costmodel.GetUsedRooms().Where(kv => kv.Value > 0).Select(kv => kv.Key).ToList()); //var formulation = ProblemFormulation.UD2NoOverbook; // formulation.AvailabilityHardConstraint = false; // formulation.OverbookingAllowed = 0.35; var ModelParameters = new CCTModel.MIPModelParameters() { UseStageIandII = false, TuneGurobi = true, UseHallsConditions = true, UseRoomHallConditions = true, // UseRoomsAsTypes = true, UseRoomsAsTypes = false, RoomBoundForEachTimeSlot = true, }; var model = new CCTModel(data, _problemFormulation, ModelParameters); model.Optimize(300); var userooms = model.GetUsedRooms(); Console.WriteLine($"Used rooms: {userooms.Sum(kv => kv.Value)} over {userooms.Count} "); // model.PenalizeRoomUsedMoreThanOnce(100); model.PenalizeRoomUsedMoreThanOnce(1, true); model.SetObjective(0, 0, 0.001); model.SetProximityOrigin(); model.SetQualConstraint(model.ObjSoftCons); // model.SetProxConstraint(20); model.Fixsol(true); model.Optimize(); model.Fixsol(false); model.Optimize(900); model.DisplayObjectives(); var sol = new Solution(data, ProblemFormulation.MinimizeRoomCost); sol.SetAssignments(model.GetAssignments()); Console.WriteLine(sol.AnalyzeSolution()); File.AppendAllText(@"c:\temp\heuristic.txt", $"{algname};{filename};{model.ObjSoftCons}\n"); }