Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Generic callbacks in docplex.mp high-level Python interface?

    Posted 05/10/21 12:17 AM
    I am using a lazy constraint callback in a model that I created with docplex.mp, fairly similar to the Traveling Salesman example that you can find in the answer to this StackOverflow post. I noticed this message in the log:

    Warning: Control callbacks may disable some MIP features.
    Lazy constraint(s) or lazy constraint/branch callback is present.
    Disabling dual reductions (CPX_PARAM_REDUCE) in presolve.
    Disabling presolve reductions that prevent crushing forms (CPX_PARAM_PREREFORM).
    Disabling repeat represolve because of lazy constraint/incumbent callback.

    According to the CPLEX manual, there is a newer "generic callback" mechanism that "does not require disabling any MIP features." This makes me thing that my problem might reach its solution faster if I used generic callbacks instead of legacy callbacks. Is it possible to write and use generic callbacks in Python? I don't see anything in the docplex.mp manual about generic callbacks. What would it take to use generic callbacks with docplex.mp?

    ------------------------------
    Leo Singer
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Generic callbacks in docplex.mp high-level Python interface?

    Posted 05/17/21 09:44 AM
    Hello Leo,

    Generic callbacks are not yet directly supported by DOcplex, but you can use them through the `cplex` attribute of a Model instance,
    and use the index-based Python API (short answer).
    I wrote a small sample code at

    https://github.com/PhilippeCouronne/docplex_contribs/blob/master/docplex_contribs/src/docplex_gencb.py

    to show how this works. In particular I am using code from `docplex.mp.callbacks.ModelCallbackMixin` to convert a DOcplex constraint to
    what is expected by the index-based API. This is a temporary workaround, but you can still leverage generic callbacks if need be.

        Philippe.

    ------------------------------
    Philippe Couronne
    ------------------------------