Skip to main content

LP Solvers for Python

CI Documentation Coverage Conda version PyPI version

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:

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)

Source distribution for lpsolvers 2.2.0
File Size Uploaded
lpsolvers-2.2.0.tar.gz 50.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lpsolvers 2.2.0
File Interpreter ABI Platform
lpsolvers-2.2.0-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.9.0

2 release files

0.8.9

1 release file

0.8.8

1 release file

0.8.7

1 release file

0.8.6

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page