Linear programming solvers in Python with a unified API.
Project description
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:
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lpsolvers-2.2.0.tar.gz.
File metadata
- Download URL: lpsolvers-2.2.0.tar.gz
- Upload date:
- Size: 50.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52d31474adb94ffbd5dcc921191e48e77dea16a51c500fe720feb16c8109b8a0
|
|
| MD5 |
f14dddb9913300929099b4459b1f26b6
|
|
| BLAKE2b-256 |
46bc43cacfd663029c1dbbeea8f239c65d4b5d2a2491c9bc8490407ee911f14d
|
File details
Details for the file lpsolvers-2.2.0-py3-none-any.whl.
File metadata
- Download URL: lpsolvers-2.2.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b24a2dd587d0d520847b8a7758dc19646179f26f643c2030712641aa49dedfb4
|
|
| MD5 |
222c35c0bd5e8779cbef019519f9e50b
|
|
| BLAKE2b-256 |
87a3b7b7101754e9bb9cf6a584019e4963366f4829d1d14449e2bc2bc28c2645
|