ilog.cplex
Class IloCplex.HeuristicCallback

java.lang.Object
  |
  +--ilog.cplex.IloCplex.Callback
        |
        +--ilog.cplex.IloCplex.MIPCallback
              |
              +--ilog.cplex.IloCplex.ControlCallback
                    |
                    +--ilog.cplex.IloCplex.HeuristicCallback

public abstract static class IloCplex.HeuristicCallback
extends IloCplex.ControlCallback

A callback class to use when IloCplex is solving a MIP. An instance of the this class represents a user-written callback in an application that uses an instance of IloCplex to solve a mixed integer programming problem (a MIP). When you derive a user-defined class of callbacks, this class offers protected methods for you to:

In short, this callback allows you to attempt to construct an integer feasible solution at a node and pass it to an instance of IloCplex to use for its new incumbent. The API allows you iteratively to change bounds of the node LP and re-solve the LP. Changing the bounds in the heuristic callback has no effect on the search beyond the termination of the callback.

The heuristic callback is called after the node of the LP has been solved (including all cuts that may have been generated).

If an attempt is made to access information not available at the node for the invoking instance of IloCplex, an exception is thrown.

See Also:
IloCplex.ControlCallback

Constructor Summary
protected IloCplex.HeuristicCallback()
          Constructs a user-written callback class which attempts to find an integer feasible solution at a node, and pass it to IloCplex as the new incumbent.
 
Method Summary
protected  IloCplex.CplexStatus getCplexStatus()
          This method returns the ILOG CPLEX status of the instance of IloCplex at the current node (that is, the state of the optimizer at the node) during the last call to solve (which may have been called directly in the callback or by IloCplex when processing the node LP).
protected  IloCplex.Status getStatus()
          Returns the solution status.
protected  void setBounds(IloNumVar[] var, double[] lb, double[] ub)
          Changes the upper and lower bounds variable in the array var.
protected  void setBounds(IloNumVar[] var, double[] lb, double[] ub, int start, int num)
          Changes the upper and lower bounds variable in the array var.
protected  void setBounds(IloNumVar var, double lb, double ub)
          Changes the upper and lower bounds for a single variable var.
protected  void setSolution(IloNumVar[] vars, double[] vals)
          Sets solution variables to the values at the current node.
protected  void setSolution(IloNumVar[] vars, double[] vals, double obj)
          Sets solution variables to the values at the current node.
protected  void setSolution(IloNumVar[] vars, double[] vals, int start, int num)
          Sets solution variables to the values at the current node.
protected  void setSolution(IloNumVar[] vars, double[] vals, int start, int num, double obj)
          Sets solution variables to the values at the current node.
protected  boolean solve()
          Solves the current node LP using the default algorithm.
protected  boolean solve(int alg)
          Solves the current node LP using a chosen algorithm.
 
Methods inherited from class ilog.cplex.IloCplex.ControlCallback
getDownPseudoCost, getFeasibilities, getFeasibilities, getFeasibility, getLB, getLBs, getLBs, getObjCoef, getObjCoefs, getObjCoefs, getObjValue, getSlack, getSlacks, getSlacks, getSOSFeasibility, getSOSFeasibility, getUB, getUBs, getUBs, getUpPseudoCost, getValue, getValue, getValues, getValues
 
Methods inherited from class ilog.cplex.IloCplex.MIPCallback
getBestObjValue, getCutoff, getDirection, getIncumbentObjValue, getIncumbentValue, getIncumbentValues, getIncumbentValues, getNcliques, getNcovers, getNdisjunctiveCuts, getNflowCovers, getNflowPaths, getNfractionalCuts, getNGUBcovers, getNimpliedBounds, getNiterations, getNMIRs, getNnodes, getNremainingNodes, getPriority, isIntegerFeasible
 
Methods inherited from class ilog.cplex.IloCplex.Callback
abort, main
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IloCplex.HeuristicCallback

protected IloCplex.HeuristicCallback()
Constructs a user-written callback class which attempts to find an integer feasible solution at a node, and pass it to IloCplex as the new incumbent.
Method Detail

