CPMpy: Constraint Programming and Modeling in Python

Source code and issue tracker: https://github.com/CPMpy/cpmpy

CPMpy is ideal for solving combinatorial problems like assignment problems or covering, packing and scheduling problems. Problems that require searching over discrete decision variables.

Supported solvers

Solver

Technology

Capabilities

Installation

Notes

OR-Tools

CP (LCG)

SAT ASAT ALLSAT - OPT - PAR

pip

The default solver

Pumpkin

CP (LCG)

SAT ASAT ALLSAT - OPT - PROOF

local install (maturin)

GCS

CP

SAT ISAT ALLSAT - OPT - PROOF

pip

Choco

CP

SAT ISAT ALLSAT - OPT

pip

CP Optimizer

CP

SAT - OPT - PAR

pip + local + (aca.) license

MiniZinc

CP

SAT - OPT

pip + local install

Communicates through textfiles

Z3

SMT

SAT ASAT ISAT - OPT

pip

Hexaly

Global Opt.

SAT ISAT ALLSAT - OPT IOPT

pip + local + (aca.) licence

Gurobi

ILP

SAT ISAT - OPT IOPT - PAR

pip + (aca.) license

CPLEX

ILP

SAT - OPT IOPT - PAR

pip + local + (aca.) license

No

Exact

Pseudo-Boolean

SAT ASAT ISAT ALLSAT - OPT IOPT - PROOF

pip >3.10 (Linux, Win)

Manual installation on Mac possible

RC2

MaxSAT

OPT

pip

Pindakaas

SAT

SAT ASAT ISAT

pip

Automatically encodes PB to SAT

PySAT

SAT

SAT ASAT ISAT

pip

PySDD

Decis. Diagram

SAT ISAT ALLSAT - KC

pip

only Boolean variables (CPMpy transformation incomplete)

Native capability abbreviations:
  • SAT: Satisfaction, ASAT: Satisfaction under Assumptions+core extraction, ISAT: Incremental Satisfaction, ALLSAT: All solution enumeration

  • OPT: Optimisation, IOPT: Incremental optimisation

  • PAR: Parallel solving, PROOF: Proof logging, KC: Knowledge Compilation

Different solvers excel at different problems. Try multiple!

CPMpy’s transformations selectively rewrite only those constraint expressions that a solver does not support. While solvers can use any transformation they need, lower-level solvers largely reuse those of higher-level ones, creating a waterfall pattern:

Waterfall from model to solvers

Open Source

CPMpy is open source (Apache 2.0 license) and the development process is open too: all discussions happen on GitHub, even between direct colleagues, and all changes are reviewed through pull requests.

Join us! We welcome any feedback and contributions. You are also free to reuse any parts in your own project. A good starting point to contribute is to add your models to the examples folder.

Are you a solver developer? We are keen to integrate solvers that have a python API on pip. If this is the case for you, or if you want to discuss what it best looks like, do contact us!