4.10.21 · D3Advanced Topics (Elite Level)

Worked examples — Linear programming — simplex method (intro)

4,499 words20 min readBack to topic

Before we start, one reminder of the vocabulary the parent built, because we will use it in line one of every example:

Recall The five words we reuse everywhere
  • Decision variables — the numbers you get to choose.
  • Slack variable — the "unused room" that turns into .
  • Basic variable — one we actually solve for; non-basic — one we force to .
  • Tableau — the grid of equation coefficients we pivot on.
  • Optimal (for maximizing) — reached when every number in the -row is .

The scenario matrix

Think of the simplex method as a machine with three moving parts: entering rule, ratio test, stopping rule. Each part has a "normal" behaviour and several "surprising" behaviours. The grid below lists every combination we must be able to survive. There are ten cells (A–J), and the nine worked examples below cover all ten — Example 7 deliberately handles two cells at once (a constraint solved as a minimization), so 9 examples 10 cells. Each example announces its cell(s) in its heading.

Cell What is unusual about this case Covered by
A. Clean run Nothing — one path straight to the top Example 1
B. Tie in entering column Two -row entries equally negative Example 2
C. Tie in ratio test (degeneracy) Two rows share the smallest ratio; a basic variable becomes Example 3
D. Unbounded objective Entering column has no positive entry; Example 4
E. Multiple optima A non-basic -row coefficient equals at the end; a whole edge is optimal Example 5
F. Degenerate start / zero RHS A constraint has ; corner sits on a wall from the start Example 6
G. constraint Wrong-way inequality; needs surplus + artificial variables Example 7
H. Minimization We want the smallest ; maximize Example 7
I. Word problem Numbers hidden in a story + units; model, then solve Example 8
J. Exam twist "How much can a coefficient change before the answer moves?"; sensitivity Example 9

Cell count reconciled: 10 cells, 9 examples, because Example 7 = Cells G + H together.


Example 1 — Cell A: the clean run (baseline, with geometry)

Forecast: Before reading on, guess the optimal corner. The steeper "profit per unit" is on ( vs ), so bet the winner leans toward large . Write your guess down.

Read the figure first. The two constraint lines are drawn — the solid line labelled "" and the dashed line labelled "" (each line is also written on the figure in words, so you never need the colour to tell them apart). The hatched region is the feasible set; its four corners (where lines cross) are marked with dots and labelled with their -values. The big arrow marked " increases" points into the top corner — that is the corner the machine will crawl toward.

  1. Add slacks. Why this step? The machine only eats equations, so name the leftover room in each :

  2. Start at . Why? Setting makes — a legal corner (the origin, where the two axes cross, is feasible), .

    Basis RHS
    2 1 1 0 10
    1 3 0 1 15
    0 0 0
  3. Entering variable. Why? is the most negative, so pushing up gains fastest. enters.

  4. Ratio test. Why? Divide RHS by positive column entries: , . Smallest is (row 1) — go further and turns negative. leaves.

  5. Pivot on the . Why pivot at all? Pivoting makes the entering column a unit vector, so becomes basic (solved for) while drops out — this is exactly the algebra of hopping to the next corner. Row1 ; Row2 Row1(new); -row Row1(new):

    Basis RHS
    1 0 5
    0 1 10
    0 2 0 20
  6. Still a under → not optimal. enters. Ratios: , . Smallest leaves. Why pivot on the ? Same reason as before: making the column a unit vector turns basic and moves us along an edge to the next, higher corner.

    Basis RHS
    1 0 3
    0 1 4
    0 0 24
  7. All -row entries → optimal. Corner , .

Verify: Check constraints: ✓ (tight), ✓ (tight). Both tight, so is a genuine corner (two lines crossing). ✓. Compare corners , , , — max confirmed, and it is the corner the arrow in the figure pointed at.


Example 2 — Cell B: a tie for who enters

Forecast: The two variables have identical profit ( each) and the region is symmetric. Guess: the answer sits on the line of symmetry .

  1. Initial -row: . The tie: both are "most negative". Why does the tie not matter? Either choice still increases ; simplex converges either way. Apply Bland's rule (stated at the top): break the tie by lowest index, so enters.

  2. enters. Ratios , → row 2 leaves (). Why pivot on the ? To make the column a unit vector so becomes basic — the corner-hop step:

    Basis RHS
    0 1 4
    1 0 4
    0 0 20
  3. under enters. Ratios , → row 1 leaves. Why pivot on the ? Same rule: unit-vector the column, hop to the next corner:

    Basis RHS
    0 1
    1 0
    0 0
  4. All → optimal at , .