setBounds

protected void setBounds(IloNumVar var,
                         double lb,
                         double ub)
                  throws IloException
Changes the upper and lower bounds for a single variable 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.
Parameters:
var - The variable for which the bounds are to be changed.
lb - The lower bound of var to be changed.
ub - The upper bound of var to be changed.

setBounds

protected void setBounds(IloNumVar[] var,
                         double[] lb,
                         double[] ub)
                  throws IloException
Changes the upper and lower bounds variable in the array 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.
Parameters:
var - The array of variables for which the bounds are to be changed.
lb - The array of lower bounds to be set.
ub - The array of upper bounds to be set.

setBounds

protected void setBounds(IloNumVar[] var,
                         double[] lb,
                         double[] ub,
                         int start,
                         int num)
                  throws IloException
Changes the upper and lower bounds variable in the array 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.
Parameters:
var - The array of variables for which the bounds are to be changed.
lb - The array of lower bounds to be set.
ub - The array of upper bounds to be set.
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.

solve

protected boolean solve(int alg)
Solves the current node LP using a chosen algorithm. This method can be used to solve the current node LP, usually after some bounds have been changed using setBounds. The algorithm alg will be used to find the solution.
Parameters:
alg - The algorithm to use to solve the node LP.
See Also:
IloCplex.Algorithm

solve

protected boolean solve()
Solves the current node LP using the default algorithm. This method can be used to solve the current node LP, usually after some bounds have been changed using setBounds. It uses the dual simplex algorithm to find the solution.

getStatus

protected IloCplex.Status getStatus()
Returns the solution status. This method returns the status of the solution found by the instance of IloCplex at the current node during the last call to solve (which may have been called directly in the callback or by IloCplex when processing the node LP).

The class IloCplex.Status lists the possible status values.


getCplexStatus

protected IloCplex.CplexStatus getCplexStatus()
This method returns the ILOG CPLEX status of the instance of IloCplex at the current node (that is, the state of the optimizer at the node) during the last call to solve (which may have been called directly in the callback or by IloCplex when processing the node LP).

The class IloCplex.CplexStatus lists the possible status values.


setSolution

protected void setSolution(IloNumVar[] vars,
                           double[] vals,
                           int start,
                           int num)
                    throws IloException
Sets solution variables to the values at the current node. For each variable in the array vars, this method uses the value in the corresponding element of the array vals to set the value of the variable at the current node.

If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyses 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].

Parameters:
vars - An array of variables to be set to the current node value.
vals - The array of values to which var will be set.
start - The index of the first variable in the array var to be set.
num - The number of variables in var to be set.

setSolution

protected void setSolution(IloNumVar[] vars,
                           double[] vals)
                    throws IloException
Sets solution variables to the values at the current node. For each variable in the array vars, this method uses the value in the corresponding element of the array vals to set the value of the variable at the current node.

If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyses 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].

Parameters:
vars - An array of variables to be set to the current node value.
vals - The array of values to which var will be set.

setSolution

protected void setSolution(IloNumVar[] vars,
                           double[] vals,
                           int start,
                           int num,
                           double obj)
                    throws IloException
Sets solution variables to the values at the current node. For each variable in the array vars, this method uses the value in the corresponding element of the array vals to set the value of the variable at the current node. obj is used as the objective value at the current node.

If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyses 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].

Parameters:
vars - An array of variables to be set to the current node value.
vals - The array of values to which var will be set.
start - The index of the first variable in the array var to be set.
num - The number of variables in var to be set.
obj - The objective value at the current node.

setSolution

protected void setSolution(IloNumVar[] vars,
                           double[] vals,
                           double obj)
                    throws IloException
Sets solution variables to the values at the current node. For each variable in the array vars, this method uses the value in the corresponding element of the array vals to set the value of the variable at the current node. obj is used as the objective value at the current node.

If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyses 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].

Parameters:
vars - An array of variables to be set to the current node value.
vals - The array of values to which var will be set.
obj - The objective value at the current node.