Metadata-Version: 2.4
Name: lpsolvers
Version: 2.2.0
Summary: Linear programming solvers in Python with a unified API.
Keywords: linear programming,solver,numerical optimization
Author-email: Stéphane Caron <stephane.caron@normalesup.org>
Maintainer-email: Stéphane Caron <stephane.caron@normalesup.org>
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Mathematics
License-File: LICENSE
Requires-Dist: numpy >=1.15.4
Requires-Dist: scipy >=1.2.0
Requires-Dist: pycddlib >=3.0.0 ; extra == "cdd"
Requires-Dist: cvxopt >=1.2.6 ; extra == "cvxopt"
Requires-Dist: cvxpy >=1.1.11 ; extra == "cvxpy"
Requires-Dist: lpsolvers[cdd, cvxopt, cvxpy, pdlp, proxqp] ; extra == "open-source-solvers"
Requires-Dist: ortools >=9.8.3296 ; extra == "pdlp"
Requires-Dist: proxsuite >=0.4.0 ; extra == "proxqp"
Project-URL: Changelog, https://codeberg.org/stephane-caron/lpsolvers/src/branch/main/CHANGELOG.md
Project-URL: Documentation, https://stephane-caron.codeberg.page/lpsolvers/
Project-URL: Homepage, https://codeberg.org/stephane-caron/lpsolvers
Project-URL: Source, https://codeberg.org/stephane-caron/lpsolvers
Project-URL: Tracker, https://codeberg.org/stephane-caron/lpsolvers/issues
Provides-Extra: cdd
Provides-Extra: cvxopt
Provides-Extra: cvxpy
Provides-Extra: open-source-solvers
Provides-Extra: pdlp
Provides-Extra: proxqp

# LP Solvers for Python


[![CI](https://ci.codeberg.org/api/badges/16581/status.svg)](https://ci.codeberg.org/repos/16581)
[![Documentation](https://img.shields.io/badge/docs-online-blue)](https://stephane-caron.codeberg.page/lpsolvers/)
[![Coverage](https://codeberg.org/stephane-caron/lpsolvers/raw/branch/coverage/badge.svg)](https://stephane-caron.codeberg.page/lpsolvers/coverage/)
[![Conda version](https://img.shields.io/conda/vn/conda-forge/lpsolvers.svg)](https://anaconda.org/conda-forge/lpsolvers)
[![PyPI version](https://img.shields.io/pypi/v/lpsolvers)](https://pypi.org/project/lpsolvers/)

Wrapper around Linear Programming (LP) solvers in Python, with a unified interface.

## Installation

### From conda-forge

```console
conda install -c conda-forge lpsolvers
```

### From PyPI

To install the library and all available LP solvers at the same time:

```console
pip install lpsolvers[open_source_solvers]
```

To install the library only, assuming LP solvers are installed separately: ``pip install lpsolvers``.

## Usage

The function [`solve_lp`](https://stephane-caron.codeberg.page/lpsolvers/linear-programming.html#lpsolvers.solve_lp) is called with the ``solver`` keyword argument to select the backend solver. The linear program it solves is, in standard form:

```
minimize    c^T x
subject to  G x ≤ h
            A x = b
```

Vector inequalities are taken coordinate by coordinate.

## Example

To solve a linear program, build the matrices that define it and call the ``solve_lp`` function:

```python
from numpy import array
from lpsolvers import solve_lp

c = array([1., 2., 3.])
G = array([[1., 2., -1.], [2., 0., 1.], [1., 2., 1.], [-1., -1., -1.]])
h = array([4., 1., 3., 2.])

x = solve_lp(c, G, h, solver="cvxopt")  # select solver here
print(f"LP solution: {x=}")
```

This example outputs the solution ``[2.2, -0.8, -3.4]``.

## Solvers

The list of supported solvers currently includes:

- [cdd](https://github.com/mcmtroffaes/pycddlib)
- [CVXOPT](http://cvxopt.org/)
- [CVXPY](https://www.cvxpy.org/) (interface)
- [PDLP](https://developers.google.com/optimization/lp/pdlp_math)
- [ProxQP](https://github.com/Simple-Robotics/proxsuite#proxqp)

