Skip to main content
FRAMES NO FRAMES

Class IloCplex::ControlCallbackI

Definition file: ilcplex/ilocplexi.h
Map of IloCplex::ControlCallbackIIloCplex::ControlCallbackIIloCplex::BranchCallbackIIloCplex::HeuristicCallbackIIloCplex::LazyConstraintCallbackIIloCplex::SolveCallbackIIloCplex::UserCutCallbackIIloCplex::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.

This class defines the common application programming interface (API) for the following classes that allow you to control the MIP search:

An instance of one of these classes represents a user-written callback that intervenes in the search for a solution at a given node in an application that uses an instance of IloCplex to solve a mixed integer program (MIP). Control callbacks are tied to a node. They are called at each node during IloCplex branch-and-cut search. The user never subclasses the IloCplex::ControlCallbackI class directly; it defines only the common interface of those listed callbacks.

In particular, SolveCallbackI is called before solving the node relaxation and optionally allows substitution of its solution. IloCplex does this by default. Then the node relaxation is solved, either by an instance of SolveCallbackI or by IloCplex. If the solution is integer feasible or the relaxation is unbounded IloCplex::LazyConstraintCallbackI is invoked; otherwise, the other control callbacks are called in the following order:

  1. IloCplex::UserCutCallbackI
  2. IloCplex::HeuristicCallbackI
  3. IloCplex::BranchCallbackI

If the cut callback added new cuts to the node relaxation, the node relaxation will be solved again using the solve callback, if used. The same is true if IloCplex generated its own cuts.

The methods of this class are protected and its constructor is private; you cannot directly subclass this class; you must derive from its subclasses.

If an attempt is made to access information not available to an instance of this class, an exception is thrown.

Unbounded rays

In the case where the node LP is unbounded, the methods getValue return a vector that corresponds to an unbounded direction. The vector is scaled in such a way that the maximum absolute value of one of its elements is CPX_INFBOUND. Thus, often the vector can be used directly, for example to separate lazy constraints. However, due to the large values, care must be taken to deal with potential numerical errors. If in doubt, rescale the vector, and use it as an unbounded ray rather than as a primal vector.

See Also:

Method Summary
public IloNumgetDownPseudoCost(const IloIntVar var) const
public IloNumgetDownPseudoCost(const IloNumVar var) const
public voidgetFeasibilities(ControlCallbackI::IntegerFeasibilityArray stat, const IloIntVarArray var) const
public voidgetFeasibilities(ControlCallbackI::IntegerFeasibilityArray stat, const IloNumVarArray var) const
public ControlCallbackI::IntegerFeasibilitygetFeasibility(const IloIntVar var) const
public ControlCallbackI::IntegerFeasibilitygetFeasibility(const IloNumVar var) const
public ControlCallbackI::IntegerFeasibilitygetFeasibility(const IloSOS2 sos) const
public ControlCallbackI::IntegerFeasibilitygetFeasibility(const IloSOS1 sos) const
public IloNumgetLB(const IloIntVar var) const
public IloNumgetLB(const IloNumVar var) const
public voidgetLBs(IloNumArray val, const IloIntVarArray vars) const
public voidgetLBs(IloNumArray val, const IloNumVarArray vars) const
public NodeData *getNodeData() const
public NodeIdgetNodeId() const
public IloNumgetObjValue() const
public IloNumgetSlack(const IloRange rng) const
public voidgetSlacks(IloNumArray val, const IloRangeArray con) const
public IloNumgetUB(const IloIntVar var) const
public IloNumgetUB(const IloNumVar var) const
public voidgetUBs(IloNumArray val, const IloIntVarArray vars) const
public voidgetUBs(IloNumArray val, const IloNumVarArray vars) const
public IloNumgetUpPseudoCost(const IloIntVar var) const
public IloNumgetUpPseudoCost(const IloNumVar var) const
public IloNumgetValue(const IloIntVar var) const
public IloNumgetValue(const IloNumVar var) const
public IloNumgetValue(const IloExprArg expr) const
public voidgetValues(IloNumArray val, const IloIntVarArray vars) const
public voidgetValues(IloNumArray val, const IloNumVarArray vars) const
public IloBoolisSOSFeasible(const IloSOS2 sos2) const
public IloBoolisSOSFeasible(const IloSOS1 sos1) const
public NodeData *setNodeData(NodeData * data)
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
Inner Enumeration
ControlCallbackI::IntegerFeasibility
Inner Typedef
ControlCallbackI::IntegerFeasibilityArray
Inner Class
ControlCallbackI::PresolvedVariableException
Method Detail

