The callback base class.

Namespace: ILOG.OPL
Assembly: oplall (in oplall.dll)

Syntax

C#
public abstract class Callback : ICloneable

Remarks

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 Cplex algorithm at specific points during the optimization. For each of these points, an extension of Cplex.Callback is provided. To implement and use a particular callback, the following steps must be carried out:

  • Select the callback class corresponding to the callback to be implemented, and create an extension of that class.
  • Implement method main for this extension. When doing so, you may use all of the methods defined in the callback class and its base classes.
  • If the default implementation of the method clone is not adequate and the callback is to be used for parallel optimization, this method also needs to be implemented by the user. Recall that the default clone method performs a shallow copy, so typically a user implementation would perform a deep copy for objects that should be local to threads or use the synchronize keyword where synchronization is required.
  • Create an instance of the user-written callback class and pass it to Cplex with the method Cplex.use.

The next time a solution method is executed on the Cplex 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.

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.

Inheritance Hierarchy

See Also