Simplex Algorithm

Abstract

This is pseudocode for the core of the Simplex Algorithm, adapted from A Gentle Introduction to Optimization.

\SetAlgoCaptionSeparator

.1

{algorithm}

Simplex Algorithm

\AlgoDisplayBlockMarkers\AlgoDisplayGroupMarkers\SetAlgoBlockMarkers

{ } \SetAlgoNoEnd\SetAlgoNoLine

\SetKwInOut

InputInput\SetKwInOutOutputOutput \InputLinear program (P) and feasible basis B \OutputAn optimal solution for (P) or a certificate proving that (P) is unbounded Rewrite (P) so that it is in canonical form for the basis B
Let x be the basic feasible solution for B
\IfcN0 stop
(x is optimal) Select kN such that ck>0
\IfAk0 stop
((P) is unbounded) Let r be any index i where the following minimum is attained:

t=min{biAi,k:Ai,k>0} (1)

Let ι be the rth basis element
Set B:=B{k}\{ι}
Go to step 1

Notes:

  1. 1.

    Recall c is the vector of coefficients in our objective function z(x), and ck is the kth element of c.

  2. 2.

    cN is c with the columns corresponding to basis B removed.

  3. 3.

    A is the m×n matrix with linearly independent rows that comprise our constraints. Ak is the kth column of A (a vector, though we aren’t writing it with the arrow above), and AB or AN is a matrix comprised of a subset of the columns of A, keeping them in the original order.