Skip to main content

Linear Programming solvers for Python with a unified API

Project description

This module provides a single function solve_lp(c, G, h, A, b, solver=X) with a solver keyword argument to select the backend solver. The linear program it solves is, in standard form:

min. c^T x
s.t. G x <= h
     A x == b

where vector inequalities are taken coordinate by coordinate.


The list of supported solvers currently includes:


To solve a linear program, simply 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.])

print "LP solution:", solve_lp(c, G, h)

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

Project details

Download files

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

Files for lpsolvers, version 0.8.9
Filename, size File type Python version Upload date Hashes
Filename, size lpsolvers-0.8.9.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page