First, open up a Jupyter Notebook or Google Colab enviroment. Reminder: if you are using a Google Colab enviroment, you will have to reinstall gilp every time by running the cell !pip install gilp.

Example LPs

GILP comes with many LP examples. Before we use them, we must import them.

from gilp import examples as ex

We can now access the LP examples using ex.NAME where NAME is the name of the example LP. For example, consider:

\max 5x_1 + 3x_2
\text{s.t.} 2x_1 + 1x_2 \leq 20
  1x_1 + 1x_2 \leq 16
  1x_1 + 0x_2 \leq 7
  x_1, x_2 \geq 0

This example LP is called ALL_INTEGER_2D_LP. Let us assign this LP to a variable called lp.


Now, we can begin visualizing LPs. We import the visualization function below.

from gilp.visualize import simplex_visual

The function simplex_visual() takes an LP and returns a plotly figure. The figure can then be viewed on a Jupyter Notebook inline using


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.


Here is the resulting visualization from running simplex_visual(lp).show()