Module docplex.cp.solver.cpo_callback

This module defines the class CpoCallback that allows to retrieve events that are sent by the CP Optimizer solver engine when running.

Any number of callbacks can be added to a solver using the method docplex.cp.solver.solver.CpoSolver.add_callback(). Callbacks can also be added on the model object using docplex.cp.model.CpoModel.add_callback()

New in version 2.10.

Detailed description

class docplex.cp.solver.cpo_callback.CpoCallback[source]

Bases: object

CPO callback allows to be warned directly by the solver engine about different solving steps.

This class is an ‘abstract’ class that must be extended by actual listener implementation. All method of this class are empty.

New in version 2.10.

invoke(solver, event, sres)[source]

Notify the callback about a solver event.

This method is called every time an event is notified by the CPO solver. Associated to the event, the solver information is provided as a an object of class class:~docplex.cp.solution.CpoSolveResult that is instantiated with information available at this step.

  • solver – Originator CPO solver (object of class CpoSolver)
  • event – Event id, string with value in ALL_CALLBACK_EVENTS
  • sres – Solver data, object of class CpoSolveResult