getDownPseudoCost

public IloNum getDownPseudoCost(const IloIntVar var) const

This method returns the current pseudo cost for branching downward on the variable var.


getDownPseudoCost

public IloNum getDownPseudoCost(const IloNumVar var) const

This method returns the current pseudo cost for branching downward on the variable var.


getFeasibilities

public void getFeasibilities(ControlCallbackI::IntegerFeasibilityArray stat, const IloIntVarArray var) const

This method specifies whether each of the variables in the array vars is integer feasible, integer infeasible, or implied integer feasible by putting the status in the corresponding element of the array stats.

Before you query the feasibility of a solution from a solve callback, a solution must exist. That is, you must first create the solution by calling the CPLEX optimization method solve, and then you must verify that the method solve generated a solution by checking its return value before you invoke the method getFeasibilities.


getFeasibilities

public void getFeasibilities(ControlCallbackI::IntegerFeasibilityArray stat, const IloNumVarArray var) const

This method specifies whether each of the variables in the array vars is integer feasible, integer infeasible, or implied integer feasible by putting the status in the corresponding element of the array stats.

Before you query the feasibility of a solution from a solve callback, a solution must exist. That is, you must first create the solution by calling the CPLEX optimization method solve, and then you must verify that the method solve generated a solution by checking its return value before you invoke the method getFeasibilities.


getFeasibility

public ControlCallbackI::IntegerFeasibility getFeasibility(const IloIntVar var) const

This method specifies whether the variable var is integer feasible, integer infeasible, or implied integer feasible in the current node solution.

Before you query the feasibility of a solution from a solve callback, a solution must exist. That is, you must first create the solution by calling the CPLEX optimization method solve, and then you must verify that the method solve generated a solution by checking its return value before you invoke the method getFeasibility.


getFeasibility

public ControlCallbackI::IntegerFeasibility getFeasibility(const IloNumVar var) const

This method specifies whether the variable var is integer feasible, integer infeasible, or implied integer feasible in the current node solution.

Before you query the feasibility of a solution from a solve callback, a solution must exist. That is, you must first create the solution by calling the CPLEX optimization method solve, and then you must verify that the method solve generated a solution by checking its return value before you invoke the method getFeasibility.


getFeasibility

public ControlCallbackI::IntegerFeasibility getFeasibility(const IloSOS2 sos) const

This method specifies whether the Special Ordered Set sos is integer feasible, integer infeasible, or implied integer feasible in the current node solution.

Before you query the feasibility of a solution from a solve callback, a solution must exist. That is, you must first create the solution by calling the CPLEX optimization method solve, and then you must verify that the method solve generated a solution by checking its return value before you invoke the method getFeasibility.


getFeasibility

public ControlCallbackI::IntegerFeasibility getFeasibility(const IloSOS1 sos) const

This method specifies whether the Special Ordered Set sos is integer feasible, integer infeasible, or implied integer feasible in the current node solution.

Before you query the feasibility of a solution from a solve callback, a solution must exist. That is, you must first create the solution by calling the CPLEX optimization method solve, and then you must verify that the method solve generated a solution by checking its return value before you invoke the method getFeasibility.


getLB

public IloNum getLB(const IloIntVar var) const

This method returns the lower bound of var at the current node. This bound is likely to be different from the bound in the original model because an instance of IloCplex tightens bounds when it branches from a node to its subnodes. The corresponding solution value from getValue may violate this bound at a node where a new incumbent has been found because the bound is tightened when an incumbent is found.

Unbounded Variables

If a variable lacks a lower bound, then getLB returns -IloInfinity (that is, the system-specific least value).


getLB

public IloNum getLB(const IloNumVar var) const

