Solver interfaces (cpmpy.solvers)
Solver interfaces have the same API as Model.
However some solvers are incremental, meaning that after solving a problem, you can add constraints or change
the objective, and the next solve will reuse as much information from the previous solve as possible.
Some clause learning solvers also support solving with assumptions, meaning you can solve the same problem with
different assumption variables toggled on/off, and the solver will reuse information from the previous solves.
See Supported solvers for the list of solvers and their capabilities.
To benefit from incrementality, you have to instantiate the solver object and reuse it, rather than working on a Model object.
Solvers must be instantiated throught the static cp.SolverLookup class:
cp.SolverLookup.solvernames()– List all installed solvers (including subsolvers).cp.SolverLookup.get(solvername, model=None)– Initialize a specific solver.
For example creating a CPMpy solver object for OR-Tools:
import cpmpy as cp
s = cp.SolverLookup.get("ortools")
# can now use solver object 's' over and over again
List of solver submodules
Interface to OR-Tools' CP-SAT Python API. |
|
Interface to Choco solver's Python API. |
|
Interface to the Glasgow Constraint Solver's API for the CPMpy library. |
|
Interface to MiniZinc's Python API. |
|
Interface to CP Optimizer's Python API. |
|
Interface to Gurobi Optimizer's Python API. |
|
Interface to Exact's Python API |
|
Interface to Z3's Python API. |
|
Interface to PySAT's API |
|
Interface to PySDD's API |
|
Interface to the Pindakaas solver's Python API. |
|
Interface to Pumpkin's API |
|
Interface to CPLEX Optimizer using the python 'docplex.mp' package |
|
Interface to Hexaly's API |
|
Interface to PySAT's RC2 MaxSAT solver API |
List of helper submodules
Generic interface, solver status and exit status. |
|
Utilities for handling solvers |
List of functions
|
Recursively yield all combinations of param values |