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

Installation

Assumptions?

Notes

OR-Tools

CP-SAT

pip

Yes

Assumptions NOT incremental! Every solve starts from scratch

Choco

CP

pip

No

GCS

CP

pip

No

Supports proof logging

MiniZinc

CP

pip + local install

No

Communicates through textfiles

CP Optimizer

CP

pip + local + (aca.) license

No

Gurobi

ILP

pip + (aca.) license

No

Exact

Pseudo-Boolean

pip >3.10 (Linux, Win)

Yes

Manual installation on Mac possible

Z3

SMT

pip

Yes

PySAT

SAT

pip

Yes

Only Boolean variables (CPMpy transformation incomplete)

PySDD

SAT Counter

pip

Yes

Knowledge compiler, only Boolean variables (CPMpy transformation incomplete)

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

(* automated int-to-bool not yet supported )

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!