LP duality: what can you prove about the cheapest plan?
The question
How can prices for blankets and water certify the lowest cost of filling an order?
- 1 SeeSet prices and close the gap.
- 2 TryPredict what extra supplies change.
- 3 ProveBuild the duality proof line by line.
- 4 ApplyCheck bounds and certify costs.
Before you start · 3 quick checks on weighted totals, inequalities, and transposing a table
Two ideas before you start
2 ideasA purchase plan must fill the order
Two bars show the quantities delivered. Marks show the minimum requirements.
Switch plans and compare the end of each bar with its requirement mark. A plan must meet both requirements.
Exact definition
The original problem, or primal, minimizes \(c^\top x\) over \(x\ge0\) with \(Ax\ge b\). The vector \(x\) lists crate amounts, \(c\) lists crate costs, \(A\) lists the supplies in each crate, and \(b\) lists required quantities. Row \(i\) of \(A\) describes one supply. Column \(j\) describes one type of crate. Vector inequalities compare matching coordinates.
A set of prices must pass the crate tests
A bar shows the value assigned to one crate’s contents. The mark shows its cost.
Value each crate’s contents using your chosen prices. Each assigned value must stay at or below its crate cost.
Exact definition
The dual maximizes \(b^\top y\) over \(y\ge0\) with \(A^\top y\le c\). The vector \(y\) lists dollars per unit of each supply. The transpose \(A^\top\) turns each original column into a row, so the \(j\)-th coordinate of \(A^\top y\) prices the contents of crate \(j\). The dual objective prices the required quantities at those same rates.
Fine print on what the model counts
Crate amounts can be any nonnegative real numbers. Buying a fraction of a crate gives that fraction of its supplies and costs that fraction of its price. Supplies add across crates, costs are fixed, and extra supplies are allowed. The game uses whole-dollar price inputs. The mathematical dual allows any nonnegative real prices that pass the crate tests.
A superscript \(\top\) indicates a transpose. A vector product such as \(c^\top x\) adds matching products. A table product such as \(Ax\) does that calculation once per row. The same notation covers more than the supplies and crates pictured here.
Raise the lower bound
- Set a price per blanket and a price per canister of water.
- Keep the assigned value of each crate’s contents at or below its cost.
- Check your prices and try to close the gap to the least feasible cost.
How the page checks your prices
Pricing all supplies in a feasible purchase plan gives at least the value assigned to the order, because prices are nonnegative and the plan fills the order. That same total is at most the purchase cost, because each crate passed its price test. The order value is therefore a lower bound on the cost of any feasible plan.
The two quantities shown by the page come from different choices. Prices give the bound. A purchase plan gives a cost. The gap is the least feasible cost minus your bound, so it is shown only for a price pair that passes both tests. When a bound and a feasible cost agree, each side certifies the other.
What changes when the order changes?
Consider a new order and new crate costs. Suppose a feasible plan and a feasible set of prices already agree in value. The plan delivers more blankets than the order requires.
Test the price in two orders
- Move the prices until your feasible bound matches the displayed plan’s cost.
- Use Next goal to change the blanket requirement and reset the prices.
Why the bound holds and when it is exact
Let \(A\) be a real matrix with finitely many rows and columns, and let \(b,c\) be real vectors of matching sizes. Use the primal and dual forms from Start. Weak duality says \(b^\top y\le c^\top x\) for any feasible pair. Strong duality says that if the primal is feasible and its cost is bounded below by a finite number, both optima are attained and their values agree.
Build the weak bound first. Then use separation to show why bounds can get arbitrarily close to the primal optimum.
Proof setup for the separation steps
Form the set \(C\) of pairs \((u,v)\) that admit some \(x\ge0\) with \(Ax\ge u\) and \(c^\top x\le v\). Write \(u=Ax-s\) and \(v=c^\top x+t\) with \(s,t\ge0\). The set is a cone, meaning it is closed under nonnegative linear combinations. Its generators are the crate columns paired with their costs, the vectors \((-e_i,0)\) for unit coordinate vectors \(e_i\), and \((0,1)\), the cost direction. The proof uses ordinary vector algebra here, without assuming that \(A,b,c\) have positive entries.
A cone generated by finitely many vectors is closed. Each conic combination can be reduced to an independent set of generators. If the generators with positive coefficients are dependent, take a dependence with at least one positive coefficient. Subtract the largest multiple of it that keeps every coefficient nonnegative. At least one coefficient becomes zero, and that generator drops out. Repeat. Each independent set generates a closed cone because coordinates in its span are continuous. Finitely many of those closed cones cover \(C\), including the origin from the empty set.
Let \(p\) be the finite infimum of feasible cost. By closedness, \((b,p)\in C\), since there are feasible costs approaching \(p\). So some \(x\ge0\) has \(Ax\ge b\) and \(c^\top x\le p\), which means the primal optimum \(p\) is attained. For any \(\varepsilon\gt0\), \((b,p-\varepsilon)\) lies outside \(C\). The separating hyperplane theorem gives a linear functional \(\ell(u,v)=-z^\top u+\gamma v\) strictly smaller there than on \(C\). In particular its value there is negative, since \(0\in C\). Its value is nonnegative throughout \(C\), since a negative value in the cone could be scaled arbitrarily far below the separating level.
The last step gives a feasible price vector for each positive \(\varepsilon\). Weak duality gives the other inequality, so the supremum of the feasible price values is \(p\). To see why it is attained, write the dual as minimizing \(-b^\top y\) with \((-A^\top)y\ge -c\) and \(y\ge0\). This minimization is feasible and bounded below. The same closed-cone argument in the setup ensures that its infimum is attained.
For any feasible pair the gap splits into two sums of nonnegative terms. The equality below groups them by crates and by requirements, respectively.
\[\begin{aligned} c^\top x-b^\top y &= x^\top(c-A^\top y)\\ &\quad + y^\top(Ax-b). \end{aligned}\]The gap vanishes exactly when every product in these sums vanishes. Any crate you buy in a positive amount must have its cost matched by its assigned value. A supply priced above zero must have its requirement met exactly. These are the LP complementary slackness conditions. Zero price is compatible with a tight requirement, as the second order in Try illustrates. The linear programming lesson approaches optimality by looking at corners of a feasible region.
Check prices, then use them as certificates
Each order below uses the same crate mixes and gives its own purchase costs. Treat amounts as divisible and costs as linear. Use dollars unless the question asks for another unit.
Further reading
- Dimitris Bertsimas and John N. Tsitsiklis, Introduction to Linear Optimization.
- Stephen Boyd and Lieven Vandenberghe, Convex Optimization.