|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ilog.cplex.IloCplex.Callback | +--ilog.cplex.IloCplex.MIPCallback | +--ilog.cplex.IloCplex.ControlCallback | +--ilog.cplex.IloCplex.HeuristicCallback
The base class for user-written callbacks that allows you to inject integer-feasible solutions during the branch-and-cut search.
The callback also provides support for implementing simplex-based heuristics for constructing solutions, by allowing you to change the bounds of variables and re-solve the node relaxation. Changing the bounds in the heuristic callback has no effect on the search once the callback has completed. This callback will be called after the node relaxation (including all cuts generated at that node) has been solved.
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.
IloCplex.ControlCallback
Constructor Summary | |
protected |
IloCplex.HeuristicCallback()
Constructor for user-written heuristic callbacks. |
Method Summary | |
protected IloCplex.CplexStatus |
getCplexStatus()
Returns the IloCplex.CplexStatus for the current
node. |
protected IloCplex.Status |
getStatus()
Returns the solution status for the current node. |
boolean |
isDualFeasible()
Returns true if a dual feasible solution is available for
the current node. |
boolean |
isPrimalFeasible()
Returns true if a primal feasible solution is available for
the current node. |
protected void |
setBounds(ilog.concert.IloNumVar[] var,
double[] lb,
double[] ub)
Changes the upper and lower bounds of variables in the array var . |
protected void |
setBounds(ilog.concert.IloNumVar[] var,
double[] lb,
double[] ub,
int start,
int num)
Changes the upper and lower bounds of the specified variables in the array var . |
protected void |
setBounds(ilog.concert.IloNumVar var,
double lb,
double ub)
Changes the upper and lower bounds of variable var . |
protected void |
setSolution(ilog.concert.IloNumVar[] vars,
double[] vals)
Injects a solution to be used as the potential new incumbent. |
protected void |
setSolution(ilog.concert.IloNumVar[] vars,
double[] vals,
int start,
int num)
Injects a solution to be used as the potential new incumbent. |
protected boolean |
solve()
Solves the current node relaxation using the default algorithm. |
protected boolean |
solve(int alg)
Solves the current node relaxation using a chosen algorithm. |
Methods inherited from class ilog.cplex.IloCplex.ControlCallback |
getDownPseudoCost, getFeasibilities, getFeasibilities, getFeasibility, getLB, getLBs, getLBs, getNodeData, getObjValue, getSlack, getSlacks, getSlacks, getSOSFeasibility, getSOSFeasibility, getUB, getUBs, getUBs, getUpPseudoCost, getValue, getValue, getValues, getValues |
Methods inherited from class ilog.cplex.IloCplex.Callback |
abort, getModel, getNcols, getNQCs, getNrows, main |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected IloCplex.HeuristicCallback()
IloCplex.HeuristicCallback
objects directly.
Method Detail |
protected void setBounds(ilog.concert.IloNumVar var, double lb, double ub) throws IloException
var
.
For the variable var
, this method sets its
upper bound to the corresponding value ub
and
its lower bound to the value lb
. Setting bounds has
no effect beyond the scope of the current invocation of the callback.
var
- The variable whose bounds are to be changed.lb
- The lower bound of var
to be changed.ub
- The upper bound of var
to be changed.
IloException
protected void setBounds(ilog.concert.IloNumVar[] var, double[] lb, double[] ub) throws IloException
var
. For each variable in the array var
,
this method sets its upper bound to the corresponding value in the
array ub
and its lower bound to the corresponding value in
the array lb
. Setting bounds has no effect beyond the
scope of the current invocation of the callback.
var
- The array of variables for which the bounds are to be changed.lb
- The array of lower bounds to be set. The lower bound of
variable var[j]
will be set to
lb[j]
.ub
- The array of upper bounds to be set. The upper bound of
variable var[j]
will be set to
ub[j]
.
IloException
protected void setBounds(ilog.concert.IloNumVar[] var, double[] lb, double[] ub, int start, int num) throws IloException
var
. For each variable selected from array
var
, this method sets its upper bound to the corresponding
value in the array ub
and its lower bound to the
corresponding value in the array lb
. Setting bounds has
no effect beyond the scope of the current invocation of the callback.
var
- The array containing the variables for which the bounds
are to be changed.lb
- The array containing the lower bounds to be set. The
lower bound of variable var[j]
will be set to
lb[j]
.ub
- The array containing the upper bounds to be set. The
upper bound of variable var[j]
will be set to
ub[j]
.start
- The index of the first variable in var
for
which the bounds are to be set.num
- The number of variables in var
for
which the bounds are to be set.
IloException
protected boolean solve(int alg) throws IloException
setBounds
. The algorithm alg
will be used
to solve the node.
alg
- The algorithm to use to solve the node relaxation.
true
if a feasible
solution has been found and false
otherwise.
IloException
IloCplex.Algorithm
protected boolean solve() throws IloException
setBounds
.
true
if a feasible
solution has been found and false
otherwise.
IloException
IloCplex.Algorithm
protected IloCplex.Status getStatus() throws IloException
IloCplex
at the current node during the last call to the
method IloCplex.HeuristicCallback.solve
(which may
have been called directly in the callback or by IloCplex
when processing the node just before the callback is called).
IloException
IloCplex.Status
protected IloCplex.CplexStatus getCplexStatus() throws IloException
IloCplex.CplexStatus
for the current
node.
This method returns the IloCplex.CplexStatus
of the solution
found by the instance of IloCplex
at the current node
during the last call to the method
IloCplex.HeuristicCallback.solve
(which may have been
called directly in the callback or by IloCplex
when
processing the node just before the callback is called).
IloException
IloCplex.CplexStatus
public boolean isDualFeasible() throws IloException
true
if a dual feasible solution is available for
the current node. If false
is returned the solution may
still be dual feasible, but the algorithm has not determined the
feasibility before it terminated.
IloException
public boolean isPrimalFeasible() throws IloException
true
if a primal feasible solution is available for
the current node. If false
is returned the solution may
still be primal feasible, but the algorithm has not determined the
feasibility before it terminated.
IloException
protected void setSolution(ilog.concert.IloNumVar[] vars, double[] vals, int start, int num) throws IloException
If a user heuristic is successful in finding a new candidate for an
incumbent, it can be passed to IloCplex
by the method
setSolution
. IloCplex
analyzes the solution
and, if it is both feasible and better than the current incumbent,
uses it as the new incumbent. A solution is specified using arrays
vars
and vals
, where vals[i]
specifies the solution value for vars[i]
.
vars
- An array containing variables whose solution
values are specified.vals
- An array containing the solution values for the variables
specified in vars
. vals[j]
specifies the solution value for vars[j]
for j
in start
through
start+num-1
.start
- The index of the first element to consider in arrays
vars
and vals
.num
- The number of elements to consider in arrays
vars
and vals
.
IloException
protected void setSolution(ilog.concert.IloNumVar[] vars, double[] vals) throws IloException
If a user heuristic is successful in finding a new candidate for an
incumbent, it can be passed to IloCplex
by the method
setSolution
. IloCplex
analyzes the
solution and, if it is both feasible and better than the current
incumbent,
uses it as the new incumbent. A solution is specified using arrays
vars
and vals
, where vals[i]
specifies the solution value for vars[i]
.
vars
- An array of variables whose solution
values are specified.vals
- An array containing the solution values for the variables
specified in vars
. vals[j]
specifies the solution value for vars[j]
.
IloException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |