public abstract static class IloCplex.IncumbentCallback extends IloCplex.MIPCallback
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.
An instance of this callback class is called whenever a new potential incumbent is found during the branch-and-cut search. It allows you to analyze the proposed incumbent and optionally reject it. In this case, CPLEX will continue the branch-and-cut search. However, since CPLEX considers the current node solution to be integer feasible, it will not be able to determine a reasonable way to branch. Thus, when this callback is implemented in such a way that it may reject an incumbent, it is typically paired with a branch callback to perform the branching after an incumbent has been rejected.
When you use this callback to reject an incumbent, you must set
the parameter to control the type of primal and dual reductions,
IloCplex.IntParam.Reduce
either to 1 (one) in order to restrict presolve to
primal reductions only, or to 0 (zero) in order to disable all
presolve reductions. This setting of the reduction parameter is not
necessary if the incumbent callback is used for other purposes.
The constructor and methods of this class are protected to
make sure that they
are used only to derive a user-written callback class or to implement
the main method in it.
Important:
The incumbent callback may be invoked during MIP start processing.
In that case,
IloCplex.IncumbentCallback.getSolutionSource()
will return
MIPStartSolution. In this situation, the following
special consideration applies:
IloCplex.MIPCallbackIloCplex.MIPCallback.NodeDataIloCplex.Callback.Context, IloCplex.Callback.Function| Modifier | Constructor and Description |
|---|---|
protected |
IloCplex.IncumbentCallback()
Constructor for user-written incumbent callback.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
getNodeData()
Returns the user object attached to the current node.
|
protected IloCplex.NodeId |
getNodeId()
Returns the node identifier of the current node.
|
protected double |
getObjValue()
Returns the objective value of the potential incumbent.
|
protected double |
getSlack(IloRange rng)
Returns the slack value of a constraint for the proposed incumbent
solution.
|
protected double[] |
getSlacks(IloRange[] rng)
Returns the slack values for an array of constraints for the proposed
incumbent solution.
|
protected double[] |
getSlacks(IloRange[] rng,
int start,
int num)
Returns the slack values for
num consecutive
constraints, starting from the index specified by start,
in the array rng
for the proposed incumbent solution. |
protected int |
getSolutionSource()
Returns a value that specifies where the potential
incumbent was found.
|
protected double |
getValue(IloNumExpr expr)
Returns the value
expr takes for the
proposed incumbent solution. |
protected double |
getValue(IloNumVar var)
Returns the value of the variable
var in the potential
incumbent solution. |
protected double[] |
getValues(IloNumVar[] var)
Returns the values of variables in the array
var
in the potential incumbent solution. |
protected double[] |
getValues(IloNumVar[] var,
int start,
int num)
Returns the values of
num consecutive variables,
starting from the index specified by start, in the array
var of variables in the potential incumbent solution. |
protected void |
reject()
Rejects the proposed incumbent solution.
|
protected java.lang.Object |
setNodeData(java.lang.Object data)
Sets the user object attached to the current node.
|
getCurrentNodeDepth, 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.IncumbentCallback()
This constructor can be called only to construct objects of
derived user-written callback classes, but not to construct
IloCplex.IncumbentCallback objects directly.
protected int getSolutionSource()
For an explanation of the values returned by this method, see
IloCplex.SolutionSource.
protected double getObjValue()
throws IloException
IloExceptionprotected double getValue(IloNumVar var) throws IloException
var in the potential
incumbent solution.IloExceptionvar - The variable whose value is to be returned.var in the potential incumbent
solution.protected double[] getValues(IloNumVar[] var) throws IloException
var
in the potential incumbent solution.IloExceptionvar - The array of variables whose values are required.var. If the
the returned array is val, val[j]
is the proposed incumbent value for the variable
var[j].protected double[] getValues(IloNumVar[] var, int start, int num) throws IloException
num consecutive variables,
starting from the index specified by start, in the array
var of variables in the potential incumbent solution.IloExceptionvar - The array containing the variables whose proposed
incumbent values are being queried.start - The index of the first variable in
the array var
for which the proposed incumbent value is requested.num - The number of consecutive variables in
the array var
for which the proposed incumbent value is requested.var.
If the returned array is val,
val[j] is the proposed incumbent value for
variable var[j+start].protected double getValue(IloNumExpr expr) throws IloException
expr takes for the
proposed incumbent solution.IloExceptionexpr - The expression for which to evaluate the proposed
incumbent solution.expr takes for the solution
of the proposed incumbent solution.protected double getSlack(IloRange rng) throws IloException
IloExceptionrng - The constraint whose slack value is being queried.rng for the
proposed incumbent solution.protected double[] getSlacks(IloRange[] rng) throws IloException
IloExceptionrng - An array of constraints whose slack values
are being queried.s, s[i] contains the
slack value for constraint rng[i].protected double[] getSlacks(IloRange[] rng, int start, int num) throws IloException
num consecutive
constraints, starting from the index specified by start,
in the array rng
for the proposed incumbent solution.IloExceptionrng - An array containing the constraints whose
slack values are being queried.start - The index of the first constraint in rng
for which to query the slack values.num - The number of consecutive constraints
in rng for which
to query the slack values.s, s[i] contains the
slack value for constraint rng[i+start].protected IloCplex.NodeId getNodeId() throws IloException
IloExceptionprotected java.lang.Object getNodeData()
throws IloException
IloCplex.BranchCallback.makeBranch in a branch callback.IloExceptionnull will
be returned.protected java.lang.Object setNodeData(java.lang.Object data)
throws IloException
IloExceptiondata - The user object to be attached to the current node.protected void reject()