ilog.cplex
Class IloCplex.Callback

java.lang.Object
  extended byilog.cplex.IloCplex.Callback
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
IloCplex.ContinuousCallback, IloCplex.CrossoverCallback, IloCplex.MIPCallback, IloCplex.NetworkCallback, IloCplex.PresolveCallback
Enclosing class:
IloCplex

public abstract static class IloCplex.Callback
extends java.lang.Object
implements java.lang.Cloneable

The callback base class.

This class defines the common interface available to all callback classes. A callback is an object with a method main implemented by the user. This method is called by the IloCplex algorithm at specific points during the optimization. For each of these points, an extension of IloCplex.Callback is provided. To implement and use a particular callback, the following steps must be carried out:

The next time a solution method is executed on the IloCplex object for which the callback has been set, the method main of the callback will be called each time the corresponding point in the optimization algorithm is reached, for example at each iteration.

The methods of this class are protected to make sure they are used only to derive a user-written callback class or to implement the main method in it.

See Also:
IloCplex.use(ilog.cplex.IloCplex.Callback)

Method Summary
protected  void abort()
          Instructs CPLEX to stop the current optimization after the user-written callback finishes.
protected  IloModel getModel()
          Returns the model being solved when the invoking callback is called, that is the active model.
protected  int getNcols()
          Returns the number of columns of the matrix representation of the active model being solved when the invoking callback is called.
protected  int getNQCs()
          Returns the number of quadratic constraints in the active model being solved when the invoking callback is called.
protected  int getNrows()
          Returns the number of rows of the matrix representation of the active model being solved when the invoking callback is called.
protected abstract  void main()
          The method to be implemented by user callback classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

protected abstract void main()
                      throws IloException
The method to be implemented by user callback classes.

Throws:
IloException

abort

protected void abort()
Instructs CPLEX to stop the current optimization after the user-written callback finishes.

This method can be called from a user-written implementation of a main method to instruct the invoking CPLEX optimizer to abort the current optimization. Note that executing additional callback methods in the callback can lead to unpredictable behavior. For example, callback methods such as IloCplex.SolveCallback.solve or IloCplex.BranchCallback.makeBranch can overwrite the callback status and thus enable the optimization to continue. Therefore, to abort an optimization effectively, a user should exit the callback by one of the following ways:


getModel

protected IloModel getModel()
                     throws IloException
Returns the model being solved when the invoking callback is called, that is the active model.

Returns:
The model being solved when the invoking callback is called.
Throws:
IloException

getNrows

protected int getNrows()
Returns the number of rows of the matrix representation of the active model being solved when the invoking callback is called.

Returns:
The number of rows of the matrix representation of the active model.

getNQCs

protected int getNQCs()
Returns the number of quadratic constraints in the active model being solved when the invoking callback is called.

Returns:
The number of quadratic constraints in the active model.

getNcols

protected int getNcols()
Returns the number of columns of the matrix representation of the active model being solved when the invoking callback is called.

Returns:
The number of columns of the matrix representation of the active model.