ILOG CPLEX 11.0 User's Manual > Advanced Programming Techniques > Using Optimization Callbacks > Implementing Callbacks in ILOG CPLEX with Concert Technology

Callbacks are accessed via the IloCplex::Callback handle class in the C++ implementation of IloCplex. It points to an implementation object of a subclass of IloCplex::CallbackI. In Java and .NET, there is no handle class and a programmer deals only with implementation classes which are subclasses of IloCplex.Callback. One such implementation class is provided for each type of callback. The implementation class provides the functions that can be used for the particular callback as protected methods.

To reflect the fact that some callbacks share part of their protected API, the callback classes are organized in a class hierarchy, as documented in the reference manuals of the APIs. For example, the class hierarchy of C++ callbacks is visible when you select Tree or Graph in the reference manual of that API. Likewise, the class and interface hierarchy of Java callbacks is visible when you select Tree in the reference manual of the Java API. Similarly, you can see the class and interface hierarchy of .NET callbacks in that reference manual.

This hierarchy means that, for example, all functions available for the MIP callback are also available for the probing, fractional cut, and disjunctive cut callbacks. In particular, the function to abort the current optimization is provided by the class IloCplex::CallbackI (IloCplex.Callback in Java and Cplex.Callback in .NET) and is thus available to all callbacks.

There are two ways of implementing callbacks for IloCplex: a more complex way that exposes all the C++ implementation details, and a simplified way that uses macros to handle the C++ technicalities. Since Java and .NET do not provide macros, only the more complex way is available for Java or .NET users. This section first explains the more complex way and discusses the underlying design. To implement your C or C++ callback quickly without details about the internal design, proceed directly to Writing Callbacks with Macros.