This method returns the lower bound of var at the current node. This bound is likely to be different from the bound in the original model because an instance of IloCplex tightens bounds when it branches from a node to its subnodes. The corresponding solution value from getValue may violate this bound at a node where a new incumbent has been found because the bound is tightened when an incumbent is found.

Unbounded Variables

If a variable lacks a lower bound, then getLB returns -IloInfinity (that is, the system-specific least value).


getLBs

public void getLBs(IloNumArray val, const IloIntVarArray vars) const

For each element of the array vars, this method puts the lower bound at the current node into the corresponding element of the array vals. These bounds are likely to be different from the bounds in the original model because an instance of IloCplex tightens bounds when it branches from a node to its subnodes. The corresponding solution values from getValues may violate these bounds at a node where a new incumbent has been found because the bounds are tightened when an incumbent is found.

Unbounded Variables

If a variable lacks a lower bound, then getLBs returns -IloInfinity (that is, the system-specific least value).


getLBs

public void getLBs(IloNumArray val, const IloNumVarArray vars) const

This method puts the lower bound at the current node of each element of the array vars into the corresponding element of the array vals. These bounds are likely to be different from the bounds in the original model because an instance of IloCplex tightens bounds when it branches from a node to its subnodes. The corresponding solution values from getValues may violate these bounds at a node where a new incumbent has been found because the bounds are tightened when an incumbent is found.

Unbounded Variables

If a variable lacks a lower bound, then getLBs returns -IloInfinity (that is, the system-specific least value).


getNodeData

public NodeData * getNodeData() const

This method retrieves the NodeData object that may have previously been assigned to the current node by the user with the method IloCplex::BranchCallbackI::makeBranch. If no data object has been assigned to the current node, the method returns 0 (zero).


getNodeId

public NodeId getNodeId() const

Returns the NodeId of the current node.

See MIPCallbackI::NodeId.


getObjValue

public IloNum getObjValue() const

This method returns the objective value of the solution at the current node.

If you need the object representing the objective itself, consider the method IloCplex::getObjective instead.


getSlack

public IloNum getSlack(const IloRange rng) const

This method returns the slack value for the constraint specified by rng in the solution of the relaxation at the current node.


getSlacks

public void getSlacks(IloNumArray val, const IloRangeArray con) const

For each of the constraints in the array of ranges rngs, this method puts the slack value in the solution of the relaxation at the current node into the corresponding element of the array vals.


getUB

public IloNum getUB(const IloIntVar var) const

This method returns the upper bound of the variable var at the current node. This bound is likely to be different from the bound in the original model because an instance of IloCplex tightens bounds when it branches from a node to its subnodes. The corresponding solution value from getValue may violate this bound at a node where a new incumbent has been found because the bound is tightened when an incumbent is found.

Unbounded Variables

If a variable lacks an upper bound, then getUB returns IloInfinity (that is, the system-specific greatest value).


getUB

public IloNum getUB(const IloNumVar var) const

This method returns the upper bound of the variable var at the current node. This bound is likely to be different from the bound in the original model because an instance of IloCplex tightens bounds when it branches from a node to its subnodes. The corresponding solution value from getValue may violate this bound at a node where a new incumbent has been found because the bound is tightened when an incumbent is found.

Unbounded Variables

If a variable lacks an upper bound, then getUB returns IloInfinity (that is, the system-specific greatest value).


getUBs

public void getUBs(IloNumArray val, const IloIntVarArray vars) const

For each element in the array vars, this method puts the upper bound at the current node into the corresponding element of the array vals. The bounds are those in the relaxation at the current node. These bounds are likely to be different from the bounds in the original model because an instance of IloCplex tightens bounds when it branches from a node to its subnodes. The corresponding solution values from getValues may violate these bounds at a node where a new incumbent has been found because the bounds are tightened when an incumbent is found.

Unbounded Variables

If a variable lacks an upper bound, then getUBs returns IloInfinity (that is, the system-specific greatest value).


getUBs

public void getUBs(IloNumArray val, const IloNumVarArray vars) const

