qpsolvers
Quadratic programming solvers in Python with a unified API
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
2 of 15 committers (13.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.3%) to scientific vocabulary
Keywords
Repository
Quadratic programming solvers in Python with a unified API
Basic Info
Statistics
- Stars: 685
- Watchers: 13
- Forks: 98
- Open Issues: 10
- Releases: 53
Topics
Metadata Files
README.md
Quadratic Programming Solvers in Python
This library provides a solve_qp function to solve convex quadratic programs:
$$ \begin{split} \begin{array}{ll} \underset{x}{\mbox{minimize}} & \frac{1}{2} x^T P x + q^T x \ \mbox{subject to} & G x \leq h \ & A x = b \ & lb \leq x \leq ub \end{array} \end{split} $$
Vector inequalities apply coordinate by coordinate. The function returns the primal solution $x^*$ found by the backend QP solver, or None in case of failure/unfeasible problem. All solvers require the problem to be convex, meaning the matrix $P$ should be positive semi-definite. Some solvers further require the problem to be strictly convex, meaning $P$ should be positive definite.
Dual multipliers: there is also a solve_problem function that returns not only the primal solution, but also its dual multipliers and all other relevant quantities computed by the backend solver.
Example
To solve a quadratic program, build the matrices that define it and call solve_qp, selecting the backend QP solver via the solver keyword argument:
```python import numpy as np from qpsolvers import solve_qp
M = np.array([[1.0, 2.0, 0.0], [-8.0, 3.0, 2.0], [0.0, 1.0, 1.0]]) P = M.T @ M # this is a positive definite matrix q = np.array([3.0, 2.0, 3.0]) @ M G = np.array([[1.0, 2.0, 1.0], [2.0, 0.0, 1.0], [-1.0, 2.0, -1.0]]) h = np.array([3.0, 2.0, -2.0]) A = np.array([1.0, 1.0, 1.0]) b = np.array([1.0])
x = solve_qp(P, q, G, h, A, b, solver="proxqp") print(f"QP solution: {x = }") ```
This example outputs the solution [0.30769231, -0.69230769, 1.38461538]. It is also possible to get dual multipliers at the solution, as shown in this example.
Installation
From conda-forge
console
conda install -c conda-forge qpsolvers
From PyPI
To install the library with open source QP solvers:
console
pip install qpsolvers[open_source_solvers]
This one-size-fits-all installation may not work immediately on all systems (for instance if a solver tries to compile from source). If you run into any issue, check out the following variants:
pip install qpsolvers[wheels_only]will only install solvers with pre-compiled binaries,pip install qpsolvers[clarabel,daqp,proxqp,scs](for instance) will install the listed set of QP solvers,pip install qpsolverswill only install the library itself.
When imported, qpsolvers loads all the solvers it can find and lists them in qpsolvers.available_solvers.
Solvers
| Solver | Keyword | Algorithm | API | License |
| ------ | ------- | --------- | --- | ------- |
| Clarabel | clarabel | Interior point | Sparse | Apache-2.0 |
| CVXOPT | cvxopt | Interior point | Dense | GPL-3.0 |
| DAQP | daqp | Active set | Dense | MIT |
| ECOS | ecos | Interior point | Sparse | GPL-3.0 |
| Gurobi | gurobi | Interior point | Sparse | Commercial |
| HiGHS | highs | Active set | Sparse | MIT |
| HPIPM | hpipm | Interior point | Dense | BSD-2-Clause |
| jaxopt.OSQP | jaxopt_osqp | Augmented Lagrangian | Dense | Apache-2.0 |
| KVXOPT | kvxopt | Interior point | Dense & Sparse | GPL-3.0 |
| MOSEK | mosek | Interior point | Sparse | Commercial |
| NPPro | nppro | Active set | Dense | Commercial |
| OSQP | osqp | Augmented Lagrangian | Sparse | Apache-2.0 |
| PIQP | piqp | Proximal interior point | Dense & Sparse | BSD-2-Clause |
| ProxQP | proxqp | Augmented Lagrangian | Dense & Sparse | BSD-2-Clause |
| QPALM | qpalm | Augmented Lagrangian | Sparse | LGPL-3.0 |
| qpax | qpax | Interior point | Dense | MIT |
| qpOASES | qpoases | Active set | Dense | LGPL-2.1 |
| qpSWIFT | qpswift | Interior point | Sparse | GPL-3.0 |
| quadprog | quadprog | Active set | Dense | GPL-2.0 |
| SCS | scs | Augmented Lagrangian | Sparse | MIT |
| SIP | sip | Barrier Augmented Lagrangian | Sparse | MIT |
Matrix arguments are NumPy arrays for dense solvers and SciPy Compressed Sparse Column (CSC) matrices for sparse ones.
Frequently Asked Questions
- Can I print the list of solvers available on my machine?
- Is it possible to solve a least squares rather than a quadratic program?
- I have a squared norm in my cost function, how can I apply a QP solver to my problem?
- I have a non-convex quadratic program, is there a solver I can use?
- I have quadratic equality constraints, is there a solver I can use?
- Error: Mircrosoft Visual C++ 14.0 or greater is required on Windows
- Can I add penalty terms as in ridge regression or LASSO?
Benchmark
QP solvers come with their strengths and weaknesses depending on the algorithmic choices they make. To help you find the ones most suited to your problems, you can check out the results from qpbenchmark, a benchmark for QP solvers in Python. The benchmark is divided into test sets, each test set representing a different distribution of quadratic programs with specific dimensions and structure (large sparse problems, optimal control problems, ...):
- 📈 Free-for-all test set: open to all problems submitted by the community.
- 📈 Maros-Meszaros test set: hard problems curated by the numerical optimization community.
- 📈 MPC test set: convex model predictive control problems arising in robotics.
Citing qpsolvers
If you find this project useful, please consider giving it a :star: or citing it if your work is scientific:
bibtex
@software{qpsolvers,
title = {{qpsolvers: Quadratic Programming Solvers in Python}},
author = {Caron, Stéphane and Arnström, Daniel and Bonagiri, Suraj and Dechaume, Antoine and Flowers, Nikolai and Heins, Adam and Ishikawa, Takuma and Kenefake, Dustin and Mazzamuto, Giacomo and Meoli, Donato and O'Donoghue, Brendan and Oppenheimer, Adam A. and Pandala, Abhishek and Quiroz Omaña, Juan José and Rontsis, Nikitas and Shah, Paarth and St-Jean, Samuel and Vitucci, Nicola and Wolfers, Soeren and Yang, Fengyu and @bdelhaisse and @MeindertHH and @rimaddo and @urob and @shaoanlu and Khalil, Ahmed and Kozlov, Lev and Groudiev, Antoine and Sousa Pinto, João and Schwan, Roland and Budhiraja, Rohan},
license = {LGPL-3.0},
url = {https://github.com/qpsolvers/qpsolvers},
version = {4.8.1},
year = {2025}
}
Don't forget to add yourself to the BibTeX above and to CITATION.cff if you contribute to this repository.
Contributing
We welcome contributions! The first step is to install the library and use it. Report any bug in the issue tracker. If you're a developer looking to hack on open source, check out the contribution guidelines for suggestions.
See also
- qpbenchmark: Benchmark for quadratic programming solvers available in Python.
- qpsolvers-eigen: C++ abstraction layer for quadratic programming solvers using Eigen.
Owner
- Name: qpsolvers
- Login: qpsolvers
- Kind: organization
- Repositories: 2
- Profile: https://github.com/qpsolvers
Quadratic programming benchmarks and solver interfaces.
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you find this code helpful, please cite it as below." title: "qpsolvers: Quadratic Programming Solvers in Python" version: 4.8.1 date-released: 2025-08-07 url: "https://github.com/qpsolvers/qpsolvers" license: "LGPL-3.0" authors: - family-names: "Caron" given-names: "Stéphane" orcid: "https://orcid.org/0000-0003-2906-692X" - family-names: "Arnström" given-names: "Daniel" - family-names: "Bonagiri" given-names: "Suraj" - family-names: "Dechaume" given-names: "Antoine" - family-names: "Flowers" given-names: "Nikolai" - family-names: "Heins" given-names: "Adam" - family-names: "Ishikawa" given-names: "Takuma" - family-names: "Kenefake" given-names: "Dustin" - family-names: "Mazzamuto" given-names: "Giacomo" - family-names: "Meoli" given-names: "Donato" - family-names: "O'Donoghue" given-names: "Brendan" - family-names: "Oppenheimer" given-names: "Adam A." - family-names: "Pandala" given-names: "Abhishek" - family-names: "Quiroz Omaña" given-names: "Juan José" - family-names: "Rontsis" given-names: "Nikitas" - family-names: "Shah" given-names: "Paarth" - family-names: "St-Jean" given-names: "Samuel" - family-names: "Vitucci" given-names: "Nicola" - family-names: "Wolfers" given-names: "Soeren" - family-names: "Yang" given-names: "Fengyu" - family-names: "@bdelhaisse" - family-names: "@MeindertHH" - family-names: "@rimaddo" - family-names: "@urob" - family-names: "@shaoanlu" - family-names: "Khalil" given-names: "Ahmed" - family-names: "Kozlov" given-names: "Lev" - family-names: "Groudiev" given-names: "Antoine" - family-names: "Sousa Pinto" given-names: "João" orcid: "https://orcid.org/0000-0003-2469-2809" - family-names: "Rey" given-names: "Valérian" - family-names: "Schwan" given-names: "Roland" - family-names: "Budhiraja" given-names: "Rohan"
GitHub Events
Total
- Create event: 17
- Release event: 5
- Issues event: 10
- Watch event: 91
- Delete event: 11
- Issue comment event: 36
- Push event: 88
- Pull request review comment event: 7
- Pull request review event: 11
- Pull request event: 31
- Fork event: 8
Last Year
- Create event: 17
- Release event: 5
- Issues event: 10
- Watch event: 91
- Delete event: 11
- Issue comment event: 36
- Push event: 88
- Pull request review comment event: 7
- Pull request review event: 11
- Pull request event: 31
- Fork event: 8
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 1,441
- Total Committers: 15
- Avg Commits per committer: 96.067
- Development Distribution Score (DDS): 0.09
Top Committers
| Name | Commits | |
|---|---|---|
| Stéphane Caron | s****n@n****g | 1,311 |
| Stéphane Caron | s****n@l****r | 101 |
| Nikitas Rontsis | n****s@g****m | 8 |
| Dustin Kenefake | D****e@t****u | 5 |
| = | j****e@m****m | 3 |
| suraj2596 | s****6@g****m | 2 |
| Donato Meoli | d****5@g****m | 2 |
| Pavel Otta | o****v@g****m | 2 |
| Justin Carpentier | j****r@i****r | 1 |
| Giacomo Mazzamuto | g****o@c****t | 1 |
| Soeren Wolfers | s****s@g****m | 1 |
| Takuma Ishikawa | n****u@u****m | 1 |
| Nicola Vitucci | n****i@g****m | 1 |
| rachel madden | r****n@g****m | 1 |
| Brian Delhaisse | b****e@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 57
- Total pull requests: 145
- Average time to close issues: about 2 months
- Average time to close pull requests: 8 days
- Total issue authors: 23
- Total pull request authors: 21
- Average comments per issue: 1.54
- Average comments per pull request: 1.03
- Merged pull requests: 131
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 6
- Pull requests: 35
- Average time to close issues: 13 days
- Average time to close pull requests: 3 days
- Issue authors: 5
- Pull request authors: 7
- Average comments per issue: 0.83
- Average comments per pull request: 1.11
- Merged pull requests: 29
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- stephane-caron (31)
- microprediction (4)
- Illviljan (2)
- ogencoglu (2)
- david-cortes (1)
- henryqin1997 (1)
- bodono (1)
- a-n-n-a-l-e-e (1)
- RuijiaX (1)
- YuanzhaoLin1999 (1)
- guzhaoyuan (1)
- rxian (1)
- yihang-gao (1)
- DManowitz (1)
- viswans2132 (1)
Pull Request Authors
- stephane-caron (131)
- ottapav (3)
- RSchwan (2)
- dmeoli (2)
- lvjonok (2)
- shaoanlu (2)
- joaospinto (2)
- sanurielf (2)
- itsahmedkhalil (2)
- adamheins (1)
- jdthorpe (1)
- nekketsuuu (1)
- DKenefake (1)
- darnstrom (1)
- ValerianRey (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 151,585 last-month
- Total docker downloads: 56
-
Total dependent packages: 28
(may contain duplicates) -
Total dependent repositories: 163
(may contain duplicates) - Total versions: 67
- Total maintainers: 3
pypi.org: qpsolvers
Quadratic programming solvers in Python with a unified API.
- Homepage: https://github.com/qpsolvers/qpsolvers
- Documentation: https://qpsolvers.github.io/qpsolvers/
- License: GNU Lesser General Public License v3 (LGPLv3)
-
Latest release: 4.8.1
published 5 months ago
Rankings
Maintainers (1)
spack.io: py-qpsolvers
Unified interface to convex Quadratic Programming (QP) solvers available in Python.
- Homepage: https://github.com/qpsolvers/qpsolvers
- License: []
-
Latest release: 3.2.0
published over 2 years ago
Rankings
Maintainers (2)
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- numpy >= 1.15.4
- scipy >=1.2.0
- actions/checkout v3 composite
- mamba-org/provision-with-micromamba main composite
- peaceiris/actions-gh-pages v3 composite
- actions/checkout v3 composite
- tarides/changelog-check-action v2 composite
- cmake
- pip >=21.3.1
- proxsuite
- qpsolvers