Lazy Constraints and Re-optimization
OngoingHello,
I am working on a problem where I use MIP's to find the optimal solution. Given the data by the user, I construct the constraints and optimize the mathematical program, while adding lazy constraints in the callback whenever they are violated. This way I can find optimal solutions to my problem.
My problem is, sometimes I need to re-optimize the mathematical program, after adding new variables and change the objective function. To test this approach, I simply re-set the objective to its current value (in my case that is the sum of a set of variables) and ran the optimization process again. I was expecting the same (or an even better) solution, but I got a worse one that doesn't satisfy the lazy constraints. My guess is that, since the previous solution was optimal, Gurobi found a new solution with the same objective value and simply returned it as optimal.
First of all, does Gurobi forget the lazy constraints it used, right after the optimization ? If that's the case, is there a way to add these constraints to the model permanently, so that the subsequent optimization procedures can make use of them ? Finally, is there a way to apply lazy constraints after an optimal solution is found ? Right now I am adding them in the MIPNODE callback.
Hope that made sense. Thank you in advance,
Baris
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
I just tested this and found that you'll have to re-add the lazy constraints, for every reoptimization. To answer your questions:
- Gurobi "forgets" lazy constraints right after the optimization
- There doesn't appear to be a way to automatically add lazy constraints to the model permanently.
- You should consider using MIPSOL instead of MIPNODE if you're interested in optimal solutions.
0 -
Hi,
I have been asking myself the same. If Gurobi doesn't have memory of past lazy constraints, is there another way to add constraints using a callback such that they stay in the model when re-optimizing?
0
Post is closed for comments.
Comments
3 comments