public abstract static class IloCplex.LazyConstraintCallback extends IloCplex.ControlCallback
This is an advanced class.
Important:
Advanced classes typically demand a profound understanding of the algorithms used by CPLEX. Thus they incur a higher risk of incorrect behavior in your application, behavior that can be difficult to debug. Therefore, the team encourages you to consider carefully whether you can accomplish the same task by means of other classes instead.
This is the lazy constraint callback class.
Extensions of this class implement user-written lazy constraint
callbacks. These allow you to add lazy constraints to the problem while
the problem is being solved with branch-and-cut search. These lazy
constraints may contribute to the model formulation and restrict the
feasible region of the problem. By contrast, if a constraint to be added
during branch-and-cut search does not change the feasible region of the
active model but only strengthens the formulation, it is referred to
as a user cut. Such constraints should better be added through
IloCplex.UserCutCallback because this distinction allows
IloCplex potentially
to perform more presolve reductions. It is an error,
however, to add lazy constraints by means of a user cut callback.
The idea behind lazy constraints is that the LPs that are solved when
the MIP is being solved can be kept smaller when these constraints are not
included. IloCplex will, however, include a lazy constraint
in the LP as soon as it becomes violated. In other words, the solution
computed by IloCplex makes sure
that all the lazy constraints that have been added are satisfied.
If you use LazyConstraintCallback, you are free to add
cuts that may chop off solutions that are otherwise feasible with
respect to the model, in contrast to UserCutCallback.
In the case of UserCutCallback, you effectively promise
CPLEX that you are not adding cuts that reduce the solution space by
the callback.
When you query information about the current solution to be tested, such information may be different from information directly derived from the node relaxation. Such differences arise when the solution candidate to be tested is generated from a heuristic rather than the branch-and-bound tree itself.
Important:
The lazy constraint callback may be invoked during MIP start processing.
In that case,
IloCplex.LazyConstraintCallback.getSolutionSource()
returns MIPStartSolution. When this value is returned,
some special considerations apply:
IloCplex.MIPCallback.NodeDataIloCplex.Callback.Context, IloCplex.Callback.Function| Modifier | Constructor and Description |
|---|---|
protected |
IloCplex.LazyConstraintCallback()
This is the constructor for user-written lazy constraint callbacks.
|
| Modifier and Type | Method and Description |
|---|---|
protected IloRange |
add(IloRange cut)
Adds
cut as a global lazy constraint to the
problem being solved. |
protected IloRange |
add(IloRange cut,
int cutmanagement)
Adds
cut as a global lazy constraint to the problem
being solved. |
protected IloRange |
addLocal(IloRange cut)
Adds
cut as a local lazy constraint to the problem being solved. |
protected int |
getSolutionSource()
Returns a value that specifies where the potential
incumbent was found.
|
protected boolean |
isUnboundedNode()
This method indicates whether or not the callback was invoked when
the LP relaxation is found to be unbounded and the user needs to test
whether a lazy constraint cuts off the unbounded direction.
|
getDownPseudoCost, getFeasibilities, getFeasibilities, getFeasibility, getLB, getLBs, getLBs, getNodeData, getNodeId, getObjValue, getSlack, getSlacks, getSlacks, getSOSFeasibility, getSOSFeasibility, getUB, getUBs, getUBs, getUpPseudoCost, getValue, getValue, getValues, getValues, setNodeDatagetCurrentNodeDepth, getNodeDoubleInfo, getNodeIntInfo, getNodeLongInfo, getObjCoef, getObjCoefs, getObjCoefsgetBestObjValue, getCutoff, getDirection, getIncumbentObjValue, getIncumbentValue, getIncumbentValue, getIncumbentValues, getIncumbentValues, getMIPRelativeGap, getNcuts, getNiterations, getNiterations64, getNnodes, getNnodes64, getNremainingNodes, getNremainingNodes64, getPriority, getQuality, hasIncumbentgetModel, getNcols, getNQCs, getNrowsabort, getCplexTime, getDetTime, getEndDetTime, getEndTime, getStartDetTime, getStartTime, mainprotected IloCplex.LazyConstraintCallback()
This constructor can be called only to construct objects of derived
user-written callback classes; it cannot be called to construct
IloCplex.LazyConstraintCallback objects directly.
protected IloRange add(IloRange cut) throws IloException
cut as a global lazy constraint to the
problem being solved. As a lazy constraint,
this cut must be globally valid. It will not be removed by backtracking
or any other means during the search.IloExceptioncut - The constraint to be added as a global lazy constraint.
The constraint must be linear.protected IloRange add(IloRange cut, int cutmanagement) throws IloException
cut as a global lazy constraint to the problem
being solved.
As a lazy constraint, this cut must be globally valid.
Possible values for the argument cutmanagement are
documented in IloCplex.CutManagement
with the following considerations:
For lazy constraints, a value of UseCutFilter
is not valid and prompts an exception to be thrown.
A value of UseCutPurge authorizes CPLEX to purge
(that is, eliminate) the lazy constraint under certain circumstances
(for example, if the constraint becomes slack). Consequently,
in view of such purging, the user must not assume that any
previously added constraints are still in the current relaxation.
In other words, the purged constraint may be violated in subsequent
relaxations, and the user must take responsibility to check whether
any new incumbent solution requires that the purged lazy constraint
be added back to the model.
A value of UseCutForce perpetually retains the cut
after it has been added as a lazy constraint. This value is
equivalent to a call of the add method with only a single
argument (that is, the cut to be added as a lazy constraint).
IloExceptioncut - The constraint to be added as a global lazy constraint.
The constraint must be linear.cutmanagement - An integer indicating how the
lazy constraint should be
managed by CPLEX. Possible values are listed in
IloCplex.CutManagement.protected IloRange addLocal(IloRange cut) throws IloException
cut as a local lazy constraint to the problem being solved.
This lazy constraint will not be removed when the search backtracks. In other words, it is active only for the subtree rooted at the invoking node.
IloExceptioncut - The constraint to be added as a local lazy constraint.
The constraint must be linear.protected boolean isUnboundedNode()
protected int getSolutionSource()
For an explanation of the values returned by this method, see
IloCplex.SolutionSource.
Note that lazy constraint callbacks are not invoked for solutions
provided by a heuristic callback. So a value of
IloCplex.SolutionSource.UserSolution
will never be returned.