Namespace: ILOG.CPLEX
Assembly: ILOG.CPLEX (in ILOG.CPLEX.dll) Version: 22.1.1.0
Syntax
| C# |
|---|
public abstract class LazyConstraintCallback : Cplex..::..ControlCallback |
| Visual Basic |
|---|
Public MustInherit Class LazyConstraintCallback _ Inherits Cplex..::..ControlCallback |
Remarks
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 Cplex.UserCutCallback because this distinction allows Cplex 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. Cplex will, however, include a lazy constraint in the LP as soon as it becomes violated. In other words, the solution computed by Cplex 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, {@link Cplex.LazyConstraintCallback#getSolutionSource() Cplex.LazyConstraintCallback.GetSolutionSource()} returns MIPStartSolution. When this value is returned, some special considerations apply:
- MIP start processing occurs very early in the solution process. At this point no search tree is setup yet and there are no search tree nodes yet. Consequently, a lot of the callback functions that require a node context will fail in this situation.
- Lazy constraints separated when processing a MIP start will be discarded after that MIP start has been processed. This means that the callback may have to separate the same constraint again for the next MIP start or for a solution that is found later in the solution process.
Inheritance Hierarchy
ILOG.CPLEX..::..Cplex..::..Callback
ILOG.CPLEX..::..Cplex..::..OptimizationCallback
ILOG.CPLEX..::..Cplex..::..MIPInfoCallback
ILOG.CPLEX..::..Cplex..::..MIPCallback
ILOG.CPLEX..::..Cplex..::..ControlCallback
ILOG.CPLEX..::..Cplex..::..LazyConstraintCallback