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:

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lpsolvers-2.2.0.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lpsolvers-2.2.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

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

Hashes for lpsolvers-2.2.0.tar.gz
Algorithm Hash digest
SHA256 52d31474adb94ffbd5dcc921191e48e77dea16a51c500fe720feb16c8109b8a0
MD5 f14dddb9913300929099b4459b1f26b6
BLAKE2b-256 46bc43cacfd663029c1dbbeea8f239c65d4b5d2a2491c9bc8490407ee911f14d

See more details on using hashes here.

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

Hashes for lpsolvers-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b24a2dd587d0d520847b8a7758dc19646179f26f643c2030712641aa49dedfb4
MD5 222c35c0bd5e8779cbef019519f9e50b
BLAKE2b-256 87a3b7b7101754e9bb9cf6a584019e4963366f4829d1d14449e2bc2bc28c2645

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 files

2.1.0

2 files

2.0.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.9.0

2 files

0.8.9

1 file

0.8.8

1 file

0.8.7

1 file

0.8.6

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page