Quadratic Programming solvers for Python with a unified API
Project description
This module provides a single function solve_qp(P, q, G, h, A, b, solver=X) with a solver keyword argument to select the backend solver. The quadratic program it solves is, in standard form:
where vector inequalities are taken coordinate by coordinate.
Solvers
The list of supported solvers currently includes:
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) # quick way to build a symmetric 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.])
print "QP solution:", solve_qp(P, q, G, h, A, b)
This example outputs the solution [0.30769231, -0.69230769, 1.38461538].
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
qpsolvers-1.0.7.tar.gz
(8.9 kB
view details)
File details
Details for the file qpsolvers-1.0.7.tar.gz
.
File metadata
- Download URL: qpsolvers-1.0.7.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.12.4 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2549daab90f21ebe02bacd28c62223dbdbc8dd2af0c2aa148e191e81b6106035 |
|
MD5 | 8bc3af1dccdf899f456992b408e42205 |
|
BLAKE2b-256 | bdd8a5ea1d7dade38657a9e9afd9779ce5814bd483d8c246032261daff73c949 |