> Advanced Programming Techniques > Using Callbacks > Implementing Callbacks in ILOG CPLEX with Concert Technology |
Implementing Callbacks in ILOG CPLEX with Concert Technology |
INDEX PREVIOUS NEXT |
Callbacks are accessed via the IloCplex::Callback
handle class in the C++ version of IloCplex
. It points to an implementation object of a subclass of IloCplex::CallbackI
. In Java and C#.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 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 C#.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
) 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 the Java programing language does not provide macros, only the more complex way is available for Java users. This section first explains the more complex way and discusses the underlying design. To quickly implement your callback without details about the internal design, proceed directly to Writing Callbacks with Macros.
Copyright © 1987-2003 ILOG, S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |