Wrong values of best incumbent objective value
AnsweredI am solving an MILP in Python with Gurobi and using a callback to add lazy constraints. I require that the callback be invoked for integer solutions only, hence I use,
if where == GRB.Callback.MIPSOL:
X={i:model.cbGetSolution(i) for i in model.getVars()}
OBJ=model.cbGet(GRB.Callback.MIPSOL_OBJ)
LB=model.cbGet(GRB.Callback.MIPSOL_OBJBND)
BS=gpars.best_obj
BS2=model.cbGet(GRB.Callback.MIPSOL_OBJBST)
But it is strange that both GRB.Callback.MIPSOL_OBJ and GRB.Callback.MIPSOL_OBJBST keep giving me the same exact number, even when there is no incumbent solution in the model. Even when I already have a integer feasible solution (and objective) accepted by Gurobi (after going through callback), these two still keep having the same value. Is there any way to get the "correct" best incumbent objective value?
For example, the best integer solution accepted so far has Obj of 100. I have a callback which is now invoked for a new potentially incumbent solution (since lazy cuts can reject the solution) with Obj=80. So, ideally in the current invocation, the Objective must be 80, and best incumbent objective must be 100. But I keep getting the same values for both of them.
-
Hi Ankan,
We can reproduce what you described. Our development team will investigate this further. We will update you then.
Thanks for your patience,
Marika0 -
Thanks. Let me know.
0 -
Hi Ankan,
Thanks for pointing out this issue! Our developers fixed the bug. The fix will be part of the release 10.0.2 available probably in Q2 or Q3 of this year.
As a workaround for the time being you might need to store the last objective by yourselfdef mycallback(model, where):
if where == gp.GRB.Callback.MIPSOL:
obj = model.cbGet(gp.GRB.Callback.MIPSOL_OBJ)
# in case of lazy constraints, make sure they are all satisfied
model._currentbest = objBest regards,
Marika0 -
Hi Ankan,
The new release 10.0.2 is now available on our website in which the issue is fixed.
Best regards,
Marika0
Please sign in to leave a comment.
Comments
4 comments