Skip to main content
FRAMES NO FRAMES

Class Callback::Context

Definition file: ilcplex/ilocplexi.h
Map of Callback::ContextCallback::ContextCallback::Context

Instances of this class define the context in which the CPLEX generic callback can be invoked.

Method Summary
public voidabort() const
public IloRangeaddUserCut(IloRange cut, IloCplex::CutManagement cutmanagement, IloBool local) const
public voidexitCutLoop() const
public IloNumgetCandidateObjective() const
public IloNumgetCandidatePoint(IloIntVar const & var) const
public IloNumgetCandidatePoint(IloNumVar const & var) const
public voidgetCandidatePoint(IloIntVarArray const & vars, IloNumArray & vals) const
public voidgetCandidatePoint(IloNumVarArray const & vars, IloNumArray & vals) const
public IloNumgetCandidateValue(IloExprArg const & expr) const
public IloNumgetDoubleInfo(Info::Infos what) const
public IloEnvgetEnv() const
public IloNumgetGlobalLB(IloIntVar const & var) const
public IloNumgetGlobalLB(IloNumVar const & var) const
public voidgetGlobalLB(IloIntVarArray const & vars, IloNumArray & vals) const
public voidgetGlobalLB(IloNumVarArray const & vars, IloNumArray & vals) const
public IloNumgetGlobalUB(IloIntVar const & var) const
public IloNumgetGlobalUB(IloNumVar const & var) const
public voidgetGlobalUB(IloIntVarArray const & vars, IloNumArray & vals) const
public voidgetGlobalUB(IloNumVarArray const & vars, IloNumArray & vals) const
public CPXLONGgetId() const
public IloNumgetIncumbent(IloIntVar const & var) const
public IloNumgetIncumbent(IloNumVar const & var) const
public voidgetIncumbent(IloIntVarArray const & vars, IloNumArray & vals) const
public voidgetIncumbent(IloNumVarArray const & vars, IloNumArray & vals) const
public IloNumgetIncumbentObjective() const
public IloNumgetIncumbentValue(IloExprArg const & expr) const
public CPXINTgetIntInfo(Info::Infos what) const
public IloNumgetLocalLB(IloIntVar const & var) const
public IloNumgetLocalLB(IloNumVar const & var) const
public voidgetLocalLB(IloIntVarArray const & vars, IloNumArray & vals) const
public voidgetLocalLB(IloNumVarArray const & vars, IloNumArray & vals) const
public IloNumgetLocalUB(IloIntVar const & var) const
public IloNumgetLocalUB(IloNumVar const & var) const
public voidgetLocalUB(IloIntVarArray const & vars, IloNumArray & vals) const
public voidgetLocalUB(IloNumVarArray const & vars, IloNumArray & vals) const
public CPXLONGgetLongInfo(Info::Infos what) const
public IloNumgetRelaxationObjective() const
public IloNumgetRelaxationPoint(IloIntVar const & var) const
public IloNumgetRelaxationPoint(IloNumVar const & var) const
public voidgetRelaxationPoint(IloIntVarArray const & vars, IloNumArray & vals) const
public voidgetRelaxationPoint(IloNumVarArray const & vars, IloNumArray & vals) const
public IloCplex::CplexStatusgetRelaxationStatus(CPXLONG flags) const
public IloNumgetRelaxationValue(IloExprArg const & expr) const
public IloBoolinBranching() const
public IloBoolinCandidate() const
public IloBoolinGlobalProgress() const
public IloBoolinLocalProgress() const
public IloBoolinRelaxation() const
public IloBoolinThreadDown() const
public IloBoolinThreadUp() const
public IloBoolisCandidatePoint() const
public IloBoolisCandidateRay() const
public CPXLONGmakeBranch(IloRangeArray const & constraints, IloNum estimate) const
public CPXLONGmakeBranch(IloIntVar const & branchVar, IloNum bound, IloCplex::BranchDirection dir, IloNum estimate) const
public CPXLONGmakeBranch(IloNumVar const & branchVar, IloNum bound, IloCplex::BranchDirection dir, IloNum estimate) const
public CPXLONGmakeBranch(IloIntVarArray const & vars, IloNumArray const & bounds, IloCplex::BranchDirectionArray const & dirs, IloNum estimate) const
public CPXLONGmakeBranch(IloNumVarArray const & vars, IloNumArray const & bounds, IloCplex::BranchDirectionArray const & dirs, IloNum estimate) const
public CPXLONGmakeBranch(IloIntVarArray const & vars, IloNumArray const & bounds, IloCplex::BranchDirectionArray const & dirs, IloRangeArray const & constraints, IloNum estimate) const
public CPXLONGmakeBranch(IloNumVarArray const & vars, IloNumArray const & bounds, IloCplex::BranchDirectionArray const & dirs, IloRangeArray const & constraints, IloNum estimate) const
public voidpostHeuristicSolution(IloIntVarArray const & vars, IloNumArray const & vals, double obj, SolutionStrategy::Types strat) const
public voidpostHeuristicSolution(IloNumVarArray const & vars, IloNumArray const & vals, double obj, SolutionStrategy::Types strat) const
public voidpruneCurrentNode() const
public IloRangerejectCandidate(IloRange violated=0) const
public voidrejectCandidate(IloRangeArray const & violated) const
public IloRangerejectCandidateLocal(IloRange violated) const
public voidrejectCandidateLocal(IloRangeArray const & violated) const
Inner structs
Context::Id
Context::Info
Context::SolutionStrategy
Method Detail

