Simplex Method Algorithm

1. Find pivot column
2. Find pivot row
3. Do the pivot
4. Repeat 1,2, 3 until done

Let’s create the “doPivot” function first. It needs the matrix, the row, and the column to pivot. Row and column will be input variables, but the matrix to manipulate is assumed to be defined in a global variable called “tableau”.

doPivot[row_, col_] := 
(tableau[[row]] = tableau[[row]]/tableau[[row, col]];
Do[If[row ≠ i,tableau[[i]] = tableau[[i]] - tableau[[row]]* tableau[[i,col]]],
{i,1,4}];)

A={{10,5,1,0,0,0,50},
        {12,1,0,1,0,0,48},
        {3,2,0,0,1,0,18},
          {-4,-2,0,0,0,1,0}};
A // MatrixForm

tableau  = A

doPivot[2,1]

tableau // MatrixForm

doPivot[1,2]

tableau // MatrixForm