ilog.cplex
Class IloCplex.SolveCallback

java.lang.Object
  extended byilog.cplex.IloCplex.Callback
      extended byilog.cplex.IloCplex.MIPCallback
          extended byilog.cplex.IloCplex.SolveCallback
All Implemented Interfaces:
java.lang.Cloneable
Enclosing class:
IloCplex

public abstract static class IloCplex.SolveCallback
extends IloCplex.MIPCallback

The base class for user-written solve callbacks to control how node relaxations are solved within branch and cut.

An instance of this class can be used to solve nodes during a branch-and-cut search. It allows you to set a starting point when a node is being solved or to select the solution algorithm on a per-node basis.

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.

See Also:
IloCplex.MIPCallback

Constructor Summary
protected IloCplex.SolveCallback()
          Constructor for user-written solve callback.
 
Method Summary
protected  IloCplex.CplexStatus getCplexStatus()
          Returns the IloCplex.CplexStatus of the last solve call.
protected  IloCplex.Status getStatus()
          Returns the solution status of the last solve call.
 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 setVectors(double[] x, IloNumVar[] var, double[] pi, IloRange[] rng)
          Specifies a starting point for the next invocation of the method solve.
protected  void setVectors(double[] x, IloNumVar[] var, int xstart, int xnum, double[] pi, IloRange[] rng, int cstart, int cnum)
          Specifies a starting point for the next invocation of the method solve.
protected  boolean solve()
          Solves the current node using the default algorithm (IloCplex.Algorithm.Auto).
protected  boolean solve(int alg)
          Solves the current node using the algorithm alg.
protected  void useSolution()
          Instructs IloCplex to use a solution.
 
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, getObjCoef, getObjCoefs, getObjCoefs, getPriority, hasIncumbent
 
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

IloCplex.SolveCallback

protected IloCplex.SolveCallback()
Constructor for user-written solve callback. This constructor can be called only to construct objects of derived user-written callback classes, but not to construct IloCplex.SolveCallback objects directly.

Method Detail

solve

protected boolean solve(int alg)
                 throws IloException
Solves the current node using the algorithm alg.

See IloCplex.Algorithm for a choice of algorithms to use.

Parameters:
alg - The IloCplex.Algorithm to use to solve the current node.
Returns:
A Boolean value indicating whether a feasible solution has been found.
Throws:
IloException

solve

protected boolean solve()
                 throws IloException
Solves the current node using the default algorithm (IloCplex.Algorithm.Auto).

Returns:
A Boolean value indicating whether a feasible solution has been found.
Throws:
IloException

getStatus

protected IloCplex.Status getStatus()
                             throws IloException
Returns the solution status of the last solve call.

Returns:
The solution status of the last solve call.
Throws:
IloException

getCplexStatus

protected IloCplex.CplexStatus getCplexStatus()
                                       throws IloException
Returns the IloCplex.CplexStatus of the last solve call.

Returns:
The IloCplex.CplexStatus of the last solve call.
Throws:
IloException

isDualFeasible

public boolean isDualFeasible()
                       throws IloException
Returns 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.

Throws:
IloException

isPrimalFeasible

public boolean isPrimalFeasible()
                         throws IloException
Returns 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 did not determine the feasibility before it terminated.

Throws:
IloException

useSolution

protected void useSolution()
Instructs IloCplex to use a solution.

This method instructs IloCplex to use the solution generated with this callback instead of solving the node itself.

If useSolution is not called, IloCplex uses the algorithm selected with parameter IloCplex.IntParam.RootAlg or IloCplex.IntParam.NodeAlg to solve the node.


setVectors

protected void setVectors(double[] x,
                          IloNumVar[] var,
                          double[] pi,
                          IloRange[] rng)
                   throws IloException
Specifies a starting point for the next invocation of the method solve.

Starting point information is exploited at the next call of the method solve. In particular, if the node is being solved with the simplex optimizer, the starting point information provided with this method is used to construct a starting basis for the simplex optimizer.

The starting point information is provided in the parameters of this method. NULL can be passed for any of the parameters. However, if x is not NULL, var must not be NULL. Similarly, if pi is not NULL, rng must not be NULL.

For all variables given in var, x[j] specifies the starting primal value for variable var[j]. Similarly, for all constraints specified in rng, pi[i] specifies the starting dual value for rng[i].

When values are not specified for all integer and continuous variables, CPLEX tries to extend this partial solution to a complete solution by solving a MIP over the variables whose values have not been specified by any previous calls to setVectors. The parameter SubMIPNodeLim controls the amount of effort CPLEX expends in trying to solve this secondary MIP. If CPLEX finds a complete feasible solution, that solution becomes the incumbent. If the specified values are infeasible, they are retained for use in a subsequent solution repair heuristic. The amount of effort spent in this heuristic can be controlled by the parameter RepairTries.

Parameters:
x - The array of primal starting values for the variables specified in var.
var - The array of variables for which to specify primal starting values.
pi - The array of dual starting values for the constraints specified in rng.
rng - The array of constraints for which to specify dual starting values.
Throws:
IloException

setVectors

protected void setVectors(double[] x,
                          IloNumVar[] var,
                          int xstart,
                          int xnum,
                          double[] pi,
                          IloRange[] rng,
                          int cstart,
                          int cnum)
                   throws IloException
Specifies a starting point for the next invocation of the method solve.

Starting point information is exploited at the next call of solve. In particular, if the node is being solved with the simplex optimizer, the starting point information provided with this method is used to construct a starting basis for the simplex optimizer.

The starting point information is provided in the parameters of this method. NULL can be passed for any of the parameters. However, if x is not NULL, var must not be NULL. Similarly, if pi is not NULL, rng must not be NULL.

x[j] specifies the starting primal value for variable var[j]. Similarly, pi[i] specifies the starting dual value for rng[i].

When values are not specified for all integer and continuous variables, CPLEX tries to extend this partial solution to a complete solution by solving a MIP over the variables whose values have not been specified by any previous calls to setVectors. The parameter SubMIPNodeLim controls the amount of effort CPLEX expends in trying to solve this secondary MIP. If CPLEX finds a complete feasible solution, that solution becomes the incumbent. If the specified values are infeasible, they are retained for use in a subsequent solution repair heuristic. The amount of effort spent in this heuristic can be controlled by the parameter RepairTries.

Parameters:
x - An array containing the primal starting values for the variables specified in var.
var - An array containing the variables for which to specify primal starting values.
xstart - The first element in x and var to be used.
xnum - The number of consecutive elements in x and var to be used.
pi - An array containing the dual starting values for the constraints specified in rng.
rng - An array containing the constraints for which to specify dual starting values.
cstart - The first element in pi and rng to be used.
cnum - The number of consecutive elements in pi and rng to be used.
Throws:
IloException