forked from qpsolvers/qpsolvers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
98 lines (81 loc) · 3.2 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2016-2020 Stephane Caron <[email protected]>
#
# This file is part of qpsolvers.
#
# qpsolvers is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# qpsolvers is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with qpsolvers. If not, see <http://www.gnu.org/licenses/>.
from setuptools import setup
classifiers = """\
Development Status :: 5 - Production/Stable
License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Intended Audience :: Developers
Intended Audience :: Science/Research
Topic :: Scientific/Engineering :: Mathematics
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 3
Operating System :: OS Independent"""
equation = 'https://raw.githubusercontent.com/stephane-caron/qpsolvers/master/doc/src/images/qp.gif'
long_description = """\
This module provides a single function ``solve_qp(P, q, G, h, A, b, lb, ub,
solver=X)`` with a *solver* keyword argument to select the backend solver. The
quadratic program it solves is, in standard form:
.. figure:: %s
where vector inequalities are taken coordinate by coordinate.
Solvers
-------
The list of supported solvers currently includes:
- Dense solvers:
- `CVXOPT <http://cvxopt.org/>`_
- `qpOASES <https://projects.coin-or.org/qpOASES>`_
- `quadprog <https://pypi.python.org/pypi/quadprog>`_
- Sparse solvers:
- `ECOS <https://web.stanford.edu/~boyd/papers/ecos.html>`_
- `Gurobi <https://www.gurobi.com/>`_
- `MOSEK <https://mosek.com/>`_
- `OSQP <https://github.com/oxfordcontrol/osqp>`_
Example
-------
To solve a quadratic program, simply build the matrices that define it and call
the ``solve_qp`` function:
.. code:: python
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]``.
""" % equation
setup(
name='qpsolvers',
version='1.4',
description="Quadratic Programming solvers for Python with a unified API",
long_description=long_description,
url="https://github.com/stephane-caron/qpsolvers",
author="Stéphane Caron",
author_email="[email protected]",
license="LGPL",
keywords="qp, quadratic programming, solver",
platforms="any",
classifiers=classifiers.split('\n'),
packages=['qpsolvers'],
install_requires=['quadprog']
)