What is a generic callback?
Generic callbacks supercede legacy callbacks, such as informational callbacks, query callbacks, or control callbacks.
The generic callback is a callback invoked in many different places during the search for a solution. In contrast to the legacy CPLEX callbacks (such as informational callbacks, query callbacks, or control callbacks), a generic callback is not a dedicated callback (for example, dedicated to separating a cut). Instead, a generic callback is a multi-purpose function. What can be reasonably done in a callback invocation is defined by the context in which the callback is invoked. For more about contexts, see the topic What is a context for a generic callback?.
Do not mix generic and legacy callbacks in your application. If you mix legacy callbacks with
generic callbacks, CPLEX raises an error at the first invocation of optimization (for example,
a call of
How does a generic callback differ from legacy callbacks?
- It is attached to the
CPXLPptr, not the
- It is compatible with dynamic search.
- It does not require disabling any MIP features.
- It monitors progress as well as guides the search.
- It works almost exclusively on the original model; that is, with some exceptions, there is no access to the presolved model nor information available about the presolved model.
- It does not implicitly change the number of threads that CPLEX uses.
- It does not implicitly sequentialize the execution of callbacks in multithreaded solves.
- It allows only routines that take a value of CPXCALLBACKCONTEXTptr as an argument.
- It offers more flexibility than legacy callbacks; for example, you can inject heuristic solutions in almost any context. You can also inject more than one heuristic solution per callback invocation.