LP Solvers for Python
Wrapper around Linear Programming (LP) solvers in Python, with a unified interface.
Installation
From conda-forge
conda install -c conda-forge lpsolvers
From PyPI
To install the library and all available LP solvers at the same time:
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 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:
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:
Metadata
Release files for lpsolvers 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lpsolvers-2.2.0.tar.gz | 50.0 kB | Without provenance | Details for lpsolvers-2.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lpsolvers-2.2.0-py3-none-any.whl | Python 3 | none | any | Details for lpsolvers-2.2.0-py3-none-any.whl |
Total release size: 64.1 kB
Release files / lpsolvers-2.2.0.tar.gz
| Download URL | lpsolvers-2.2.0.tar.gz |
|---|---|
| Size | 50.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52d31474adb94ffbd5dcc921191e48e77dea16a51c500fe720feb16c8109b8a0
|
|
BLAKE2b-256 checksum How to use checksums |
46bc43cacfd663029c1dbbeea8f239c65d4b5d2a2491c9bc8490407ee911f14d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.4
|
Release files / lpsolvers-2.2.0-py3-none-any.whl
| Download URL | lpsolvers-2.2.0-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b24a2dd587d0d520847b8a7758dc19646179f26f643c2030712641aa49dedfb4
|
|
BLAKE2b-256 checksum How to use checksums |
87a3b7b7101754e9bb9cf6a584019e4963366f4829d1d14449e2bc2bc28c2645
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.4
|
Security for lpsolvers 2.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.