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:

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

ortools

Interface to OR-Tools' CP-SAT Python API.

choco

Interface to Choco solver's Python API.

gcs

Interface to the Glasgow Constraint Solver's API for the CPMpy library.

minizinc

Interface to MiniZinc's Python API.

cpo

Interface to CP Optimizer's Python API.

gurobi

Interface to Gurobi Optimizer's Python API.

exact

Interface to Exact's Python API

z3

Interface to Z3's Python API.

pysat

Interface to PySAT's API

pysdd

Interface to PySDD's API

pindakaas

Interface to the Pindakaas solver's Python API.

pumpkin

Interface to Pumpkin's API

cplex

Interface to CPLEX Optimizer using the python 'docplex.mp' package

hexaly

Interface to Hexaly's API

rc2

Interface to PySAT's RC2 MaxSAT solver API

List of helper submodules

solver_interface

Generic interface, solver status and exit status.

utils

Utilities for handling solvers

List of functions

param_combinations

Recursively yield all combinations of param values