Skip to main content
FRAMES NO FRAMES

Class IloCplex::LazyConstraintCallbackI

Definition file: ilcplex/ilocplexi.h
Map of IloCplex::LazyConstraintCallbackIIloCplex::LazyConstraintCallbackIIloCplex::LazyConstraintCallbackIIloCplex::ControlCallbackIIloCplex::MIPCallbackIIloCplex::MIPInfoCallbackIIloCplex::OptimizationCallbackIIloCplex::CallbackI
Note

This is an advanced class. 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.

An instance of the class IloCplex::LazyConstraintCallbackI represents a user-written callback in an application that uses an instance of IloCplex to solve a MIP while applying lazy constraints. IloCplex calls the user-written callback when either a candidate feasible solution is found, and the candidate needs to be tested whether it violates any lazy constraints; or the LP relaxation is found to be unbounded, and a lazy constraint may cut off the unbounded direction.

When querying 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.

Note

The lazy constraint callback may be invoked during MIP start processing. In that case 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.

See Also:

Method Summary
public IloConstraintadd(IloConstraint con, IloCplex::CutManagement purgeable=UseCutForce)
public IloConstraintaddLocal(IloConstraint con)
public IncumbentCallbackI::SolutionSourcegetSolutionSource() const
protected Callback::TypegetType() const
public IloBoolisUnboundedNode() const
Inherited Methods from ControlCallbackI
getDownPseudoCost, getDownPseudoCost, getFeasibilities, getFeasibilities, getFeasibility, getFeasibility, getFeasibility, getFeasibility, getLB, getLB, getLBs, getLBs, getNodeData, getNodeId, getObjValue, getSlack, getSlacks, getUB, getUB, getUBs, getUBs, getUpPseudoCost, getUpPseudoCost, getValue, getValue, getValue, getValues, getValues, isSOSFeasible, isSOSFeasible, setNodeData
Inherited Methods from MIPCallbackI
getCurrentNodeDepth, getObjCoef, getObjCoef, getObjCoefs, getObjCoefs, getType, getUserThreads, MIPCallbackI
Inherited Methods from MIPInfoCallbackI
getBestObjValue, getCutoff, getDirection, getDirection, getIncumbentObjValue, getIncumbentSlack, getIncumbentSlacks, getIncumbentValue, getIncumbentValue, getIncumbentValue, getIncumbentValues, getIncumbentValues, getMIPRelativeGap, getMyThreadNum, getNcuts, getNiterations, getNiterations64, getNnodes, getNnodes64, getNremainingNodes, getNremainingNodes64, getPriority, getPriority, getQuality, getType, hasIncumbent, MIPInfoCallbackI
Inherited Methods from OptimizationCallbackI
getModel, getNcols, getNQCs, getNrows
Inherited Methods from CallbackI
abort, duplicateCallback, getCplexTime, getDetTime, getEndDetTime, getEndTime, getEnv, getStartDetTime, getStartTime, getType, main
Method Detail

add

public IloConstraint add(IloConstraint con, IloCplex::CutManagement purgeable=UseCutForce)

This method adds a lazy constraint to the current node LP subproblem for the constraint specified by con. This lazy constraint must be globally valid. The added lazy constraint must be linear. It will not be removed by backtracking. The lazy constraint that this method adds is a deep copy of the argument con.

Depending on the value of the argument purgeable, CPLEX removes the lazy constraint during branch and cut under certain circumstances.

Special considerations:

When you use this method with the nondefault value UseCutPurge for the argument purgeable, you are authorizing CPLEX to purge (that is, to eliminate) the lazy constraint under certain circumstances (for example, if the constraint becomes slack). Consequently, in view of such purging, you must not assume that any previously added constraints are still in the current relaxation. In other words, the purged constraint can be violated in subsequent relaxations. As a user, you must take responsibility to check whether any new incumbent solution requires that the purged constraint be added back to the problem.

Parameters:

con

The constraint to be added as lazy. This method (in contrast to IloCplex::add) creates a deep copy of the argument con; that is, subsequent modifications of con do not modify the added constraint.

purgeable

A value specifying when and whether CPLEX can remove this lazy constraint.

Returns:

The routine always returns con.


addLocal

public IloConstraint addLocal(IloConstraint con)

This method adds a local lazy constraint to the current node LP subproblem for the constraint specified by con. IloCplex will manage the local lazy constraint in such a way that it will be active only when CPLEX is processing nodes of this subtree. That is, the added lazy constraint is local. The added lazy constraint must be linear. The lazy constraint that this method adds is a deep copy of the argument con.

Parameters:

con

The constraint to be added locally as lazy. This method (in contrast to IloCplex::add) creates a deep copy of the argument con; that is, subsequent modifications of con do not modify the added constraint.

Returns:

The routine always returns con.


getSolutionSource

public IncumbentCallbackI::SolutionSource getSolutionSource() const

This method returns the source of the solution for which the callback was invoked.

Note that lazy constraint callbacks are not invoked for solutions provided by the heuristic callback. So a value of UserSolution will never be returned.


isUnboundedNode

public IloBool isUnboundedNode() const

This method returns IloTrue if 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; and it returns IloFalse if the callback was invoked to test whether a feasible solution candidate found at this search tree node satisfies all lazy constraints.


getType

protected Callback::Type getType() const

This method returns the callback type of the invoking callback object.