I am using Google OR-Tools with a CBC_MIXED_INTEGER_PROGRAMMING solver.
Most of the time, the solver finds the optimal solution in less than 20 seconds, but sometimes it takes several minutes to find it. It can guess really fast a good estimate of the solution but finding the optimal the solution takes ages.
My first idea was to set a simple time limit to return the best solution found after 30 seconds:
solver = pywraplp.Solver('scheduling_solver', pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
solver.SetTimeLimit(30*1000) # 30 seconds time limit
Unfortunately, the solution found at that point might be too far from the optimal solution.
Is it possible to:
Many thanks in advance,
Romain
The main issue here is to combine the different requirements while respecting the priority of these rules.
This is how I fixed the issue:
Using this strategy, you ensure that:
This is extremely useful when most of the runs can find an optimal solution very fast but get stuck for ages when this is not the case. In particular, when an acceptable solution is easily found.
Cons: you need to run the model twice.
Pros: In my case, the optimal solution is retrieved most of the time instead of always returning the first solution that simply satisfies the GAP limit.