All Projects → stephane-caron → Qpsolvers

stephane-caron / Qpsolvers

Licence: lgpl-3.0
Quadratic Programming solvers in Python with a unified API

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Qpsolvers

Convex.jl
A Julia package for disciplined convex programming
Stars: ✭ 417 (+165.61%)
Mutual labels:  solver
Mayamatchmovesolver
A Bundle Adjustment solver for MatchMove related tasks.
Stars: ✭ 50 (-68.15%)
Mutual labels:  solver
Hiop
HPC solver for nonlinear optimization problems
Stars: ✭ 75 (-52.23%)
Mutual labels:  solver
Vroom
Vehicle Routing Open-source Optimization Machine
Stars: ✭ 533 (+239.49%)
Mutual labels:  solver
Flutter Ai Rubik Cube Solver
Flutter-Python rubiks cube solver.
Stars: ✭ 744 (+373.89%)
Mutual labels:  solver
Prioritizr
Systematic conservation prioritization in R
Stars: ✭ 62 (-60.51%)
Mutual labels:  solver
Ik
Minimal Inverse Kinematics library
Stars: ✭ 340 (+116.56%)
Mutual labels:  solver
Hodlr
A fast, accurate direct solver and determinant computation for dense linear systems
Stars: ✭ 140 (-10.83%)
Mutual labels:  solver
Cuckoo
a memory-bound graph-theoretic proof-of-work system
Stars: ✭ 747 (+375.8%)
Mutual labels:  solver
Angler
Frequency-domain photonic simulation and inverse design optimization for linear and nonlinear devices
Stars: ✭ 75 (-52.23%)
Mutual labels:  solver
Zeratool
Automatic Exploit Generation (AEG) and remote flag capture for exploitable CTF problems
Stars: ✭ 584 (+271.97%)
Mutual labels:  solver
Osqp
The Operator Splitting QP Solver
Stars: ✭ 689 (+338.85%)
Mutual labels:  solver
Py Lapsolver
Fast linear assignment problem (LAP) solvers for Python based on c-extensions
Stars: ✭ 70 (-55.41%)
Mutual labels:  solver
Choco Solver
An open-source Java library for Constraint Programming
Stars: ✭ 518 (+229.94%)
Mutual labels:  solver
Java Smt
JavaSMT - Unified Java API for SMT solvers.
Stars: ✭ 88 (-43.95%)
Mutual labels:  solver
Handeye calib camodocal
Easy to use and accurate hand eye calibration which has been working reliably for years (2016-present) with kinect, kinectv2, rgbd cameras, optical trackers, and several robots including the ur5 and kuka iiwa.
Stars: ✭ 364 (+131.85%)
Mutual labels:  solver
Pulp
A python Linear Programming API
Stars: ✭ 1,080 (+587.9%)
Mutual labels:  solver
Cosmo.jl
COSMO: Accelerated ADMM-based solver for convex conic optimisation problems (LP, QP, SOCP, SDP, ExpCP, PowCP). Automatic chordal decomposition of sparse semidefinite programs.
Stars: ✭ 149 (-5.1%)
Mutual labels:  solver
Projecteuler
Polyglot solutions for www.projecteuler.net mathematical challenges
Stars: ✭ 137 (-12.74%)
Mutual labels:  solver
Visma
VISual MAth - an equation solver and visualizer
Stars: ✭ 71 (-54.78%)
Mutual labels:  solver

QP Solvers for Python

PyPI package Documentation Status

Wrapper around Quadratic Programming (QP) solvers in Python, with a unified interface.

Installation

sudo apt install python3-dev
pip3 install qpsolvers

Check out the documentation for Python 2 or Windows instructions.

Usage

The function solve_qp(P, q, G, h, A, b, lb, ub) is called with the solver keyword argument to select the backend solver. The convex quadratic program it solves is, in standard form:

Equation of Quadratic Program

Vector inequalities are taken coordinate by coordinate. The matrix P should be positive definite.

Example

To solve a quadratic program, simply build the matrices that define it and call the solve_qp function:

from numpy import array, dot
from qpsolvers import solve_qp

M = array([[1., 2., 0.], [-8., 3., 2.], [0., 1., 1.]])
P = dot(M.T, M)  # this is a positive definite matrix
q = dot(array([3., 2., 3.]), M).reshape((3,))
G = array([[1., 2., 1.], [2., 0., 1.], [-1., 2., -1.]])
h = array([3., 2., -2.]).reshape((3,))
A = array([1., 1., 1.])
b = array([1.])

x = solve_qp(P, q, G, h, A, b)
print("QP solution: x = {}".format(x))

This example outputs the solution [0.30769231, -0.69230769, 1.38461538].

Solvers

The list of supported solvers currently includes:

Frequently Asked Questions

  • Can I print the list of solvers available on my machine?
    • Absolutely: print(qpsolvers.available_solvers)
  • Is it possible to solve a least squares rather than a quadratic program?
    • Yes, qpsolvers also provides a solve_ls function.
  • 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?
    • Unfortunately most available QP solvers are designed for convex problems.
    • If your cost matrix P is semi-definite rather than definite, try OSQP.
    • If your problem has concave components, go for a nonlinear solver such as IPOPT e.g. using CasADi.
  • I get the following build error on Windows when running pip install qpsolvers.

Performances

On a dense problem, the performance of all solvers (as measured by IPython's %timeit on my machine) is:

Solver Type Time (ms)
quadprog Dense 0.02
qpoases Dense 0.03
osqp Sparse 0.04
ecos Sparse 0.34
cvxopt Dense 0.46
gurobi Sparse 0.84
cvxpy Sparse 3.40
mosek Sparse 7.17

On a sparse problem, these performances become:

Solver Type Time (ms)
osqp Sparse 1
mosek Sparse 17
ecos Sparse 21
cvxopt Dense 186
gurobi Sparse 221
quadprog Dense 550
cvxpy Sparse 654
qpoases Dense 2250

Finally, here are the results on a benchmark of random problems (each data point corresponds to an average over 10 runs):

Note that performances of QP solvers largely depend on the problem solved. For instance, MOSEK performs an automatic conversion to Second-Order Cone Programming (SOCP) which the documentation advises bypassing for better performance. Similarly, ECOS reformulates from QP to SOCP and works best on small problems.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].