A pedagogical implementation of the simplex method

This is a simple implementation of the simplex method that can be vastly improved with better use of data structures and design. This code is designed to be used for classroom exercises and makes no attempt to be efficient at all.

The overall organization of the code is that we have:

  • SimplexState which represents the current vertex and problem
  • SimplexPoint which represents the KKT information at a point

We can create a SimplexPoint from a SimplexState to understand the current point.

Then the fundamental iteration is simplex_step, which moves from one vertex to another and returns an updated SimplexState

Our running example

We'll use this example to illustrate the codes

In [1]:
A1 = [-2.0 1; 
      -1 2; 
       1 0]
b = [2.0; 7; 3]

A = [A1 eye(3)] # form the problem with slacks.