cpo3
cpo3 is a sparse interior-point solver for convex linear and quadratic programs, written in Rust with a Python interface. It solves
minimize over x, s ½ xᵀ P x + cᵀ x
subject to Ax + s = b, s ∈ K
where P is symmetric positive semidefinite. The supported cone blocks are
zero cones for equalities and nonnegative cones for inequalities. Thus,
nonnegative-cone rows represent Ax ≤ b; variable bounds can be written as
additional constraint rows.
- Solutions and certificates: recover primal and dual solutions or certificates of primal or dual infeasibility.
- Warm starts: supply a previous solution when solving related problems.
- Sparse linear algebra: Faer, Apple Accelerate, SuiteSparse CHOLMOD, and Intel MKL PARDISO backends, with presolve and Ruiz equilibration.
- File loading: read continuous LPs and QPs from MPS and QPS files.
The method uses a regularized homogeneous embedding with a canonical central path. Its predictor–corrector steps retain the nonlinear embedding equations while linearizing complementarity.
The name cpo3 combines Conic Programming with O3, a double reference to
the compiler optimization flag -O3 and the trioxide in rust—a nod to its
implementation in Rust.
cpo3 is under active development. The API and solver behavior may change between releases.
Installation
The release packages can be installed with:
python -m pip install cpo3==0.0.1
[dependencies]
cpo3 = "0.0.1"
Requires Python 3.10 or later.
For an unreleased checkout, or to customize the build, use the source installation below.
To build the Python interface from source, install Rust 1.91 or later, Python 3.10 or later, and uv, then run:
git clone https://github.com/cpo3-org/cpo3.git
cd cpo3
uv sync
Use uv run python from this checkout to run Python with the built package.
To use an unreleased checkout in a Rust application:
[dependencies]
cpo3 = { git = "https://github.com/cpo3-org/cpo3.git" }
Python quick start
This problem minimizes ½(x₁² + x₂²) − x₁ − 2x₂ subject to
x₁ ≤ 3 and x₂ ≤ 4. The solution is x = (1, 2), with objective −2.5.
import cpo3
import numpy as np
from scipy import sparse
problem = cpo3.Problem(
P=sparse.eye(2, format="csc"),
c=np.array([-1.0, -2.0]),
A=sparse.eye(2, format="csc"),
b=np.array([3.0, 4.0]),
cones=[cpo3.NonnegativeCone(2)],
)
solution = cpo3.solve(problem)
print(solution.status)
if solution.status == cpo3.SolverStatus.SOLVED:
print(solution.x) # approximately [1.0, 2.0]
print(solution.info.pobj) # approximately -2.5
Use SciPy sparse matrices for P and A, and set P=None for an LP.
Cone blocks correspond to consecutive rows of A and b; their dimensions must
sum to the number of constraints. Use cpo3.ZeroCone(dim) for equality rows.
Pass options through Settings:
settings = cpo3.Settings(verbose=True, time_limit=30.0, threads=1)
solution = cpo3.solve(problem, settings=settings)
verbose=True prints progress and a termination summary. threads=1 selects
sequential factorization and solves; the default, threads=0, uses the backend's
automatic thread selection. See the
Settings docstring for the available controls.
For a related problem, pass warm_start=(solution.x, solution.y, solution.s)
to solve. The solver screens the point before deciding whether to use it.
Load a problem from disk with cpo3.io.read_mps("problem.mps").
Rust quick start
The same problem in Rust:
use cpo3::{Cone, CscMatrix, Problem, Settings, SolverStatus, solve};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let problem = Problem::new(
Some(CscMatrix::identity(2)?),
vec![-1.0, -2.0],
CscMatrix::identity(2)?,
vec![3.0, 4.0],
vec![Cone::Nonnegative(2)],
)?;
let solution = solve(&problem, &Settings::default())?;
println!("{:?}", solution.status());
if solution.status() == SolverStatus::Solved {
println!("{:?}", solution.x()); // approximately [1.0, 2.0]
}
Ok(())
}
Run numerical workloads with cargo run --release. Enable the mps Cargo
feature to read MPS and QPS files. Use solve_from with a WarmStart to supply a
starting point for a related problem.
Optional factorization backends
Faer is always included and needs no external numerical runtime. The published wheel builds include the following integrations:
| Wheel platform | Included backend integrations |
|---|---|
| Linux x86-64 and Windows x86-64 | Faer, CHOLMOD, PARDISO |
| macOS Intel and Apple Silicon | Faer, Accelerate, CHOLMOD |
Accelerate uses the macOS system framework. CHOLMOD and MKL are not bundled;
install compatible shared runtimes separately before selecting those backends.
Importing cpo3 and using Faer work without either runtime. Check availability
with cpo3.LinearSolver.CHOLMOD.is_available() (or another enum member).
Source builds, including installation from the sdist, default to Faer. Python source builds also enable MPS/QPS loading. Enable other backends explicitly:
| Backend | Build feature | Requirements |
|---|---|---|
| Apple Accelerate | accelerate |
macOS 13 or later; threads=0 required |
| SuiteSparse CHOLMOD | cholmod |
CHOLMOD 5.2.x or 5.3.x, development headers for source builds only |
| Intel MKL PARDISO | pardiso |
Intel oneMKL shared runtime |
For example, build from a checkout with Accelerate and start Python:
uv sync --config-setting "build-args=--features=python,mps,accelerate"
uv run --no-sync python
The --no-sync option preserves your selected build. To solve the problem
from the Python quick start with Accelerate:
import cpo3
if cpo3.LinearSolver.ACCELERATE.is_available():
settings = cpo3.Settings(linear_solver=cpo3.LinearSolver.ACCELERATE, threads=0)
solution = cpo3.solve(problem, settings=settings)
Replace accelerate with cholmod or pardiso to build another backend;
features can be combined. Rust applications enable these features in their
Cargo dependency. Equality-only problems always use Faer.
For CHOLMOD, install SuiteSparse with brew install suite-sparse (macOS),
sudo apt-get install libsuitesparse-dev (Ubuntu), or
conda install -c conda-forge suitesparse (Conda). Check that the installed
CHOLMOD version is supported. Set
CHOLMOD_INCLUDE_DIR to the directory containing cholmod.h unless pkg-config
can find it. If runtime discovery fails, set CPO3_CHOLMOD or CPO3_MKL_RT to
the shared library's full path before starting Python; its dependencies must
also be discoverable by the system loader.
Understanding results
Always check the termination status before interpreting the returned vectors.
| Status | Meaning |
|---|---|
solved |
A solution satisfies the feasibility and duality-gap tolerances. |
primal_infeasible |
A certificate of primal infeasibility was found. |
dual_infeasible |
A certificate of dual infeasibility was found. |
max_iterations |
The iteration limit was reached. |
time_limit |
The time limit was reached. |
For a solved problem, x contains primal variables, y dual multipliers, and s
constraint slacks. For primal infeasibility, y contains the certificate; for
dual infeasibility, x and s contain the certificate direction. A limit status
does not certify optimality or infeasibility.
solution.info includes objectives, residuals, elapsed time, iteration counts,
and linear-algebra statistics. Numerical failures raise RuntimeError in Python
or return SolveError in Rust.
Development
After installing the checkout:
cargo test --features mps
uv run --no-sync pytest -ra
cargo fmt --check
cargo clippy --all-targets --features python,mps -- -D warnings
uv run --no-sync ruff check .
uv run --no-sync ruff format --check .
uv run --no-sync ty check
See the changelog.
See benchmarks/README.md for the benchmark data.
Authors and license
Matteo Santamaria, Michael Cummins, and Brendan O'Donoghue.
Licensed under MIT.
Metadata
Release files for cpo3 0.0.1
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 |
|---|---|---|---|---|
| cpo3-0.0.1.tar.gz | 176.0 kB | With provenance | Details for cpo3-0.0.1.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| cpo3-0.0.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for cpo3-0.0.1-cp310-abi3-win_amd64.whl |
| cpo3-0.0.1-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details for cpo3-0.0.1-cp310-abi3-manylinux_2_28_x86_64.whl |
| cpo3-0.0.1-cp310-abi3-macosx_13_0_x86_64.whl | CPython 3.10 | abi3 | macOS 13.0+ x86-64 | Details for cpo3-0.0.1-cp310-abi3-macosx_13_0_x86_64.whl |
| cpo3-0.0.1-cp310-abi3-macosx_13_0_arm64.whl | CPython 3.10 | abi3 | macOS 13.0+ ARM64 | Details for cpo3-0.0.1-cp310-abi3-macosx_13_0_arm64.whl |
Total release size: 5.4 MB
Release files / cpo3-0.0.1.tar.gz
| Download URL | cpo3-0.0.1.tar.gz |
|---|---|
| Size | 176.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a250a361877cfd7b83c7c5c1bc2238a78efe6c19d0db9ca8c7b19b7cee8d931f
|
|
BLAKE2b-256 checksum How to use checksums |
c7c71caf6c8a1bc9432f52f91f5fca36fe330b3edb514ff87ca5c3fe05da765c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / cpo3-0.0.1-cp310-abi3-win_amd64.whl
| Download URL | cpo3-0.0.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
cc8a40b758cd36ac6092820d73676bf8132a9b6ef545f7228d73daa3ac42ab0b
|
|
BLAKE2b-256 checksum How to use checksums |
d92e1f579ae66e90278e654280a3933b10982d4d51f22eac39dfbb257a6b775f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / cpo3-0.0.1-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | cpo3-0.0.1-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
612a4da72f0db21f0716bea1ef6faac0653ffcc3610e215434d850cc3bd75c25
|
|
BLAKE2b-256 checksum How to use checksums |
c8743bf66657a09d7b9eb83bbe1ba6349d5427ee8ef6248c6cbd218f981ad79b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / cpo3-0.0.1-cp310-abi3-macosx_13_0_x86_64.whl
| Download URL | cpo3-0.0.1-cp310-abi3-macosx_13_0_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 abi3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
e51930159ffd4bafdc5ca04862cce6cf78f19aec62f872c4e9c7076db6fa9c17
|
|
BLAKE2b-256 checksum How to use checksums |
3c50d055e1e23b3d9f23c78cba2ab57546bbb06d31095f0530bc71295b2fb95c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / cpo3-0.0.1-cp310-abi3-macosx_13_0_arm64.whl
| Download URL | cpo3-0.0.1-cp310-abi3-macosx_13_0_arm64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.10 abi3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
dbe175931b7e49f020998312cc22bd9d72bf7351b9cfc20ecff4690dd9c13efd
|
|
BLAKE2b-256 checksum How to use checksums |
93123af8118c7d0e21f8b6914d67a619c767ee85df4acb5b7b8fcb5ea7a96591
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logSecurity for cpo3 0.0.1
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.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for cpo3-0.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logA 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.