4.10.21 · D2Advanced Topics (Elite Level)

Visual walkthrough — Linear programming — simplex method (intro)

2,257 words10 min readBack to topic

Step 1 — Draw the playground (the feasible region)

WHAT. We are given the problem which we want to make as big as possible, and two rules the pair must obey:

Here and are just two dials you can turn — call them decision variables. Every choice of the two dials is a point on a flat map. Each "" rule says "stay on one side of a straight line". Overlap all the allowed sides and you get a shape.

WHY start here. Before any algebra, we need to see the space of legal choices. A "" inequality carves the plane into two halves — a half-plane — and keeps one half. Four rules = four half-planes. Their common overlap is the feasible region: every point that breaks no rule.

PICTURE. The shaded region below is that overlap — a four-cornered fenced field. Its corners are marked. Those corners are the only places the maximum can live (we prove why in Step 2).

Figure — Linear programming — simplex method (intro)

Step 2 — Why the prize sits at a corner

WHAT. The objective takes a value at each point. Points sharing the same value of lie on a straight line: set for a fixed number and you get one line. Change and the line slides — parallel to itself. These are the level lines of .

WHY this tool. We want the largest , so we ask: how far can the sliding line move in the "more profit" direction and still touch the field? The direction of steepest increase is the gradient — an arrow pointing where climbs fastest. Because is linear, every level line is straight and they are all parallel. Slide the line up the gradient until it is about to leave the field: the last point of contact is a corner (or, in a tie, a whole edge — but an edge always includes corners). So we never need interior points.

PICTURE. Watch the dashed level lines march up the field in the direction. The last one to touch grazes the corner — the winner.

Figure — Linear programming — simplex method (intro)

Here just means "how much rises per unit of " — it's because the term adds each time goes up by one. Same idea gives for .


Step 3 — Turn "less-than" rules into clean equations (slack)

WHAT. An inequality like has spare room. If you're using only of your budget of , there's left over. Name that leftover :

The new variables are slack variables: each measures how much of that rule is unused.

WHY do this. Computers and clean linear algebra love equations, not inequalities. With slacks, every "" becomes "", and now row-reduction can solve things. Bonus meaning: means rule A is tight — you're standing right on that fence line.

PICTURE. Each fence has a coloured "slack bar" showing the unused amount. On the boundary the bar shrinks to zero.

Figure — Linear programming — simplex method (intro)

Step 4 — Write the starting corner as a table (the tableau)

WHAT. Stack the two slack equations and the objective (rearranged as ) into a grid. Each row is one equation; each column is one variable's coefficients.

Basis RHS
1 1 1 0 4
1 3 0 1 6
0 0 0

WHY here, why now. We must start at some legal corner. Setting (both dials off) leaves — both positive, so it's legal. That's the corner with . This is the safe launch pad because the budgets are non-negative.

PICTURE. The tableau is the corner drawn as a table. The bottom row secretly stores (move the negatives across).

Figure — Linear programming — simplex method (intro)

Reading the bottom row term-by-term: A negative number under a column means "turning that dial up raises " — a chance to improve.


Step 5 — Choose who enters (steepest improvement)

WHAT. Look only at the -row: under , under . The most negative is . So will become basic — it enters.

WHY. Each negative is the rate of profit gained per unit of that dial. beats : raising pays per unit, the steepest climb available. Picking the most negative is the greedy "go up the steepest fence-edge" move.

PICTURE. From corner , two edges leave — one along the -axis, one along . The -edge is steeper in profit, so we step onto it.

Figure — Linear programming — simplex method (intro)

Step 6 — Choose who leaves (the ratio test)

WHAT. We slide up along its edge. But a fence will stop us. For each row with a positive entry in the column, compute : The smallest ratio, , wins: row is the binding fence, so leaves the basis.

WHY only positive entries, why the smallest. As grows, each slack changes by . If the entry is positive, that slack shrinks and will hit at — that's where you slam into the fence. The first fence you meet (smallest ratio) is the limit; going past it drives a slack negative = illegal. A negative or zero entry means that slack never runs out in this direction, so it never stops you — skip it.

PICTURE. Ride the red arrow up the -axis. Fence A (from rule A) blocks you at ; fence B would only block at . You stop at the nearer one, .

Figure — Linear programming — simplex method (intro)

Step 7 — Pivot: make basic (row-reduce)

WHAT. The pivot is the entry at (row , column ) . We make its whole column into a unit column using row operations:

  • Row : divide by pivot () → unchanged.
  • Row : (kill the above… below it).
  • Row : (kill the ).
Basis RHS
1 1 1 0 4
0 2 1 2
0 1 3 0 12

WHY. After this, reading the table off directly gives — we've moved to the corner . Pivoting is exactly "re-solve the equations so the new corner's values sit in the RHS column".

PICTURE. The hop: from up the edge to , profit jumping .

Figure — Linear programming — simplex method (intro)

Reading the new -row: , i.e. Both coefficients are now non-negative, so turning any off-dial up can only lower .


Step 8 — Know when to stop (optimality)

WHAT. The -row is now no negative entries left. Stop. The corner with is optimal.

WHY. A negative in the -row was our "improvement available" flag. None left = no dial can be raised to gain profit = we're at the top of the ramp. This matches the picture from Step 2: the last level line grazed exactly .

PICTURE. Corner scoreboard — every vertex's value shown; wears the crown.

Figure — Linear programming — simplex method (intro)

Cross-check against every corner (no case skipped):

Corner how it arises
both dials off
on fence B,
fences A & B cross
on fence A,

The winner appears at — exactly where simplex stopped.


The one-picture summary

Everything above in a single frame: the field, the sliding profit lines, the corner-hop that simplex takes, and the crowned optimum.

Figure — Linear programming — simplex method (intro)
Recall Feynman retelling — the whole walk in plain words

You're in a many-cornered fenced field (the feasible region). The ground is a flat ramp tilting toward "more profit" (the linear objective). On a flat ramp, the highest reachable spot is always a corner, so you only ever need to visit corners. To turn the fuzzy "" fences into exact lines you can compute with, you give each fence a "leftover" measure — a slack — that hits zero when you touch that fence. You start at the easy corner where all dials are off. You read the table: any negative number in the bottom row means "turning this dial up earns profit", so you pick the biggest earner (enter, most negative). You walk up that edge until the first fence stops you — found by the smallest RHS-over-positive-entry ratio (leave, smallest ratio). You re-solve the equations (pivot) so the new corner's numbers slide into place. Repeat. The instant the bottom row has no negatives left, no dial can earn more — you're standing on the highest corner. Done.


Connections

  • Convex Sets and Polytopes — the field is a convex polytope; that's why optima live at corners.
  • Gradient and Level Sets — Step 2's sliding lines and the climb arrow.
  • Gaussian Elimination — the pivot in Step 7 is exactly guided row reduction.
  • Duality in Linear Programming — the same optimum read from the partner problem.
  • Integer Programming — what changes when the dials must be whole numbers.
  • Optimization (Lagrange Multipliers) — the smooth-constraint cousin of this corner-walk.