How callback classes are organized
Describes the hierarchy of callback classes.
Callbacks are accessed via the IloCplex::Callback handle
class in the C++ implementation of IloCplex.
An instance of that handle class 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 or Cplex.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. The reference manual of the Python API also documents the class hierarchy of callbacks.
This hierarchy means that, for example, all functions
available for the MIP callback are also available for the probing,
fractional cut, flow-and-MIR 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 callbacks.Callback in
the Python API) and is thus available
to all callbacks (informational, query or diagnostic, and control
callbacks).
There are two ways of implementing callbacks for CPLEX: 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 in C++.