ILOG CPLEX 10.1 User's Manual > Advanced Programming Techniques > Using Callbacks > Implementing Callbacks in the Callable Library |
Implementing Callbacks in the Callable Library |
INDEX
![]() |
ILOG CPLEX optimization routines in the Callable Library incorporate a callback facility to allow your application to transfer control temporarily from ILOG CPLEX to the calling application. Using callbacks, your application can implement interrupt capability, for example, or create displays of optimization progress. After control is transferred back to a function in the calling application, the calling application can retrieve specific information about the current optimization from the routine CPXgetcallbackinfo
. Optionally, the calling application can then tell ILOG CPLEX to discontinue optimization.
To implement and use a callback in your application, you must first write the callback function and then tell ILOG CPLEX about it. For more information about the ILOG CPLEX Callable Library routines for callbacks, see the ILOG CPLEX Callable Library Reference Manual. In that reference manual, the group optim.cplex.callable.callbacks
gives you direct access to callback routines.
In the Callable Library, diagnostic callbacks are organized into two groups: LP callbacks (that is, continuous callbacks) and MIP callbacks (that is, discrete callbacks). For each group, one callback function can be set by the routine CPXsetlpcallbackfunc
and one by CPXsetmipcallbackfunc
. You can distinguish between the actual callbacks by querying the argument wherefrom
passed to the callback function as an argument by ILOG CPLEX.
The continous callback is also called during the solution of problems of type LP, QP, and QCP.
ILOG CPLEX will evaluate two user-defined callback functions, one during the solution of continuous problems and one during the solution of discrete problems. ILOG CPLEX calls the continuous callback once per iteration during the solution of an LP, QP, or QCP problem and periodically during the presolve. ILOG CPLEX calls the discrete callback periodically during the probing phase of MIP preprocessing, periodically during cut generation, and once before each subproblem is solved in the branch & cut process.
Every user-defined callback must have these arguments:
env
, a pointer to the ILOG CPLEX environment;
cbdata
, a pointer to ILOG CPLEX internal data structures needed by CPXgetcallbackinfo
;
wherefrom
, indicates which optimizer is calling the callback;
cbhandle
, a pointer supplied when your application calls CPXsetlpcallbackfunc
or CPXsetmipcallbackfunc
(so that the callback has access to private user data).
The arguments wherefrom
and cbdata
should be used only in calls to CPXgetcallbackinfo
.
Copyright © 1987-2006 ILOG S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |