Introduction to Algorithms (CLRS)ΒΆ
This page includes several visualizations for linear programs used in the third edition of Introduction to Algorithms, by Cormen, Leiserson, Rivest, and Stein.
Chapter 29 of Cormen, Leiserson, Rivest, and Stein uses the following LP to motivate fundamental LP concepts and introduce the graphical method for solving 2-dimensional LPs. See Equations (29.11-29.15).
Note that we have rewritten the third constraint as \(-5x_1+2x_2\leq 2\)
when defining the LP in gilp
below
from gilp import examples
from gilp.visualize import simplex_visual
simplex_visual(examples.CLRS_INTEGER_2D_LP).show()
Section 29.3 of Cormen, Leiserson, Rivest, and Stein uses the following LP as an extended example of the Simplex algorithm. See Equations (29.53-29.57).
simplex_visual(examples.CLRS_SIMPLEX_EX_3D_LP).show()
Section 29.3 of Cormen, Leiserson, Rivest, and Stein uses the following LP to explain the phenomenon of degeneracy.
Note that Cormen, Leiserson, Rivest, and Stein originally write this LP in dictionary form as shown below.
When you run the following visualization, observe that iteration 0 of simplex matches this dictionary form. Observe also that iterations 1 and 2 correspond to the same corner point, with the same objective value. Using Blandβs pivot rule prevents cycling.
simplex_visual(examples.CLRS_DEGENERATE_3D_LP).show()