Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get intermediate results of Gurobi optimization

I'm using Gurobi 7.0.2 (+ Python 3.5, i.e., gurobipy) to solve some hard optimization problems (MIPs). Finding optimal results usually takes days or even weeks. It's possible to interrupt Gurobi before having found an optimal solution, i.e., Gap > 0%, and the currently best solution will be returned.

However, it would be much nicer to retrieve such an intermediate result with Gap > 0% but without completely interrupting Gurobi. Gurobi should continue trying to improve the current solution, but I could already start working with the intermediate solution.

Is this possible somehow? If not, please add it to the next Gurobi version.

like image 592
CGFoX Avatar asked Sep 14 '25 14:09

CGFoX


1 Answers

Write a callback function, with where==MIPSOL. Then call Model.cbGetSolution(); see the sample code for Model.cbGetSolution().

like image 92
Greg Glockner Avatar answered Sep 17 '25 03:09

Greg Glockner