Verify: ✓ matches the symmetry forecast. ✓ tight; ✓ tight. ✓. Had we broken the tie the other way, we'd land on the same corner — the lesson of Cell B.


Example 3 — Cell C: a ratio-test tie (degeneracy)

Forecast: The three lines , , all pass through . Three walls, one corner: the corner is "over-determined". Guess: the optimum is but the machine may take a "stalled" step where the answer doesn't improve.

  1. Slacks: , , . Initial tableau (start at ):

    Basis RHS
    1 0 1 0 0 2
    0 1 0 1 0 2
    1 1 0 0 1 4
    0 0 0 0
  2. enters (-row tie → Bland's rule picks lowest index ). Ratios: (row 1), -row has in column (skip), (row 3). Smallest leaves. Why pivot on row-1 -entry ()? To make basic and hop to the corner :

    Basis RHS
    1 0 1 0 0 2
    0 1 0 1 0 2
    0 1 0 1 2
    0 1 0 0 2

    Now at corner (where meets ).

  3. under enters. Ratios: (row 2, ), and row 3 now gives too () — a tie. Why it matters: whichever we pick, the other basic variable will land at exactly — a degenerate basic feasible solution. Bland's rule breaks it: choose the leaving variable of lowest index, (index below ).

    Read the figure: the wall labelled "", the wall labelled "" and the line labelled "" all pierce the single marked point (each line is drawn with a different dash pattern and captioned in words). Three walls, one corner — that visual over-crowding is exactly what "degenerate" means, and it is why two rows tied in the ratio test.

  4. leaves (pivot on row-2 -entry to make basic). We reach with , but sits in the basis at value 0. Why this is the whole point of Cell C: the corner can be described by two different bases; the simplex might swap between them with zero improvement (a stall). Bland's lowest-index rule is exactly what stops that swap from looping forever.

  5. Check the -row after that pivot: all → optimal, .

Verify: : ✓ tight, ✓ tight, ✓ tight — three tight constraints at one corner is exactly what "degenerate" means. ✓.


Example 4 — Cell D: unbounded objective (no maximum)

Forecast: Look at the constraints — both let grow enormously as long as trails behind. Guess: this region is an open wedge and can be pushed to infinity.

Read the figure first. The two constraint lines (one solid, one dashed, each captioned in words) bound a hatched region that does not close up — it flares open to the upper-right forever. The big arrow marked " increases" rides that open channel: as you slide along it, both and grow without limit, so has no ceiling. A closed polygon would trap the arrow at a corner; this open wedge never does.

  1. Slacks: , . Initial -row .

  2. enters (-row tie → Bland's rule picks ). Ratio test needs positive column entries: column is . Only row 2's is positive → ratio . leaves. Why pivot on that ? To unit-vector the column and make basic — the usual corner-hop:

    Basis RHS
    0 1 1 3
    1 0 1 2
    0 0 1 2
  3. under enters. Column is both negative! Why this is the signal: the ratio test only accepts positive entries, and there are none. That means we can raise forever without any constraint stopping us, and rises without bound.

  4. Conclusion: the LP is UNBOUNDED. There is no finite maximum.

Verify: Set and follow the basis: , (all stay for every ). Then as ✓. The forecast (open wedge) holds.


Example 5 — Cell E: multiple optima (a whole optimal edge)

Forecast: The objective is maximized by making as big as possible — but caps it at . Guess: every point on the segment inside the region gives . Not one corner — a whole edge.

Read the figure first. The solid line captioned "" is parallel to the dashed "objective level lines" (lines of constant ). Because they are parallel, the objective doesn't touch the region at a single corner — it lies flat along the whole bold edge from to . Every point on that bold edge scores the same ; that is what "multiple optima" looks like.

  1. Slacks: , . -row .

  2. enters (-row tie → Bland's rule picks ). Ratios , leaves. Why pivot on the -entry in row 2? Unit-vector the column, make basic, hop to corner :

    Basis RHS
    0 1 1 1
    1 0 0 1 3
    0 0 2 6
  3. under enters. Ratio leaves. Why pivot on the -entry in row 1? Same rule; hop to corner :

    Basis RHS
    0 1 1 1
    1 0 0 1 3
    0 0 2 0 8
  4. All -row → optimal, at . But look at : its -row coefficient is and is non-basic. Why this signals multiple optima: a under a non-basic variable means we could bring it into the basis and would not change. Doing so slides us to the other corner — same , exactly the bold edge in the figure.

Verify: Corner : ✓. Corner : ✓. Midpoint on the edge: ✓ — the entire segment is optimal, exactly as forecast.


Example 6 — Cell F: degenerate start ( constraint)

Forecast: The first constraint with passes through the origin. So the starting corner already sits on that wall — the very first tableau is degenerate. Guess: the first pivot may look "stuck" (no visible improvement) before things move.

  1. Slacks: , . Start : , . Note already — degenerate start (the origin already lies on the wall ).

  2. enters ( most negative). Ratios: row 1 , row 2 . Smallest is leaves. Why the zero ratio is fine: it means can increase by this step — a degenerate pivot that swaps the basis without moving the corner.

  3. Why pivot on row-1 -entry ()? To make basic even though we won't physically move — the basis-swap is what lets the next step escape the wall:

    Basis RHS
    1 1 0 0
    0 2 1 4
    0 3 0 0

    Still , — the stall the forecast predicted.

  4. under enters. Ratios: row 1 has (skip, negative), row 2 leaves. Why pivot on the ? Unit-vector the column, make basic, finally hop off the wall to a new corner:

    Basis RHS
    1 0 2
    0 1 2
    0 0 10
  5. All → optimal, , .

Verify: ✓ tight; ✓ tight; ✓. The degenerate first pivot cost us one "empty" step but reached the right answer — matching the forecast.


Example 7 — Cells G + H: a constraint via the two-phase simplex

Forecast: Minimizing a positive-cost objective pushes both variables down toward ; the constraint stops them. Guess the cheapest corner is where meets an axis.

  1. Turn minimization into maximization (Cell H). Why? The machine maximizes. Min = , so maximize .

  2. Convert the properly (Cell G) — surplus + artificial. Why not just multiply by ? That would give a negative RHS, so the origin is infeasible and plain simplex cannot start. Instead, for we subtract a surplus variable (the amount by which we exceed ) and add an artificial variable (a temporary crutch that gives us a legal starting basis): Start with basis : — legal.

  3. Phase 1 — drive the artificial to zero. Why? means we're cheating (the real constraint isn't yet satisfied). Minimize , i.e. maximize . Express in non-basic terms using , so ; the -row is under .

    Basis RHS
    1 1 1 0 2
    1 2 0 0 1 6
    1 0 0

    enters (-row tie → Bland's rule picks ). Ratios , leaves. Why pivot on the -row -entry ()? To make basic and kick the artificial out:

    Basis RHS
    1 1 1 0 2
    0 1 1 1 4
    0 0 0 1 0 0

    with non-basic → Phase 1 done, artificial is gone, and is a legal starting corner.

  4. Phase 2 — now optimize the real objective . Drop the column. Express in non-basic terms: with , , so the -row is under and under :

    Basis RHS
    1 1 0 2
    0 1 1 1 4
    0 0

    enters (, most negative). Ratio test uses positive entries in the column : only row 2's qualifies → ratio leaves. Why pivot on that ? Unit-vector the column, make basic, hop to a new corner:

    Basis RHS
    1 2 0 1 6
    0 1 1 1 4
    0 1 0 2 4

    This new corner is , i.e. , with -row RHS , meaning the same as the previous tableau. So the pivot did not improve : both tableaux record . The stored optimum is at corner (the pre-pivot tableau was already optimal). Hence the true optimum is , i.e. , at .

Verify: Feasibility of : ✓ tight, ✓. Cross-check every corner of : , , , ; the two lines cross at (discard). Minimum at ✓ — matching the two-phase result and the forecast (a corner on an axis).


Example 8 — Cell I: a real-world word problem (with units)

Forecast: Tables earn more per unit but hog carpentry. Guess a mix, not "all tables".

  1. Model it (the hard part of word problems). Why define units first? So the constraints balance. Let chairs/day, tables/day (both dimensionless counts).

    \underbrace{2x_1+1x_2\le 8}_{\text{polishing hr}},\quad x_1,x_2\ge0.$$ Objective (dollars/day): $z=20x_1+30x_2$.
  2. Slacks (spare carpentry hr), (spare polishing hr). -row .

  3. enters ( most negative). Ratios , leaves. Why pivot on the ? Unit-vector the column, make basic, hop to the next corner:

    Basis RHS
    1 0 4
    0 1 4
    0 10 0 120
  4. under enters. Ratios , leaves. Why pivot on the ? Same rule: make basic, hop to the final corner:

    Basis RHS
    0 1
    1 0
    0 0 8 6 144
  5. All → optimal: chairs, tables, profit z=\144$/day.

Verify (with units!): Carpentry used hr ✓ (all used, tight). Polishing hr ✓ (all used, tight). Both constraints tight ⇒ genuine corner. Profit ✓. (Sanity: solving the two tight equations , directly gives the same .)


Example 9 — Cell J: the exam twist (sensitivity)

Forecast: If chairs