Overview

Outlines advantages of goals and callbacks.

Goals and callbacks both provide an API within IBM ILOG CPLEX 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 goals and callbacks. In fact, the goal API is built on top of callbacks. As a consequence, you can not use callbacks and goals at the same time. To help you choose which API is more suited to your needs, this topic examines commonalities and differences between both.

A quick checklist comparing goals and callbacks

Both approaches (goals and callbacks) allow you to control the branch & cut search used by CPLEX to solve MIP models. The following points distinguish specific features of this control.

  • Checking feasibility

    • With goals, you can discontinue the search at a node by returning a Fail goal. Alternatively, you can continue searching, even though an integer feasible solution has been found, by returning another nonempty goal.

    • With callbacks, you can use method prune of the branch callback to discontinue the search, and an incumbent callback to accept or reject integer feasible solutions.

  • Creating branches

    • With goals, you create branches by using Or goals with local cut goals as parameters.

    • With callbacks, you create branches by using a branch callback.

  • Adding local or global cuts

    • With goals, you can add global and local cuts by using global and local cut goals, respectively.

    • With callbacks, you need to implement either a cut callback (for global and local cuts) or a branch callback for branching on local cuts

  • Injecting solution candidates

    • With goals, you inject solutions by using a solution goal.

    • With callbacks, you need to implement a heuristic callback to inject solutions.

  • Controlling the node selection strategy

    • With goals, you control node selection by applying node evaluators to your search goal.

    • With callbacks, you control node selection by using a node callback.

  • Supporting advanced starts

    • Since goals can enforce constraints, they do not support advanced starting information. An optimization with goals starts from scratch.

    • Since each callback provides a specific functionality, callbacks support advanced starts.

Further notes about goals and callbacks

Please note in the following discussion that CPLEX traditionally offered legacy callbacks, such as informational callbacks, query callbacks, or control callbacks, which were designed to monitor and control a branch-and-bound or branch-and-cut search. Over time, CPLEX has evolved and now executes more sophisticated strategies than straightforward branch-and-bound or branch-and-cut, although that strategy is still at the core of the solver. Dynamic search and other features have been added to CPLEX to solve models faster. The generic callback is compatible with all these new features since it does not assume a strictly branch-and-bound or branch-and-cut perspective in the solution process. For more information about the two types of callbacks, see Generic callbacks.

One of the main differences between goals and legacy callbacks is that with goals, all functionality is available from the execute method of the goal, whereas with legacy callbacks, you must implement different callbacks to access different functionality.

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 legacy callback may involve a smaller API and thus be quicker and easier to understand and implement.

Example contrasting goals and callbacks

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. The choice of the appropriate branch may be quite difficult for constraints not modeled with linear expressions, even though CPLEX supports branching on hyperplanes.