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.
Getting started:
Supported solvers
Solver |
Technology |
Installation |
Assumptions? |
Notes |
---|---|---|---|---|
CP-SAT |
pip |
Yes |
Assumptions NOT incremental! Every solve starts from scratch |
|
CP |
pip |
No |
||
CP |
pip |
No |
Supports proof logging |
|
CP |
pip + local install |
No |
Communicates through textfiles |
|
CP |
pip + local + (aca.) license |
No |
||
ILP |
pip + (aca.) license |
No |
||
Pseudo-Boolean |
pip >3.10 (Linux, Win) |
Yes |
Manual installation on Mac possible |
|
SMT |
pip |
Yes |
||
SAT |
pip |
Yes |
Only Boolean variables (CPMpy transformation incomplete) |
|
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:

(* 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!