How are lazy constraints used?
回答済みHi,
I'm solving a problem structurally similar to the TSP. My current approach solves a relaxed formulation that omits certain complicating constraints upfront. Then, at where == MIPSOL, a callback computes tailored Benders cuts and adds them to the model as lazy constraints. This has significantly improved performance compared to fully restarting the branch-and-bound with those constraints included from the start.
I'm aware that lazy constraints do not strengthen the LP relaxation. That said, I have a few questions about how Gurobi handles them internally.
1.
The documentation states:
"With a value of 1, the constraint can be used to cut off a feasible solution, but it won't necessarily be pulled in if another lazy constraint also cuts off the solution. With a value of 2, all lazy constraints that are violated by a feasible solution will be pulled into the model. With a value of 3, lazy constraints that cut off the relaxation solution at the root node are also pulled in."
How does this apply when lazy constraints are added dynamically via callbacks? Does the parameter value affect how Gurobi re-evaluates previously added lazy constraints at subsequent nodes?
2.
I track how many cuts are added via callbacks, but the number does not match what Gurobi reports:
Cutting planes:
Lazy constraints: 1493
counter:
n_cuts_added: 1787I understand there is a reason for this discrepancy (discussed in another post), but I would like to clarify what exactly Gurobi's count represents: is it the total number of lazy constraints added across all nodes, only at the root node, or only at the node where the optimal solution was found?
Additionally, why are lazy constraints reported under "Cutting planes"? Are the entries listed there cuts derived from those constraints, rather than the constraints themselves?
3.
Once a lazy constraint is added via a callback at a given node:
- Is it propagated to child nodes of that node?
- Does this behavior extend to solutions found via heuristics?
- Is there any upward propagation in the tree?
- Are constraints shared across branches or threads at any point?
-
Hi Federica,
The Lazy attribute is only relevant to constraints that you generate before the solve, so if you're using a callback to add lazy constraints, then you don't have to worry about this attribute.
The cutting planes section will list the cuts at the last node evaluated. This is not necessarily the node where the optimal solution is found - in fact I would say it almost certainly isn't.
We do make a distinction between lazy constraints and lazy cuts, but I wouldn't read into the lazy constraints being listed under cutting planes. This is just for convenience.
Lazy constraints (and lazy cuts) are required to be globally valid. They will be added to a pool, and future solves (whether node LPs or as part of heuristics) will include them. So yes, they are shared across threads and branches, although not always immediately.
There are a couple of reasons why your count might not match what is reported in the log. The first being that a lazy constraint is not needed in the final LP solution, and the other being that you may be counting duplicated lazy constraints (since the threads do not immediately sync the lazy constraint information).
- Riley
0
サインインしてコメントを残してください。
コメント
1件のコメント