A Comparison of Goals and Callbacks
Goals and callbacks both provide an API within IloCplex
to allow you to take control over the branch & cut search for solving MIP models. With one exception, the same functionality is available in both APIs. In fact, the goal API is built on top of callbacks. As a consequence, you cannot use callbacks and goals at the same time. To help you choose which API is more suited to your needs, this section examines commonalities and differences between both.
As pointed out previously, both APIs allow you to control the branch & cut search used by IloCplex
to solve MIP models. The following points distinguish specific features of this control.
Thus, one of the main differences between goals and callbacks is that with goals, all functionality is available from the execute()
method of the goal, whereas with callbacks, you must implement different callbacks to access different functionality.
As an example, suppose you want to extend a search to satisfy additional constraints that could not conveniently be added as linear constraints to the model.
With callbacks, you need to use an incumbent callback and a branch callback. The incumbent callback has to reject an otherwise integer feasible solution if it violates such an additional constraint. In this case, the branch callback has to follow up with an appropriate branch to enforce the constraint. Since the branch callback function allows branching only on individual variables, the determination of the appropriate branch may be quite difficult for constraints not modelled with linear expressions.
With goals, the feasibility test and the resulting branching can be implemented with a single goal.
The second big difference between goals and callbacks is that with goals you can easily specify different search strategies in different subtrees. To do this, simply provide different search goals as a parameter to the Or
goal when creating the root nodes for the subtrees in question. To achieve a similar result with callbacks requires an implementation that is too complex for a presentation here.
The only functionality that is not supported via goals is that provided by the solve
callback. Because of this, the solve
callbacks can be used at the same time as goals. However, this callback is very rarely used.
In summary, goals can be advantageous if you want to take control over several steps of the branch & cut search simultaneously, or if you want to specify different search strategies in different subtrees. On the other hand, if you only need to control a single aspect of the search-for example, adding cuts-using the appropriate callback may involve a smaller API and thus be quicker and easier to understand and implement.