abort

public void abort() const

This method stops optimization. A call of this method instructs CPLEX to halt optimization as soon as possible after the callback returns.


addUserCut

public IloRange addUserCut(IloRange cut, IloCplex::CutManagement cutmanagement, IloBool local) const

This method adds a user-defined cut. The method creates a deep copy of all IloRange instances passed to it, so you can invoke the method end on the ranges after the method returns.

how CPLEX should manage the cut.

Parameters:

cut
The cut to add.
cutmanagement
A value from IloCplex::CutManagement that specifies how CPLEX should manage the cut.
local
A Boolean value specifying whether this cut is locally or globally valid.

Returns:

Always returns cut.

exitCutLoop

public void exitCutLoop() const

This method asks CPLEX to stop cutting plane separation at the current node.

.

This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation; it throws an exception when invoked from another context.


getCandidateObjective

public IloNum getCandidateObjective() const

This method accesses the objective of the current candidate solution. This method can be invoked only from the context IloCplex::Callback::Context::Id::Candidate; it throws an exception when invoked from another context.

Returns:

The objective value of the current candidate solution.

getCandidatePoint

public IloNum getCandidatePoint(IloIntVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::getCandidatePoint(IloIntVarArray const&, IloNumArray &). (See the documentation of that method for more detail.) This method retrieves the candidate solution value for a single variable.

Parameters:

var
The variable for which to query the value.

Returns:

The value for var in the current candidate solution.

getCandidatePoint

public IloNum getCandidatePoint(IloNumVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::getCandidatePoint(IloNumVarArray const&, IloNumArray & />. (See the documentation of that method for more detail.) This method retrieves the candidate solution value for a single variable.

Parameters:

var
The variable for which to query the value.

Returns:

The value for var in the current candidate solution.

getCandidatePoint

public void getCandidatePoint(IloIntVarArray const & vars, IloNumArray & vals) const

This method accesses a candidate solution. It retrieves the values for vars[start], . . . , vars[start+length-1] in the current candidate and returns them. This method can be invoked only from the context IloCplex::Callback::Context::Id::Candidate and if IloCplex::Callback::Context:isCandidatePoint() returns true; it throws an exception when invoked from another context.

Parameters:

vars
The variables for which values are to be queried.
vals
Where to store the values for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the value for the i-th variable in vars. Note that the method resizes vals appropriately.

getCandidatePoint

public void getCandidatePoint(IloNumVarArray const & vars, IloNumArray & vals) const

This method accesses the candidate solution. It retrieves the values for vars[start], . . . , vars[start+length-1] in the current candidate and returns them. This method can be invoked only from the context IloCplex::Callback::Context::Id::Candidate and if IloCplex::Callback::Context::isCandidatePoint() returns true; it throws an exception when invoked from another context.

Parameters:

vars
The variables for which values are to be queried.
vals
Where to store the values for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the value for the i-th variable in vars. Note that the method resizes vals appropriately.

getCandidateValue

public IloNum getCandidateValue(IloExprArg const & expr) const

This method evaluates expr with respect to the current candidate solution. This method can be invoked only in the context IloCplex::Callback::Context::Id::Candidate and if IloCplex::Callback::Context::isCandidatePoint() returns true.

Parameters:

expr
The expression to evaluate.

Returns:

The value of expr with respect to the current candidate solution.

getDoubleInfo

public IloNum getDoubleInfo(Info::Infos what) const

This method accesses double-precision valued information. See the documentation of the Info struct for details about what information can be queried.

Parameters:

what
The information to be queried.

Returns:

The requested information.

getEnv

public IloEnv getEnv() const

This method accesses an instance of IloEnv that is valid for use during a callback. Use the environment object returned by this method (instead of the global instance of IloEnv) for everything that your application does in a callback.


getGlobalLB

public IloNum getGlobalLB(IloIntVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::Context::getGlobalLB(IloIntVarArray const&, IloIntArray &). (See the documentation of that method for more detail.) This method retrieves the global lower bound for a single variable.

Parameters:

var
The variable for which to query the local bound.

Returns:

The local bound for var.

getGlobalLB

public IloNum getGlobalLB(IloNumVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::Context::getGlobalLB(IloNumVarArray const&, IloNumArray &). (See the documentation of that method for more detail.) This method retrieves the global lower bound for a single variable.

Parameters:

var
The variable for which to query the local bound.

Returns:

The local bound for var.

getGlobalLB

public void getGlobalLB(IloIntVarArray const & vars, IloNumArray & vals) const

This method accesses the global lower bounds for variables. This methods queries the best known globally valid bounds.

This method cannot be invoked from the context IloCplex::Callback::Context::Id::ThreadUp or IloCplex::Callback::Context::Id::ThreadDown.

Parameters:

vars
The variables for which lower bounds should be queried.
vals
Where to store the local bounds for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the global bound for the i-th variable in vars. Note that the method resizes vals appropriately.

getGlobalLB

public void getGlobalLB(IloNumVarArray const & vars, IloNumArray & vals) const

This method accesses the global lower bounds for variables. This methods queries the best known globally valid bounds.

This method cannot be invoked from the context IloCplex::Callback::Context::Id::ThreadUp or IloCplex::Callback::Context::Id::ThreadDown.

Parameters:

vars
The variables for which lower bounds should be queried.
vals
Where to store the local bounds for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the global bound for the i-th variable in vars. Note that the method resizes vals appropriately.

getGlobalUB

public IloNum getGlobalUB(IloIntVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::Context::getGlobalUB(IloIntVarArray const&, IloNumArray &). (See the documentation of that method for more detail.) This method retrieves the global upper bound for a single variable.

Parameters:

var
The variable for which to query the local bound.

Returns:

The local bound for var.

getGlobalUB

public IloNum getGlobalUB(IloNumVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::Context::getGlobalUB(IloNumVarArray const&, IloNumArray &)' />. (See the documentation of that method for more detail.) This method retrieves the global upper bound for a single variable.

Parameters:

var
The variable for which to query the local bound.

Returns:

The local bound for var.

getGlobalUB

public void getGlobalUB(IloIntVarArray const & vars, IloNumArray & vals) const

This method accesses the global upper bounds for variables. This method queries the best known globally valid bounds.

This method cannot be invoked from the context IloCplex::Callback::Context::Id::ThreadUp or IloCplex::Callback::Context::Id::ThreadDown.

Parameters:

vars
The variables for which upper bounds should be queried.
vals
Where to store the local bounds for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the global bound for the i-th variable in vars. Note that the method resizes vals appropriately.

getGlobalUB

public void getGlobalUB(IloNumVarArray const & vars, IloNumArray & vals) const

This method accesses the global upper bounds for variables. This method queries the best known globally valid bounds.

This method cannot be invoked from the context IloCplex::Callback::Context::Id::ThreadUp or IloCplex::Callback::Context::Id::ThreadDown.

Parameters:

vars
The variables for which upper bounds should be queried.
vals
Where to store the local bounds for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the global bound for the i-th variable in vars. Note that the method resizes vals appropriately.

getId

public CPXLONG getId() const

This method accesses the context in which the corresponding callback was invoked.

Returns:

A value from IloCplex::Callback::Context::Id that specifies the context in which this instance was invoked.

getIncumbent

public IloNum getIncumbent(IloIntVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::getIncumbent(IloIntVarArray const&, IloNumArray &). (See the documentation of that method for more detail.) This method retrieves the incumbent solution value for a single variable.

Parameters:

var
The variable for which to query the value.

Returns:

The value for var in the current incumbent solution.

getIncumbent

public IloNum getIncumbent(IloNumVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::getIncumbent(IloNumVarArray const&, IloNumArray &). (See the documentation of that method for more detail.) This method retrieves the incumbent solution value for a single variable.

Parameters:

var
The variable for which to query the value.

Returns:

The value for var in the current incumbent solution.

getIncumbent

public void getIncumbent(IloIntVarArray const & vars, IloNumArray & vals) const

This method accesses the current incumbent solution. It retrieves the values for vars[start], . . . , vars[start+length-1] in the current incumbent solution and returns them. The method raises an exception if there is no incumbent solution available. Use the method IloCplex::Callback::getIntInfo with the value Info::Feasible to check whether an incumbent is available.

Parameters:

vars
The variables for which incumbent values are to be queried.
vals
Where to store the values for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the value for the i-th variable in vars. Note that the method resizes vals appropriately.

getIncumbent

public void getIncumbent(IloNumVarArray const & vars, IloNumArray & vals) const

This method accesses the current incumbent solution. It retrieves the values for vars[start], . . . , vars[start+length-1] in the current incumbent solution and returns them. The method raises an exception if there is no incumbent solution available. Use the method IloCplex::Callback::getIntInfo with the value Info::Feasible to check whether an incumbent is available.

Parameters:

vars
The variables for which incumbent values are to be queried.
vals
Where to store the values for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the value for the i-th variable in vars. Note that the method resizes vals appropriately.

getIncumbentObjective

public IloNum getIncumbentObjective() const

This method access the objective value for the current incumbent.

Returns:

The objective for the current incumbent; if there is currently no incumbent, the return value can be infinite (represented by a value such as 1e75).

getIncumbentValue

public IloNum getIncumbentValue(IloExprArg const & expr) const

This method evaluates expr with respect to the current incumbent solution.

Parameters:

expr
The expression to evaluate.

Returns:

The value of expr with respect to the current incumbent solution.

getIntInfo

public CPXINT getIntInfo(Info::Infos what) const

This method accesses 32-bit, signed, integer-valued information. See the documentation of the Info struct for details about what information can be queried.

Parameters:

what
The information to be queried.

Returns:

The requested information.

getLocalLB

public IloNum getLocalLB(IloIntVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::Context::getLocalLB(IloIntVarArray const&, IloIntArray &). (See the documentation of that method for more detail.) This method retrieves the local lower bound for a single variable.

Parameters:

var
The variable for which to query the local bound.

Returns:

The local bound for var.

getLocalLB

public IloNum getLocalLB(IloNumVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::Context::getLocalLB(IloNumVarArray const&, IloNumArray &). (See the documentation of that method for more detail.) This method retrieves the local lower bound for a single variable.

Parameters:

var
The variable for which to query the local bound.

Returns:

The local bound for var.

getLocalLB

public void getLocalLB(IloIntVarArray const & vars, IloNumArray & vals) const

This method accesses the local lower bounds for variables. This methods queries the local bounds that were in place when the current relaxation was computed. These bounds can be tighter than global bounds due to presolve, branching, and other activity.

This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation; it throws an exception when invoked from another context.

Parameters:

vars
The variables for which lower bounds should be queried.
vals
Where to store the local bounds for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the local bound for the i-th variable in vars. Note that the method resizes vals appropriately.

getLocalLB

public void getLocalLB(IloNumVarArray const & vars, IloNumArray & vals) const

This method accesses the local lower bounds for variables. This methods queries the local bounds that were in place when the current relaxation was computed. These bounds can be tighter than global bounds due to presolve, branching, and other activity.

This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation; it throws an exception when invoked from another context.

Parameters:

vars
The variables for which lower bounds should be queried.
vals
Where to store the local bounds for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the local bound for the i-th variable in vars. Note that the method resizes vals appropriately.

getLocalUB

public IloNum getLocalUB(IloIntVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::Context::getLocalUB(IloIntVarArray const&, IloNumArray &). (See the documentation of that method for more detail.) This method retrieves the local upper bound for a single variable.

Parameters:

var
The variable for which to query the local bound.

Returns:

The local bound for var.

getLocalUB

public IloNum getLocalUB(IloNumVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::Context::getLocalUB(IloNumVarArray const&, IloNumArray &)' />. (See the documentation of that method for more detail.) This method retrieves the local upper bound for a single variable.

Parameters:

var
The variable for which to query the local bound.

Returns:

The local bound for var.

getLocalUB

public void getLocalUB(IloIntVarArray const & vars, IloNumArray & vals) const

This method accesses the local upper bounds for variables. This method queries the local bounds that were in place when the current relaxation was computed. These bounds may be tighter than global bounds due to presolve, branching, and other activity.

This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation; it throws an exception when invoked from another context.

Parameters:

vars
The variables for which upper bounds should be queried.
vals
Where to store the local bounds for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the local bound for the i-th variable in vars. Note that the method resizes vals appropriately.

getLocalUB

public void getLocalUB(IloNumVarArray const & vars, IloNumArray & vals) const

This method accesses the local upper bounds for variables. This method queries the local bounds that were in place when the current relaxation was computed. These bounds may be tighter than global bounds due to presolve, branching, and other activity.

This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation; it throws an exception when invoked from another context.

Parameters:

vars
The variables for which upper bounds should be queried.
vals
Where to store the local bounds for the variables in vars.

Returns:

Upon successful return, the i-th value in vals specifies the local bound for the i-th variable in vars. Note that the method resizes vals appropriately.

getLongInfo

public CPXLONG getLongInfo(Info::Infos what) const

This method accesses 64-bit, signed, integer-valued information. See the documentation of the Info struct for details about what information can be queried.

Parameters:

what
The information to be queried.

Returns:

The requested information.

getRelaxationObjective

public IloNum getRelaxationObjective() const

This method accesses the objective of the current relaxation.

This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation or IloCplex::Callback::Context::Id::Branching; it throws an exception when invoked from another context.

Returns:

The objective value of the current relaxation.

getRelaxationPoint

public IloNum getRelaxationPoint(IloIntVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::getRelaxationPoint(IloIntVarArray const&, IloNumArray &). (See the documentation of that method for more detail.) This method retrieves the relaxation solution value for a single variable.

Parameters:

var
The variable for which to query the value.

Returns:

The value for var in the current relaxation solution.

getRelaxationPoint

public IloNum getRelaxationPoint(IloNumVar const & var) const

This method is a convenience wrapper for the method IloCplex::Callback::getRelaxationPoint(IloNumVarArray const&, IloNumArray &). (See the documentation of that method for more detail.) This method retrieves the relaxation solution value for a single variable.

Parameters:

var
The variable for which to query the value.

Returns:

The value for var in the current relaxation solution.

getRelaxationPoint

public void getRelaxationPoint(IloIntVarArray const & vars, IloNumArray & vals) const

This method accesses the current relaxation. It retrieves the values for vars[start], . . . , vars[start+length-1] in the current relaxation and returns them. This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation or IloCplex::Callback::Context::Id::Branching; it throws an exception when invoked from another context.

Parameters:

vars
The variables for which relaxation values are to be queried.
vals
Where to store the values for the variables in vars.

Returns:

Upon successful return, the i-th value in vals will specify the value for the i-th variable in vars. Note that the method resizes vals appropriately.

getRelaxationPoint

public void getRelaxationPoint(IloNumVarArray const & vars, IloNumArray & vals) const

This method accesses the current relaxation. It retrieves the values for vars[start], . . . , vars[start+length-1] in the current relaxation and returns them. This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation or IloCplex::Callback::Context::Id::Branching; it throws an exception when invoked from another context.

Parameters:

vars
The variables for which relaxation values are to be queried.
vals
Where to store the values for the variables in vars.

Returns:

Upon successful return, the i-th value in vals will specify the value for the i-th variable in vars. Note that the method resizes vals appropriately.

getRelaxationStatus

public IloCplex::CplexStatus getRelaxationStatus(CPXLONG flags) const

This method accesses the solution status of the current continous solution. See the documentation of CPXXcallbackgetrelaxationstatus in the callable library reference manual for further details.

This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation or IloCplex::Callback::Context::Id::Branching; it throws an exception when invoked from another context.

CPXXcallbackgetrelaxationstatus for values that can be passed here.

Parameters:

flags
See the documentation of CPXXcallbackgetrelaxationstatus for values that can be passed here.

Returns:

The solution status of the current continuous relaxation.

getRelaxationValue

public IloNum getRelaxationValue(IloExprArg const & expr) const

This method evaluates expr with respect to the current relaxation. This method can be invoked only in the context IloCplex::Callback::Context::Id::Relaxation or IloCplex::Callback::Context::Id::Branching.

Parameters:

expr
The expression to evaluate.

Returns:

The value of expr with respect to the current relaxation.

inBranching

public IloBool inBranching() const

This method tests whether the callback was invoked in the context IloCplex::Callback::Context::Id::Branching.

It is a shortcut for getId() == IloCplex::Callback::Context::Id::Branching

Returns:

true if the callback was invoked in the context IloCplex::Callback::Context::Id::Branching and false otherwise.

inCandidate

public IloBool inCandidate() const

This method tests whether the callback was invoked in the context IloCplex::Callback::Context::Id::Candidate.

It is a shortcut for getId() == IloCplex::Callback::Context::Id::Candidate

Returns:

true if the callback was invoked in the context IloCplex::Callback::Context::Id::Candidate and false otherwise.

inGlobalProgress

public IloBool inGlobalProgress() const

This method tests whether the callback was invoked in the context IloCplex::Callback::Context::Id::GlobalProgress.

It is a shortcut for getId() == IloCplex::Callback::Context::Id::GlobalProgress

Returns:

true if the callback was invoked in the context IloCplex::Callback::Context::Id::GlobalProgress and false otherwise.

inLocalProgress

public IloBool inLocalProgress() const

This method tests whether the callback was invoked in the context IloCplex::Callback::Context::Id::LocalProgres.

It is a shortcut for getId() == IloCplex::Callback::Context::Id::LocalProgress

Returns:

true if the callback was invoked in the context IloCplex::Callback::Context::Id::LocalProgress and false otherwise.

inRelaxation

public IloBool inRelaxation() const

This method tests whether the callback was invoked in the context IloCplex::Callback::Context::Id::Relaxation.

It is a shortcut for getId() == IloCplex::Callback::Context::Id::Relaxation

Returns:

true if the callback was invoked in the context IloCplex::Callback::Context::Id::Relaxation and false otherwise.

inThreadDown

public IloBool inThreadDown() const

This method tests whether the callback was invoked in the context IloCplex::Callback::Context::Id::ThreadDown.

It is a shortcut for getId() == IloCplex::Callback::Context::Id::ThreadDown

Returns:

true if the callback was invoked in the context IloCplex::Callback::Context::Id::ThreadDown and false otherwise.

inThreadUp

public IloBool inThreadUp() const

This method tests whether the callback was invoked in the context IloCplex::Callback::Context::Id::ThreadUp.

It is a shortcut for getId() == IloCplex::Callback::Context::Id::ThreadUp

Returns:

true if the callback was invoked in the context IloCplex::Callback::Context::Id::ThreadUp and false otherwise.

isCandidatePoint

public IloBool isCandidatePoint() const

This method tests whether the callback was invoked in context IloCplex::Callback::Context::Id::Candidate with a candidate feasible point.

If the function returns true, then you can call IloCplex::Callback::Context::getCandidatePoint(), IloCplex::Callback::Context::getCandidateValue(), and IloCplex::Callback::Context::getCandidateObjective() to query the potentially feasible point.

Returns:

True if the callback was invoked for a feasible point, false otherwise.

isCandidateRay

public IloBool isCandidateRay() const

This method tests whether the callback was invoked in context IloCplex::Callback::Context::Id::Candidate with an unbounded ray.

If the function returns true, then you can call IloCplex::Callback::Context::getCandidateRay() to query the unbounded ray.

Returns:

True if the callback was invoked for an unbounded ray, false otherwise.

makeBranch

public CPXLONG makeBranch(IloRangeArray const & constraints, IloNum estimate) const

Convenience wrapper for makeBranch(IloIntVarArray const &, IloNumArray const &, IloCplex::BranchDirectionArray const &, IloRangeArray const &, IloNum).

The function creates a branch that is defined only by a set of constraints.


makeBranch

public CPXLONG makeBranch(IloIntVar const & branchVar, IloNum bound, IloCplex::BranchDirection dir, IloNum estimate) const

Convenience wrapper for makeBranch(IloIntVarArray const &, IloNumArray const &, IloCplex::BranchDirectionArray const &, IloRangeArray const &, IloNum).

The function creates a branch that is defined by only branching on a single variable.


makeBranch

public CPXLONG makeBranch(IloNumVar const & branchVar, IloNum bound, IloCplex::BranchDirection dir, IloNum estimate) const

Convenience wrapper for makeBranch(IloNumVarArray const &, IloNumArray const &, IloCplex::BranchDirectionArray const &, IloRangeArray const &, IloNum).

The function creates a branch that is defined by only branching on a single variable.


makeBranch

public CPXLONG makeBranch(IloIntVarArray const & vars, IloNumArray const & bounds, IloCplex::BranchDirectionArray const & dirs, IloNum estimate) const

Convenience wrapper for makeBranch(IloIntVarArray const &, IloNumArray const &, IloCplex::BranchDirectionArray const &, IloRangeArray const &, IloNum).

The function creates a branch that is defined only by bound changes.


makeBranch

public CPXLONG makeBranch(IloNumVarArray const & vars, IloNumArray const & bounds, IloCplex::BranchDirectionArray const & dirs, IloNum estimate) const

Convenience wrapper for makeBranch(IloNumVarArray const &, IloNumArray const &, IloCplex::BranchDirectionArray const &, IloRangeArray const &, IloNum).

The function creates a branch that is defined only by bound changes.


makeBranch

public CPXLONG makeBranch(IloIntVarArray const & vars, IloNumArray const & bounds, IloCplex::BranchDirectionArray const & dirs, IloRangeArray const & constraints, IloNum estimate) const

This method creates a custom branch at the current node.

The method creates the branch as specified by the arguments. It is fine to branch only on variables (in which case constraints can be empty) or only on constraints (in which case vars, bounds, dirs can be empty).

This method can be invoked only from the context IloCplex::Callback::Context::Id::Branching; it throws an exception when invoked from another context.

At most two branches can be created at a node.

vars. The elements in this array must be in 1-to-1-correspondence with the elements in vars. The elements in this array must be in 1-to-1-correspondence with the elements in vars. If the direction is IloCplex::BranchUp then the corresponding element in bounds specifies a lower bound on the corresponding variable in vars, otherwise it specifies an upper bound. of the new child. Often a reasonable choice is the objective value of the current node's relaxation.

Parameters:

vars
The variables on which to branch.
bounds
The bounds for branching on the variables in vars. The elements in this array must be in 1-to-1-correspondence with the elements in vars.
dirs
The branching directions for the variables. The elements in this array must be in 1-to-1-correspondence with the elements in vars. If the direction is IloCplex::BranchUp then the corresponding element in bounds specifies a lower bound on the corresponding variable in vars, otherwise it specifies an upper bound.
constraints
The constraints on which to branch.
estimate
An estimate for the objective value of the relaxation of the new child. Often a reasonable choice is the objective value of the current node's relaxation.

Returns:

A unique identifier for the newly created child. This corresponds to the value returned by IloCplex::Callback::Context::Info:NodeUID.

makeBranch

public CPXLONG makeBranch(IloNumVarArray const & vars, IloNumArray const & bounds, IloCplex::BranchDirectionArray const & dirs, IloRangeArray const & constraints, IloNum estimate) const

This method creates a custom branch at the current node.

The method creates the branch as specified by the arguments. It is fine to branch only on variables (in which case constraints can be empty) or only on constraints (in which case vars, bounds, dirs can be empty).

This method can be invoked only from the context IloCplex::Callback::Context::Id::Branching; it throws an exception when invoked from another context.

At most two branches can be created at a node.

vars. The elements in this array must be in 1-to-1-correspondence with the elements in vars. The elements in this array must be in 1-to-1-correspondence with the elements in vars. If the direction is IloCplex::BranchUp then the corresponding element in bounds specifies a lower bound on the corresponding variable in vars, otherwise it specifies an upper bound. of the new child. Often a reasonable choice is the objective value of the current node's relaxation.

Parameters:

vars
The variables on which to branch.
bounds
The bounds for branching on the variables in vars. The elements in this array must be in 1-to-1-correspondence with the elements in vars.
dirs
The branching directions for the variables. The elements in this array must be in 1-to-1-correspondence with the elements in vars. If the direction is IloCplex::BranchUp then the corresponding element in bounds specifies a lower bound on the corresponding variable in vars, otherwise it specifies an upper bound.
constraints
The constraints on which to branch.
estimate
An estimate for the objective value of the relaxation of the new child. Often a reasonable choice is the objective value of the current node's relaxation.

Returns:

A unique identifier for the newly created child. This corresponds to the value returned by IloCplex::Callback::Context::Info:NodeUID.

postHeuristicSolution

public void postHeuristicSolution(IloIntVarArray const & vars, IloNumArray const & vals, double obj, SolutionStrategy::Types strat) const

This method posts a (heuristic) solution to CPLEX. Specifically, the method posts a solution vector to CPLEX. The vector is queued internally. Before CPLEX invokes a heuristic, CPLEX looks at the queue and attempts to create a feasible solution from each vector. This activity can result in new incumbent solutions.

Parameters:

vars
Variables that constitute the solution to be posted.
vals
Values for variables in vars.
obj
(Estimated) objective value for the new solution.
strat
Strategy for completing partial solutions.

postHeuristicSolution

public void postHeuristicSolution(IloNumVarArray const & vars, IloNumArray const & vals, double obj, SolutionStrategy::Types strat) const

This method posts a (heuristic) solution to CPLEX. Specifically, the method posts a solution vector to CPLEX. The vector is queued internally. Before CPLEX invokes a heuristic, CPLEX looks at the queue and attempts to create a feasible solution from each vector. This activity can result in new incumbent solutions.

Parameters:

vars
Variables that constitute the solution to be posted.
vals
Values for variables in vars.
obj
(Estimated) objective value for the new solution.
strat
Strategy for completing partial solutions.

pruneCurrentNode

public void pruneCurrentNode() const

This method prunes the current search tree node.

The node for which the callback was invoked is pruned, no further children are created from it. Subsequent calls to makeBranch for this node are ignored.

This method can be invoked only from the context IloCplex::Callback::Context::Id::Relaxation or IloCplex::Callback::Context::Id::Branching; it throws an exception when invoked from another context.


rejectCandidate

public IloRange rejectCandidate(IloRange violated=0) const

This method rejects the current candidate solution. This method is a convenience wrapper for the method IloCplex::Callback::rejectCandidate(IloRangeArray). (See the documentation of that method for more detail.)

The method creates a deep copy of the IloRange instance passed to it, so you can invoke the end method after this method returns.

can be null.

Parameters:

violated
A constraint that cuts off the candidate solution. This argument can be null.

Returns:

Always returns violated.

rejectCandidate

public void rejectCandidate(IloRangeArray const & violated) const

This method rejects the current candidate solution. This method can be invoked only from the context IloCplex::Callback::Context::Id::Candidate; it throws an exception when invoked from another context.

The function creates a deep copy of all IloRange instances passed to it, so it is ok to invoke the method end on those ranges after the function returns.

the candidate solution. This argument may also be null. If not null and not empty, then CPLEX may use these constraints to cut off further candidate solutions that it finds. (There is no guarantee that it does so, though.) These constraints are essentially lazy constraints. None of the elements in this array is allowed to be an empty handle (use an empty array to reject without constraints),

Parameters:

violated
A potentially empty set of constraints that cut off the candidate solution. This argument may also be null. If not null and not empty, then CPLEX may use these constraints to cut off further candidate solutions that it finds. (There is no guarantee that it does so, though.) These constraints are essentially lazy constraints. None of the elements in this array is allowed to be an empty handle (use an empty array to reject without constraints),

rejectCandidateLocal

public IloRange rejectCandidateLocal(IloRange violated) const

This method rejects the current candidate solution. This method is a convenience wrapper for the method IloCplex::Callback::rejectCandidateLocal(IloRangeArray). (See the documentation of that method for more detail.)

The method creates a deep copy of the IloRange instance passed to it, so you can invoke the end method after this method returns.

Parameters:

violated
A constraint that cuts off the candidate solution locally.

Returns:

Always returns violated.

rejectCandidateLocal

public void rejectCandidateLocal(IloRangeArray const & violated) const

This method rejects the current candidate solution. This method can be invoked only from the context IloCplex::Callback::Context::Id::Candidate and only if the callback was invoked for an integral node (see CandidateSource); it throws an exception when invoked from another context.

The function creates a deep copy of all IloRange instances passed to it, so it is ok to invoke the method end on those ranges after the function returns.

The passed constraints are not required to be globally valid. CPLEX only assumes them to be valid in the subtree in which the callback was invoked.

The parameter violated is a potentially empty set of constraints that cut off the candidate solution. This argument may also be null. If not null and not empty, then CPLEX may use these constraints to cut off further candidate solutions that it finds. (There is no guarantee that it does so, though.) These constraints are essentially lazy constraints. None of the elements in this array is allowed to be an empty handle (use an empty array to reject without constraints). The constraints are not required to be globally valid. CPLEX only assumes them to be valid in the subtree in which the callback was invoked.


Inner Struct Detail

Struct Context::Id

Definition file: ilcplex/ilocplexi.h

This struct designates places in which a CPLEX generic callback can be invoked. The values defined here specify in which contexts CPLEX can invoke a callback. They are used in two different ways:

For details about the various context values, see the reference manual of the Callable Library (C API).

Important notes about the ThreadDown context:

Think of ThreadUp and ThreadDown as "constructor" and "destructor": the destructor is invoked only if the object was fully constructed and is not allowed to throw an exception.

Attribute Summary
static CPXLONG constBranching
static CPXLONG constCandidate
static CPXLONG constGlobalProgress
static CPXLONG constLocalProgress
static CPXLONG constRelaxation
static CPXLONG constThreadDown
static CPXLONG constThreadUp
Attribute Detail

Branching

static CPXLONG const Branching

See the documentation of CPX_CALLBACKCONTEXT_BRANCHING in the reference manual of the Callable Library (C API).


Candidate

static CPXLONG const Candidate

See the documentation of CPX_CALLBACKCONTEXT_CANDIDATE in the reference manual of the Callable Library (C API).


GlobalProgress

static CPXLONG const GlobalProgress

See the documentation of CPX_CALLBACKCONTEXT_GLOBAL_PROGRESS in the reference manual of the Callable Library (C API).


LocalProgress

static CPXLONG const LocalProgress

See the documentation of CPX_CALLBACKCONTEXT_LOCAL_PROGRESS in the reference manual of the Callable Library (C API).


Relaxation

static CPXLONG const Relaxation

See the documentation of CPX_CALLBACKCONTEXT_RELAXATION in the reference manual of the Callable Library (C API).


ThreadDown

static CPXLONG const ThreadDown

See the documentation of CPX_CALLBACKCONTEXT_THREAD_DOWN in the reference manual of the Callable Library (C API).


ThreadUp

static CPXLONG const ThreadUp

See the documentation of CPX_CALLBACKCONTEXT_THREAD_UP in the reference manual of the Callable Library (C API).


Struct Context::Info

Definition file: ilcplex/ilocplexi.h

This struct provides an enum of identifiers for the kinds of information that you can retrieve from a generic callback by invoking one (or more) of the generic callback informational methods.

Inner Enumeration
Info::Infos
Inner Enumeration Detail

Enumeration Infos

Definition file: ilcplex/ilocplexi.h

This enum identifies the kinds of information that your application can retrieve from a generic callback by means of the methods IloCple::Callback::getIntInfo(Info), IloCplex::Callback::getLongInfo(Info), or IloCplex::Callback::getDoubleInfo(Info). See documentation of the enumeration CPXCALLBACKINFO in the reference manual of the Callable Library (C API) for further details about these values.

Fields

ThreadId = CPXCALLBACKINFO_THREADID
See CPXCALLBACKINFO_THREADID in the callable library reference manual.
NodeCount = CPXCALLBACKINFO_NODECOUNT
See CPXCALLBACKINFO_NODECOUNT in the callable library reference manual.
IterationCount = CPXCALLBACKINFO_ITCOUNT
See CPXCALLBACKINFO_ITCOUNT in the callable library reference manual.
BestSolution = CPXCALLBACKINFO_BEST_SOL
See CPXCALLBACKINFO_BEST_SOL in the callable library reference manual.
BestBound = CPXCALLBACKINFO_BEST_BND
See CPXCALLBACKINFO_BEST_BND in the callable library reference manual.
Threads = CPXCALLBACKINFO_THREADS
See CPXCALLBACKINFO_THREADS in the callable library reference manual.
Feasible = CPXCALLBACKINFO_FEASIBLE
See CPXCALLBACKINFO_FEASIBLE in the callable library reference manual.
Time = CPXCALLBACKINFO_TIME
See CPXCALLBACKINFO_TIME in the callable library reference manual.
DeterministicTime = CPXCALLBACKINFO_DETTIME
See CPXCALLBACKINFO_DETTIME in the callable library reference manual.
NodeUID = CPXCALLBACKINFO_NODEUID
See CPXCALLBACKINFO_NODEUID in the callable library reference manual.
NodeDepth = CPXCALLBACKINFO_NODEDEPTH
See CPXCALLBACKINFO_NODEDEPTH in the callable library reference manual.
CandidateSource = CPXCALLBACKINFO_CANDIDATE_SOURCE
See CPXCALLBACKINFO_CANDIDATE_SOURCE in the callable library reference manual.
Restarts = CPXCALLBACKINFO_RESTARTS AfterCutLoop = CPXCALLBACKINFO_AFTERCUTLOOP
See CPXCALLBACKINFO_RESTARTS in the callable library reference manual.
NodesLeft = CPXCALLBACKINFO_NODESLEFT
See CPXCALLBACKINFO_NODESLEFT in the callable library reference manual.

Struct Context::SolutionStrategy

Definition file: ilcplex/ilocplexi.h

This struct defines an enum that provides identifiers for the various completion strategies that can be passed to the method IloCplex::Callback::Context::postHeuristicSolution.

For more detail, see the documentation of the enumeration CPXCALLBACKSOLUTIONSTRATEGY in the reference manual of the Callable Library (C API) of CPLEX.

Inner Enumeration
SolutionStrategy::Types
Inner Enumeration Detail

Enumeration Types

Definition file: ilcplex/ilocplexi.h

This enum identifies completion strategies for CPLEX to use with the method IloCplex::Callback::Context::postHeuristicSolution.

If you pass a complete solution to this method, that is, the solution specifies a value for every variable in the model, then CPLEX can check the feasibility of that complete solution.

Possibly the arguments that you passed to that method specify only a partial solution. In such a case, CPLEX can attempt to complete the partial solution by means of bound propagation.

For more detail about these completion strategies, see the documentation of the enumeration CPXCALLBACKSOLUTIONSTRATEGY in the reference manual of the Callable Library (C API) of CPLEX.

Fields

NoCheck = CPXCALLBACKSOLUTION_NOCHECK
See CPXCALLBACKSOLUTION_NOCHECK in the callable library reference manual.
CheckFeasible = CPXCALLBACKSOLUTION_CHECKFEAS
See CPXCALLBACKSOLUTION_CHECKFEAS in the callable library reference manual.
Propagate = CPXCALLBACKSOLUTION_PROPAGATE
See CPXCALLBACKSOLUTION_PROPAGATE in the callable library reference manual.
Solve = CPXCALLBACKSOLUTION_SOLVE
See CPXCALLBACKSOLUTION_SOLVE in the callable library reference manual.