Skip to main content
Examonaut

Topic 5 · Lesson 3 of 5

The simplex algorithm

Slack variables

A slack variable turns a ≤\leq constraint into an equation: x+y≤7x + y \leq 7 becomes x+y+r=7x + y + r = 7 with r≥0r \geq 0. The slack rr measures the unused amount of that resource. At the origin, the slack variables equal the right-hand sides, which gives a starting solution.

The simplex tableau

Write the objective as P−3x−2y=0P - 3x - 2y = 0, so the objective row has the negatives of the coefficients. Each constraint is one row. The basic variables are listed down the side: at the start, the slack variables. Variables not in the basis (non-basic) are 0.

b.v.xyrstValuer111007s1301015t2100112P−3−20000\begin{array}{c|ccccc|c} \text{b.v.} & x & y & r & s & t & \text{Value} \\ \hline r & 1 & 1 & 1 & 0 & 0 & 7 \\ s & 1 & 3 & 0 & 1 & 0 & 15 \\ t & 2 & 1 & 0 & 0 & 1 & 12 \\ P & -3 & -2 & 0 & 0 & 0 & 0 \end{array}

The algorithm

  1. Pivot column: the column with the most negative entry in the objective row. (If there are no negative entries, the tableau is optimal: stop.)
  2. Pivot row: for each row with a positive entry in the pivot column, divide the value by that entry (the ratio). The row with the smallest ratio is the pivot row. The pivot is where the pivot row and column cross.
  3. Divide the pivot row by the pivot, so the pivot becomes 1. The pivot column's variable replaces that row's basic variable.
  4. Add or subtract multiples of the new pivot row to every other row, including the objective row, so that every other entry in the pivot column becomes 0. State the row operations you use.
  5. Repeat until there are no negative entries in the objective row.

The smallest ratio stops a variable going negative: it is how far you can increase the entering variable before one of the constraints runs out.

Worked example

The simplex algorithm

For the problem above: the most negative entry is −3-3, so xx enters. Ratios: 71=7\frac{7}{1} = 7, 151=15\frac{15}{1} = 15, 122=6\frac{12}{2} = 6. The smallest is in row tt, so the pivot is the 2. Divide row tt by 2, then R1 − new R3, R2 − new R3, R4 + 3 × new R3:

Show solution
b.v.xyrstValuer01210−121s05201−129x11200126P0−12003218\begin{array}{c|ccccc|c} \text{b.v.} & x & y & r & s & t & \text{Value} \\ \hline r & 0 & \frac{1}{2} & 1 & 0 & -\frac{1}{2} & 1 \\ s & 0 & \frac{5}{2} & 0 & 1 & -\frac{1}{2} & 9 \\ x & 1 & \frac{1}{2} & 0 & 0 & \frac{1}{2} & 6 \\ P & 0 & -\frac{1}{2} & 0 & 0 & \frac{3}{2} & 18 \end{array}

Now yy has the only negative entry, −12-\frac{1}{2}. Ratios: 11/2=2\frac{1}{1/2} = 2, 95/2=3.6\frac{9}{5/2} = 3.6, 61/2=12\frac{6}{1/2} = 12, so the pivot is in row rr. Multiply row rr by 2, then R2 − 52\frac{5}{2} × new R1, R3 − 12\frac{1}{2} × new R1, R4 + 12\frac{1}{2} × new R1:

b.v.xyrstValuey0120−12s00−5124x10−1015P0010119\begin{array}{c|ccccc|c} \text{b.v.} & x & y & r & s & t & \text{Value} \\ \hline y & 0 & 1 & 2 & 0 & -1 & 2 \\ s & 0 & 0 & -5 & 1 & 2 & 4 \\ x & 1 & 0 & -1 & 0 & 1 & 5 \\ P & 0 & 0 & 1 & 0 & 1 & 19 \end{array}

No negative entries remain, so this is optimal: x=5x = 5, y=2y = 2, P=19P = 19, with s=4s = 4 (4 hours of moulding unused) and r=t=0r = t = 0 (resin and finishing fully used). This matches the graphical solution: each iteration moved to a neighbouring vertex, (0,0)(0, 0) to (6,0)(6, 0) to (5,2)(5, 2).

Try it: step through this example, or your own problem, one decision at a time, and watch each tableau move to a new vertex of the feasible region. The presets include two-stage and big-M problems.

Try it: simulation

Simplex method

Loading the simulation…

Reading a tableau

  • Basic variables take the values in the Value column; non-basic variables are 0.
  • The objective row can be read as an equation. In the final tableau above, P+r+t=19P + r + t = 19, so P=19−r−tP = 19 - r - t: increasing any non-basic variable from 0 would reduce PP, which is why the tableau is optimal.
  • For a minimisation problem, maximise −C-C instead.

Practise this topic

Both are part of Premium.