For each element in the array vars, this method puts the upper bound at the current node into the corresponding element of the array vals. The bounds are those in the relaxation at the current node. These bounds are likely to be different from the bounds in the original model because an instance of IloCplex tightens bounds when it branches from a node to its subnodes. The corresponding solution values from getValues may violate these bounds at a node where a new incumbent has been found because the bounds are tightened when an incumbent is found.

Unbounded Variables

If a variable lacks an upper bound, then getUBs returns IloInfinity (that is, the system-specific greatest value).


getUpPseudoCost

public IloNum getUpPseudoCost(const IloIntVar var) const

This method returns the current pseudo cost for branching upward on the variable var.


getUpPseudoCost

public IloNum getUpPseudoCost(const IloNumVar var) const

This method returns the current pseudo cost for branching upward on the variable var.


getValue

public IloNum getValue(const IloIntVar var) const

This method returns the value of the variable var in the solution of the relaxation at the current node.

For special considerations about integrality, truncation, and rounding applicable to this method, see the concept Integer values, integrality tolerance, and round-off in CPLEX Optimizers.


getValue

public IloNum getValue(const IloNumVar var) const

This method returns the value of the variable var in the solution of the relaxation at the current node.


getValue

public IloNum getValue(const IloExprArg expr) const

This method returns the value of the expression expr in the solution of the relaxation at the current node.


getValues

public void getValues(IloNumArray val, const IloIntVarArray vars) const

For each variable in the array vars, this method puts the value in the solution of the relaxation at the current node into the corresponding element of the array vals.

For special considerations about integrality, truncation, and rounding applicable to this method, see the concept Integer values, integrality tolerance, and round-off in CPLEX Optimizers.


getValues

public void getValues(IloNumArray val, const IloNumVarArray vars) const

For each variable in the array vars, this method puts the value in the solution of the relaxation at the current node into the corresponding element of the array vals.


isSOSFeasible

public IloBool isSOSFeasible(const IloSOS2 sos2) const

This method returns IloTrue if the solution of the LP at the current node is SOS feasible for the special ordered set specified in its argument. The SOS set passed as a parameter to this method may be of type 2. See the CPLEX User's Manual for more explanation of types of special ordered sets.

Before you query the feasibility of a solution from a solve callback, a solution must exist. That is, you must first create the solution by calling the CPLEX optimization method solve, and then you must verify that the method solve generated a solution by checking its return value before you invoke the method isSOSFeasible.


isSOSFeasible

public IloBool isSOSFeasible(const IloSOS1 sos1) const

This method returns IloTrue if the solution of the LP at the current node is SOS feasible for the special ordered set specified in its argument. The SOS set passed as a parameter to this method may be of type 1. See the CPLEX User's Manual for more explanation about these types of special ordered sets.

Before you query the feasibility of a solution from a solve callback, a solution must exist. That is, you must first create the solution by calling the CPLEX optimization method solve, and then you must verify that the method solve generated a solution by checking its return value before you invoke the method isSOSFeasible.


setNodeData

public NodeData * setNodeData(NodeData * data)

This method sets the NodeData object assigned to the the current node. If a NodeData object has already been set for the current node, then the method replaces this object and returns the old object. Otherwise, the method returns 0 (zero).


Inner Enumeration Detail

Enumeration IntegerFeasibility

Definition file: ilcplex/ilocplexi.h

The enumeration IloCplex::ControlCallbackI::IntegerFeasibility is an enumeration limited in scope to the class IloCplex::ControlCallbackI. This enumeration is used by IloCplex::ControlCallbackI::getFeasibility to represent the integer feasibility of a variable or SOS in the current node solution:

See Also:

Fields

ImpliedInfeasible = -1 
Feasible = CPX_INTEGER_FEASIBLE 
Infeasible = CPX_INTEGER_INFEASIBLE 
ImpliedFeasible = CPX_IMPLIED_INTEGER_FEASIBLE 

Inner Typedef Detail

Typedef IntegerFeasibilityArray

Definition file: ilcplex/ilocplexi.h

IloArray< IntegerFeasibility > IntegerFeasibilityArray

This type defines an array-type for IloCplex::ControlCallbackI::IntegerFeasibility. The fully qualified name of an integer feasibility array is IloCplex::ControlCallbackI::IntegerFeasibility::Array.

See Also: