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 |
Capabilities |
Installation |
Notes |
|---|---|---|---|---|
CP (LCG) |
SAT ASAT ALLSAT - OPT - PAR |
pip |
The default solver |
|
CP (LCG) |
SAT ASAT ALLSAT - OPT - PROOF |
local install (maturin) |
||
CP |
SAT ISAT ALLSAT - OPT - PROOF |
pip |
||
CP |
SAT ISAT ALLSAT - OPT |
pip |
||
CP |
SAT - OPT - PAR |
pip + local + (aca.) license |
||
CP |
SAT - OPT |
pip + local install |
Communicates through textfiles |
|
SMT |
SAT ASAT ISAT - OPT |
pip |
||
Global Opt. |
SAT ISAT ALLSAT - OPT IOPT |
pip + local + (aca.) licence |
||
ILP |
SAT ISAT - OPT IOPT - PAR |
pip + (aca.) license |
||
ILP |
SAT - OPT IOPT - PAR |
pip + local + (aca.) license |
No |
|
Pseudo-Boolean |
SAT ASAT ISAT ALLSAT - OPT IOPT - PROOF |
pip >3.10 (Linux, Win) |
Manual installation on Mac possible |
|
MaxSAT |
OPT |
pip |
||
SAT |
SAT ASAT ISAT |
pip |
Automatically encodes PB to SAT |
|
SAT |
SAT ASAT ISAT |
pip |
||
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:
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!