SMALL, unit 02's tableau example
constraint 1$x + y \le 4$ multiplier $u$: price 1 at the optimum, where it is tight
constraint 2$2x + y \le 6$ multiplier $v$: price 1 at the optimum, where it is tight
the dual$\min\ 4u + 6v$ s.t. $u + 2v \ge 3,\ \ u + v \ge 2,\ \ u, v \ge 0$ $u, v$ weight constraints 1 and 2: in the general formulas, $y = (u, v)$. Optimum $(1, 1)$, value 10
the final tableau$\begin{array}{c|rrrr|r} & x & y & s_1 & s_2 & \text{rhs} \\ \hline y & 0 & 1 & 2 & -1 & 2 \\ x & 1 & 0 & -1 & 1 & 2 \\ \hline z & 0 & 0 & 1 & 1 & 10 \end{array}$ unit 02's, for the running example: basis $\{y, x\}$ at $(2, 2)$. The bottom row's slack columns are the duals $(1, 1)$
Part I · trunk A · linear programming · spine
Every LP has a shadow LP that bounds it, prices its constraints, certifies its optimum, and re-solves it cheaply after a change.
needs 02~2½ h slides + 2½ h lablab: uv run co lab 03
03 · overview
Nonnegative combinations of constraints bound the objective. The best such bound is an LP, and it is exact.
A pair $(x, y)$ with equal objectives proves both optimal. Complementary slackness is the pointwise version.
$y_i$ is what one more unit of $b_i$ is worth, exactly, within a computable range: a shadow price.
The dual simplex method keeps optimality and restores feasibility. It is the method used after adding a cut or a bound.
Words with a dotted underline are glossary terms: click one for its definition. G lists every term in the unit, N shows the notes, where the longer proofs live. One LP, $\max 3x + 2y$, runs through every section: a solid underline like that one shows it on hover. Optional extra: interactive figures, linked from the slides they support by a small ▸ chip; skip them freely.
section 1
Adding up constraints, done as well as possible.
03 · bound
$\max\ 3x + 2y\;$ s.t. $\;x + y \le 4,\ \ 2x + y \le 6,\ \ x, y \ge 0$.
Call this the primal. Multiply the constraints by multipliers $u, v \ge 0$ and add:
$$(u + 2v)\,x + (u + v)\,y \;\le\; 4u + 6v$$If $u + 2v \ge 3$ and $u + v \ge 2$, the left side is at least $3x + 2y$ for every $x, y \ge 0$. So $4u + 6v$ is an upper bound on the optimum.
$u = 3, v = 0$: $\ 3x + 3y \le 12$, bound 12.
$u = 2, v = 1$: $\ 4x + 3y \le 14$, bound 14.
$u = 1, v = 1$: $\ 3x + 2y \le 10$, bound 10. Can any do better?
The best such bound is itself an LP:
$u = v = 1$ gives the bound $10$, and $x = y = 2$ attains $10$. Both are optimal, and neither needed a solver to check.
03 · bound
The dualization rules, for a max primal. In general the multipliers are $y = (y_1, \dots, y_m)$; on the textbook LP they are $(u, v)$.
| primal (max $c^\top x$) | dual (min $b^\top y$) |
|---|---|
| constraint $i$: $a_i x \le b_i$ | $y_i \ge 0$ |
| constraint $i$: $a_i x \ge b_i$ | $y_i \le 0$ |
| constraint $i$: $a_i x = b_i$ | $y_i$ free |
| $x_j \ge 0$ | dual constraint $j$: $(A^\top y)_j \ge c_j$ |
| $x_j \le 0$ | dual constraint $j$: $(A^\top y)_j \le c_j$ |
| $x_j$ free | dual constraint $j$: $(A^\top y)_j = c_j$ |
Multipliers must keep inequalities pointing the right way: $\le$ constraints get $y \ge 0$. The combination must dominate the objective on the variable's allowed sign: $x_j \ge 0$ needs coefficient $\ge c_j$.
For a min primal, flip every sign. Then $\text{dual}(\text{dual}(P)) = P$ exactly, and lab step 1 tests this on 40 random LPs.
03 · bound · example
| primal piece | rule | dual piece |
|---|---|---|
| constraint 1 is $\le$ | $\le$ constraint | $y_1 \ge 0$ |
| constraint 2 is $\ge$ | $\ge$ constraint | $y_2 \le 0$ |
| $x_1 \ge 0$, column $(1, 1)$, cost 1 | $x_j \ge 0$ | $y_1 + y_2 \ge 1$ |
| $x_2$ free, column $(1, -1)$, cost 2 | $x_j$ free | $y_1 - y_2 = 2$ |
| right-hand sides $(3, -1)$ | → costs | $3y_1 - y_2$ |
Primal: $x = (1, 2)$, value $1 + 4 = \mathbf 5$.
Dual: $y = (\tfrac32, -\tfrac12)$, value $\tfrac92 + \tfrac12 = \mathbf 5$.
Check the dual: $\tfrac32 - \tfrac12 = 1 \ge 1$ ✓, $\ \tfrac32 + \tfrac12 = 2$ ✓, signs ✓. Equal values, so both are optimal.
03 · bound
For $\max\{c^\top x : Ax \le b,\, x \ge 0\}$ and its dual: if $x$ and $y$ are feasible, $c^\top x \le b^\top y$.
Why: $c^\top x \le (A^\top y)^\top x = y^\top (Ax) \le y^\top b$: the first step uses $x \ge 0$, the second $y \ge 0$. It is "add up the constraints", written with matrices.
If the primal has an optimal solution, so does the dual, and the optimal values are equal.
Why: if every dual bound stayed above $z^* + \varepsilon$, the constraints plus "objective $\ge z^* + \varepsilon$" would have no solution. Farkas (unit 01) hands over weights proving that, and those weights are a dual solution with a bound below $z^* + \varepsilon$. Contradiction.
full proof in the notes (N)
| primal $(x, y)$ | $3x + 2y$ | dual $(u, v)$ | $4u + 6v$ |
|---|---|---|---|
| $(1, 1)$ | 5 | $(2, 1)$ | 14 |
| $(3, 0)$ | 9 | $(3, 0)$ | 12 |
| $(2, 2)$ | 10 | $(1, 1)$ | 10 |
Every primal value is below every dual value: weak duality, nine comparisons at once. The last row has no gap: strong duality, and both are optimal.
The difference $b^\top y - c^\top x$ is the duality gap of a pair. For $(1,1)$ against $(2,1)$ it is 9; it closes to 0 only at the optimum.
03 · bound
The outcome table: which primal status can pair with which dual status.
| primal \ dual | optimal | unbounded | infeasible |
|---|---|---|---|
| optimal | ✓ equal values | ✗ | ✗ |
| unbounded | ✗ | ✗ | ✓ |
| infeasible | ✗ | ✓ | ✓ possible |
Unbounded primal ⇒ infeasible dual: any dual solution would bound it.
Both infeasible happens, for example with $\max\ x_1$ subject to $x_1 - x_2 \le -1,\ -x_1 + x_2 \le -1$.
It is why presolve sometimes can only say "infeasible or unbounded". In the lab's random general LPs, HiGHS found 246 optimal pairs and 154 unbounded/infeasible pairs out of 400.
section 2
Where the multipliers must be zero, and where they can be read off.
03 · certificate
Feasible $x$ and $y$ are both optimal if and only if
$$y_i\,(b_i - a_i x) = 0 \ \text{ for every constraint } i, \qquad x_j\,\big((A^\top y)_j - c_j\big) = 0 \ \text{ for every variable } j.$$$b^\top y - c^\top x = \underbrace{y^\top (b - Ax)}_{\ge 0} + \underbrace{x^\top (A^\top y - c)}_{\ge 0}$
Every piece is (nonnegative) × (nonnegative). The gap is 0 exactly when every piece is 0, and a zero gap means both are optimal.
In words: a constraint with slack has price 0. A variable that is used has zero reduced cost. Only a binding constraint can carry a price.
Checking takes two matrix–vector products: an optimality certificate, lab step 3. The next slide runs the checks on the example.
03 · certificate · example
$x = (2, 2)$ and the dual's $(u, v) = (1, 1)$:
| piece | slack | paired with | product |
|---|---|---|---|
| constraint 1 | $4 - 4 = 0$ | $u = 1$ | 0 |
| constraint 2 | $6 - 6 = 0$ | $v = 1$ | 0 |
| variable $x$ | $3 - 3 = 0$ | $x = 2$ | 0 |
| variable $y$ | $2 - 2 = 0$ | $y = 2$ | 0 |
All four products are 0, so the gap $10 - 10$ is 0.
$x = (0, 0)$ with $(u, v) = (1, 1)$. Constraint 1 has slack 4 but price 1: product 4. Constraint 2: slack 6, price 1: product 6. The gap is $10 - 0 = 4 + 6$, exactly the sum. The certificate check rejects it on constraint 1.
Given only $x = (2, 2)$: both variables are positive, so both dual constraints must be tight:
$u + 2v = 3,\quad u + v = 2 \;\Rightarrow\; v = 1,\ u = 1.$
Two equations, no optimization. Then check $u, v \ge 0$: yes, so $(2, 2)$ is proved optimal.
Add the constraint $x \le 3$. At $(2, 2)$ it has slack 1, so its price must be 0. Solving confirms duals $(1, 1, 0)$, optimum still 10. Loosening a constraint that isn't pressing changes nothing.
03 · certificate
At an optimal basis, $y^\top = c_B^\top A_B^{-1}$, and the reduced cost of every column is $\bar c_j = c_j - y^\top a_j$.
A slack $s_i$ has cost 0 and column $e_i$, so $\bar c_{s_i} = -y_i$. The objective row, which stores $-\bar c$, holds $y_i$ in slack column $i$.
The optimal dual solution is the slack columns of the objective row (reading duals off the tableau). Every simplex solve returns a primal solution and a dual certificate at once.
Unit 02's final tableau:
| y | 0 | 1 | 2 | −1 | 2 |
| x | 1 | 0 | −1 | 1 | 2 |
| z | 0 | 0 | 1 | 1 | 10 |
$(u, v) = (1, 1)$, and $4u + 6v = 10 = 3x + 2y$.
section 3
What a unit of each resource is worth, and for how long.
03 · prices
Optimum of the textbook LP as the right-hand side of $x + y \le b_1$ varies. Shaded: the range where the current basis stays optimal.
If the optimal basis is nondegenerate, $\;\dfrac{\partial z^*}{\partial b_i} = y_i$.
More generally the value function $z^*(b)$ is concave and piecewise linear, and $y$ is a supergradient.
Here $y_1 = u = 1$ on $b_1 \in [3, 6]$. Below 3, constraint 2 stops binding and the price jumps to 3. Above 6, constraint 1 itself stops binding and the price drops to 0.
03 · prices
Ranging: change $b_i$ to $b_i + \delta$. Reduced costs don't involve $b$, so the basis stays optimal for as long as it stays feasible:
$$x_B(\delta) = A_B^{-1}(b + \delta e_i) = \bar b + \delta\, d$$where $d$ is slack column $i$ of the final tableau.
Feasible while $\bar b_r + \delta d_r \ge 0$ for all rows:
$$\max_{d_r > 0} \frac{-\bar b_r}{d_r} \;\le\; \delta \;\le\; \min_{d_r < 0} \frac{-\bar b_r}{d_r}$$Slack column 1 is $d = (2, -1)$ with $\bar b = (2, 2)$: $\delta \in [-1, 2]$, so $b_1 \in [3, 6]$. Inside, $z^* = 10 + 1\cdot\delta$.
HiGHS's ranging report gives $[3, 6]$ with objective 9 and 12 at the ends. The lab's then checks 103 binding constraints, and all agree.
Outside the range the basis changes and the slope changes. A linear prediction there is wrong, which is why lab step 5 must refuse it.
03 · prices
The same LP, $\max 3x + 2y$, $x + y \le 4$, $2x + y \le 6$:
| source | $u$ | $v$ |
|---|---|---|
| your tableau | 1 | 1 |
HiGHS, sense=max | 1 | 1 |
| HiGHS, written as $\min -c^\top x$ | −1 | −1 |
SciPy linprog marginals | −1 | −1 |
A reported dual is $\partial(\text{objective})/\partial(\text{rhs})$ in the solver's own objective sense.
Maximizing, loosening a $\le$ constraint helps, so the dual is $\ge 0$. Minimizing $-c^\top x$, the same loosening lowers the objective, so it is $\le 0$.
section 4
Keep optimality, restore feasibility.
03 · dual simplex
State: a basis whose objective row is nonnegative (dual feasible) but with some negative right-hand sides (no primal feasibility).
It is exactly the primal simplex method applied to the dual LP, run on the same tableau.
The dual ratio test keeps every objective-row entry nonnegative after the pivot, and the objective value decreases monotonically toward the optimum from above.
Row $r$ in the infeasible case, an infeasible row, is a Farkas certificate: unit 01 again.
The next slide runs one pivot of it on the example.
03 · dual simplex · example
From the optimum $(2, 2)$, add the cut $x \le 1.5$ with slack $s_3$. Written in the current basis, its row is $s_1 - s_2 + s_3 = -\tfrac12$:
| x | y | s₁ | s₂ | s₃ | rhs | |
|---|---|---|---|---|---|---|
| y | 0 | 1 | 2 | −1 | 0 | 2 |
| x | 1 | 0 | −1 | 1 | 0 | 2 |
| s₃ | 0 | 0 | 1 | −1 | 1 | −½ |
| z | 0 | 0 | 1 | 1 | 0 | 10 |
1. Objective row still $\ge 0$: dual feasible. Only $s_3 = -\tfrac12$ is wrong, so row $s_3$ leaves.
2. Negative entries in that row: only $s_2$, ratio $1 / 1$. $s_2$ enters.
3. Pivot. New point $(1.5, 2.5)$, $z = 9.5$, every rhs $\ge 0$: optimal after one pivot.
A cold re-solve from the origin takes 2 pivots. New duals $(2, 0, 1)$: constraint 2 now has slack $\tfrac12$, and price 0.
Shaded: what the cut removes. Ring: the old optimum, now infeasible. The pivot slides along $x + y = 4$ to the new corner.
03 · dual simplex
After an optimal solve, add a cut $a^\top x \le \beta$ (unit 08) or tighten a bound $x_j \le \lfloor x_j^* \rfloor$ (unit 07):
That is the dual simplex's starting state, and it is typically a few pivots away from optimal: a warm start, not a cold start.
Lab then, 163 random LPs with one added cut:
| warm | cold | |
|---|---|---|
| your dual simplex (pivots) | 0.98 | 3.34 |
| HiGHS (iterations) | 0.96 | 3.47 |
On 4×5 LPs. The ratio widens with size: a cold solve's pivots grow with the LP, while a warm re-solve's pivots grow with the size of the change.
03 · the load
| 08 cutting planes | cuts are new constraints; the dual simplex re-optimizes after each round; Gomory cuts are read off the tableau. |
| 10 column generation | the master's duals are the pricing problem's objective; a column with positive reduced cost enters. |
| 11 Lagrangian relaxation | price the hard constraints, and the best prices give a bound: a partial dual, climbed by subgradients. |
| 12 Benders | subproblem duals become cuts on the master: duals as rows instead of columns. |
| 15 matching | the Hungarian algorithm keeps dual potentials feasible and grows the matching on tight edges: primal–dual, and complementary slackness. |
| 24 primal–dual approximation | raise duals until constraints go tight, buy what goes tight, and bound the cost by weak duality. |
| 29 KKT | the conditions of this unit for curved objectives and constraints: feasibility, dual feasibility, complementary slackness. |
When one of those units feels hard, come back to the slide here that it generalizes: the seven hats are one idea.
03 · lab
uv run co test 03
uv run co then 03 # sign conventions · ranging vs HiGHS · warm vs cold
03 · checkpoint
Bertsimas & Tsitsiklis, ch. 4 (§4.1–4.5) and §5.1–5.2.
Chvátal, ch. 5 and 10.
Gärtner & Matoušek, §6.5–6.6 (optional).
05 formulations (IP begins) · 04 ellipsoid and interior point (branch) · 11 Lagrangian relaxation, which needs 16 as well · 29 convexity, if you want the continuous view now.