Using -1 for lazy value gives wrong result
回答済みHello,
I recently integrated lazy constraints into my model. I just tried out some parametrization and especially the value for the Lazy attribute of the constraints I want to specify as such (in my case they are Bender's cuts).
When I compared the results I noticed that the computation time decrease from ~20 minutes to 2 seconds when I specified the Lazy attribute as -1. However, I also noticed that the objective value is significantly better than in the "standard" case (without integrating constraints as lazy). In my case the "standard optimal value" is 19198.1984 and using -1 as value for the Lazy attribute gives 18026.974 (~7% decrease). I did not change the MIPGAP parameter which is why I am really confused as to why the solution is so off. When I set the Lazy Attribute to anything else (0, 1, 2, 3) I do not see a significant change in the objective value.
I am using Gurobi version 12.0.0.
Any help is highly appreciated.
Best regards,
Christian
-
Hello Christian,
Thank you for reaching out to the community forum. We appreciate your contribution.
To respond to your comments around the usage of lazy attribute = -1, have you seen this article: https://support.gurobi.com/hc/en-us/articles/360025804471-What-is-the-difference-between-user-cuts-and-lazy-constraints?
In summary, setting the Lazy attribute to -1 instructs Gurobi to treat the constraint as a user cut. When Gurobi does this, it treats the user cut as optional, and the user cuts are not allowed to cut off integer feasible solutions. When the constraints are integrated as lazy constraints (when the attribute takes one values 1,2, or 3), Gurobi spends additional computation time to check for feasibility and validity of the model; this could also result in cutting off integer feasible solutions, impacting the final objective value.
By way of example, try minimizing a variable x with objective coefficient 1.0, and then toggle between a lazy attribute of -1 and 1, and view the logs for further understanding.
import gurobipy as gp
m = gp.Model()
x = m.addVar(obj=1, vtype="I")
c = m.addConstr(x >= 1)
c.Lazy=-1
m.optimize()
print(f"\n\n{x.X=}")Warm thanks,
Erik H.
0
サインインしてコメントを残してください。
コメント
1件のコメント