pyomo-cpsat
A Pyomo direct interface to the CP-SAT solver.
pyomo-cpsat is limited to solving pure integer linear programs with CP-SAT, or optimization models with
- a linear objective function with real coefficients,
- linear constraints with integral coefficients, and
- bounded integer variables.
pyomo-cpsat does not implement other CP-SAT constraint types, such as cumulative constraints, reservoir constraints, etc.
Through a keyword argument, pyomo-cpsat can find infeasible subsystems of constraints for infeasible models, using the approach illustrated here.
pyomo-cpsat is currently experimental - it is based on the future Pyomo solver interface documented here, still under active development.
Examples
Solving a simple model
import pyomo.environ as pyo
from pyomo.contrib.solver.common.factory import SolverFactory
import pyomo_cpsat
model = pyo.ConcreteModel()
model.I = pyo.Set(initialize=[1, 2, 3])
model.w = pyo.Param(model.I, initialize={1: 10, 2: 20, 3: 30})
model.x = pyo.Var(model.I, domain=pyo.Integers, bounds=(0, 100))
def con_rule(model):
return pyo.quicksum(model.w[i] * model.x[i] for i in model.I) <= 20
model.con = pyo.Constraint(rule=con_rule)
def obj_rule(model):
return pyo.quicksum(model.x[i] for i in model.I)
model.obj = pyo.Objective(rule=obj_rule, sense=pyo.maximize)
solver = SolverFactory('cpsat')
results = solver.solve(
model,
tee=False, # sets log_search_progress in CP-SAT
threads=8, # sets num_workers in CP-SAT
time_limit=300, # sets max_time_in_seconds in CP-SAT
rel_gap=0.1, # sets relative_gap_limit in CP-SAT
abs_gap=1e-6, # sets absolute_gap_limit in CP-SAT
solver_options={ # passes CP-SAT parameters
'subsolvers': ['pseudo_costs', 'probing']
},
)
print(f'Termination condition: {results.termination_condition}')
print(f'Solution status: {results.solution_status}')
print('Solution:')
for i in model.I:
print(f' x[{i}] = {pyo.value(model.x[i])}')
Resulting output:
Termination condition: TerminationCondition.convergenceCriteriaSatisfied
Solution status: SolutionStatus.optimal
Solution:
x[1] = 2
x[2] = 0
x[3] = 0
Finding an infeasible subsystem of constraints
import pyomo.environ as pyo
from pyomo.contrib.solver.common.factory import SolverFactory
import pyomo_cpsat
model = pyo.ConcreteModel()
model.I = pyo.Set(initialize=[1, 2, 3])
model.K = pyo.Set(initialize=['a', 'b'])
model.a = pyo.Param(
model.K,
model.I,
initialize={
('a', 1): 1,
('a', 2): 2,
('a', 3): 3,
('b', 1): -1,
('b', 2): -1,
('b', 3): -1,
},
)
model.b = pyo.Param(
model.K,
initialize={'a': 5, 'b': -10},
)
model.x = pyo.Var(model.I, domain=pyo.Integers, bounds=(0, 1))
def con_rule(model, k):
return pyo.quicksum(model.a[k, i] * model.x[i] for i in model.I) <= model.b[k]
model.con = pyo.Constraint(model.K, rule=con_rule)
def obj_rule(model):
return pyo.quicksum(model.x[i] for i in model.I)
model.obj = pyo.Objective(rule=obj_rule, sense=pyo.maximize)
solver = SolverFactory('cpsat')
results = solver.solve(model, find_infeasible_subsystem=True)
Resulting output:
Infeasible subsystem of constraints
-----------------------------------
con[b]
Metadata
Release files for pyomo-cpsat 2026.8.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyomo_cpsat-2026.8.12.tar.gz | 6.7 kB | Without provenance | Details for pyomo_cpsat-2026.8.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyomo_cpsat-2026.8.12-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for pyomo_cpsat-2026.8.12-py2.py3-none-any.whl |
Total release size: 14.3 kB
Release files / pyomo_cpsat-2026.8.12.tar.gz
| Download URL | pyomo_cpsat-2026.8.12.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6361872eef8d37f471515a99a4c4ff13a85df11b048893f7258c9f725c663e91
|
|
BLAKE2b-256 checksum How to use checksums |
1fbd5aba3facc14bbf1e7259da517ae4142a7dff872b1f0c2aa97ba32716280c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.34.2
|
Release files / pyomo_cpsat-2026.8.12-py2.py3-none-any.whl
| Download URL | pyomo_cpsat-2026.8.12-py2.py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8bec2827249f9e4a971e6bd59747dc7cdb23f0b4b7e34cb8dd2187b9ab818149
|
|
BLAKE2b-256 checksum How to use checksums |
5b119456a42b906ab4d7b6a8a19aaec005e7412d22a1aaa85b52a8d228f991fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.34.2
|
Security for pyomo-cpsat 2026.8.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.