Lazy constraints and cuts in the same model callback
回答済みLet M be the integer programming model I need to implement using Gurobi and let C be a family of cuts I am willing to add dynamically during the resolution.
Also, the model M contains an exponential family of constraints, therefore I cannot load all of them from the beginning; my strategy is to add them as lazy constraints.
Therefore, I will need to use both lazy constraints and cuts.
At the moment I initially load the model M without any constraint from the exponential family and inside my callback I do as follow (using the Java API):
- When called in `CB_MIPSOL` state, I inspect the current integer solution and load violated constraints from the exponential family (if any) using `cbLazy(...)`
- When called in `CB_MIPNODE` state, I inspect the current relaxed solution and load violated cuts from C (if any) using `addCut(...)`.
Now, afaik a very important assumption that Gurobi makes is that a cut should never eliminate an integer solution that would otherwise be feasible.
Although I am sure that the inequalities in C satisfy this requirement for the model M, I am not sure that they still satisfy this requirement when the model M is partially loaded (without the exponential family of cuts).
What should I do to comply with Gurobi's expectations?
- Is the above approach fine?
- Should I switch to loading all inequalities (both actual lazy constraints and cuts) using `cbLazy(...)`?
- Is there something better?
Thank you a lot!
-
Hi Lorenzo,
The recommended way is to add all cuts that might cut off integer solutions via cbLazy(), even during a user cut callback (which is your option 2).
This also ensures that more cuts are kept in the model and actually considered by the solver, while cuts added by cbCut() might be discarded if they do not meet the solver's conditions (numerics, density, etc.).Best regards,
Mario0
サインインしてコメントを残してください。
コメント
1件のコメント