Skip to main content

A Python package for visualizing the geometry of linear programs.

Project description

GILP

PyPI pyversions CircleCI Documentation Status codecov

GILP (Geometric Interpretation of Linear Programs) is a Python package for visualizing the geometry of:

LPs can be constructed from NumPy arrays and many examples (such as the Klee-Minty cube) are included. The revised simplex method is implemented along with phase I for finding an initial feasible solution. The package relies on Plotly to generate standalone HTML files which can be viewed in a Jupyter Notebook inline or in a web browser.

Examples

2d simplex example 3d simplex example 2d branch and bound example 3d branch and bound example

Installation

The quickest way to get started is with a pip install.

pip install gilp

Development

To develop and run tests on gilp, first download the source code in the desired directory.

git clone https://github.com/henryrobbins/gilp

Next, cd into the gilp directory and create a Python virtual enviroment.

cd gilp
python -m venv env_name

Activate the virtual enviroment.

source env_name/bin/activate

Run the following in the virtual enviroment. The -e flag lets you make adjustments to the source code and see changes without re-installing. The [dev] installs necessary dependencies for developing and testing.

pip install -e .[dev]

To run tests and see coverage, run the following in the virtual enviroment.

coverage run -m pytest
coverage report --include=gilp/*

Usage

The LP class creates linear programs from (3) NumPy arrays: A, b, and c which define the LP in standard inequality form.

For example, consider the following LP:

The LP instance is created as follows.

import gilp

A = np.array([[2, 1],
              [1, 1],
              [1, 0]])
b = np.array([[20],
              [16],
              [7]])
c = np.array([[5],
              [3]])
lp = LP(A,b,c)

After creating an LP, one can run simplex and generate a visualization with

gilp.simplex_visual(lp)]

where simplex_visual() returns a plotly figure. The figure can then be viewed on a Jupyter Notebook inline using

gilp.simplex_visual(lp).show()

If .show() is run outside a Jupyter Notebook enviroment, the visualization will open up in the browser. Alternatively, the HTML file can be written and then opened.

gilp.simplex_visual(lp).write_html('name.html')

Below is the visualization for the example LP. The plot on the left shows the feasible region and constraints of the LP. Hovering over an extreme point shows the basic feasible solution, basis, and objective value. The iteration slider allows one to toggle through the iterations of simplex and see the updating tableaus. The objective slider lets one see the objective line or plane for some range of objective values.

2d simplex example

License

Licensed under the MIT License

Project details


Download files

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

Source Distribution

gilp-1.0.0rc4.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

gilp-1.0.0rc4-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

Details for the file gilp-1.0.0rc4.tar.gz.

File metadata

  • Download URL: gilp-1.0.0rc4.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for gilp-1.0.0rc4.tar.gz
Algorithm Hash digest
SHA256 6b22e5811399075f3c00e818f8ebafc4a1e741b99c6c2c2207b422a34dace584
MD5 ea450c34517165551154ec5110b2b77a
BLAKE2b-256 36ac2c64ef8c3981559480c0daa3330f5a5682acae69ed3ae0078ca5d0f1706b

See more details on using hashes here.

File details

Details for the file gilp-1.0.0rc4-py3-none-any.whl.

File metadata

  • Download URL: gilp-1.0.0rc4-py3-none-any.whl
  • Upload date:
  • Size: 41.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for gilp-1.0.0rc4-py3-none-any.whl
Algorithm Hash digest
SHA256 cb769fe7d1527ff1fd9319f9bdad0e48d481f4bdd8979d0279c0a6b39feb1d02
MD5 4b9236906da9bd42bf961f896253115f
BLAKE2b-256 7a59c5c3aa8f0a87e8ffe1714b1ad97652479e13dfe5a34818f2c7ee9c756c0a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page