Loading and getting the same solutions everytime
AnsweredI'm working in this minimization model for a academic reasearch, and it takes a lot of time (sometimes days) to find an optimal solution. Thus, I tried saving and loading solutions, so the model runs for 6 hours; I save it and it starts running again from the previous one (so, if the machine shuts down, I don't have giant losses).
The problem is that, sometimes, these 6 hours are not sufficient to my model find a new solution, and it just get a higher BestBd value and lower GAP value.
So, the problem is:
1) I starting running a model without previous solution;
2) After 6 hours, gurobi stops running and I save a first solution (say X, with a gap G);
3) Then, I start running the model again, initializaing all variables (var.Start) with the values I got from the last optimization;
4) The model runs again for 6h hours, but it doesn't find a better solution, it only gets a better gap (say G');
5) I save it again (solution with value X).
6) Then, when my model runs for the third time (let's assume that 6 hour isn't enough), and it loads the previous solution, it will loads again the solution with cost X and gap G. And, again, I'll find the solution X with gap G'.
7) Infinte loop....
Do you have any recommendations? Do I have to add a callback to terminate the model after 6 hours if, and only if, I got a better solution or I can save and load the BestBd value?

Hi André,
Do I have to add a callback to terminate the model after 6 hours if, and only if, I got a better solution
A callback seems like the appropriate solution here. It sounds like you're across it already, but just in case:
How do I use callbacks to terminate the solver?
You can also use the callback to write solutions to file, so that you do not have to terminate the optimization (in case you're under the impression you need to terminate in order to write a solution to file).or I can save and load the BestBd value?
It's not intuitive but feeding known dual bounds to a solver is not beneficial in the same way that providing known solutions is, for reasons outlined in responses to this post on OR StackExchange.
The situation you are describing sounds like you are terminating the optimization, then starting again with a fresh branch and bound tree. I would try and avoid this and continue optimization rather than restarting. If you terminate your optimization using a callback, simply calling the optimize method again will resume the optimization  it will continue with the existing branch and bound tree, and dual bounds, and previous solutions. Likewise if you were to interrupt the optimization in an interactive python session (via Ctrl C or something similar) then you can again resume by running the optimize method.You may also find it worthwhile taking a guess at parameters which could improve the ability to find the solutions faster. This tuning webinar and parameter docs would be a good starting point if you have not dipped your toe into these waters before.
 Riley
0
Please sign in to leave a comment.
Comments
1 comment