Applied

What a constraint is worth

The rung below settled that a linear program and its dual reach the same number. This one asks what the dual's variables are, and the answer converts a solution into a rate for every constraint — piecewise constant, zero on the constraints that are not doing any work.

Worth reading first: Two numbers that have to meet · The slope of a single point.

The rung below settled that a linear program and the program built from its transpose reach the same number, and left the second program looking like a device for proving something about the first. It has variables of its own, one for each constraint, and nobody has asked what they are.

What one more unit of constraint 1 is worthThe optimum of a linear program plotted against one of its right-hand sides, as an exact piecewise linear graph, with the breakpoints marked and each piece's slope named as a dual variable.51015202530051015202530b₁max 3x₁ + 4x₂b₁ = 5b₁ = 30slope 2 = y₁slope 4/5 = y₁slope 0 = y₁one row per linear piecethe optimum sits onslope of the optimumdual variable y₁b₁ from 2 to 5b₁ from 5 to 30b₁ from 30 to 32row 1 and x₁ = 0(0, 5/4)22row 1 and row 2(1/5, 49/20)4/54/5row 2 and x₂ = 0(10, 0)00the optimum is piecewise linear in b₁ with 3 pieces, breaking at b₁ = 5 and 30on each piece the slope, taken from the optima at the two ends, equals the dual variable y₁ at the middleof that piece — 2, then 4/5, then 0 — and it changes exactly where a different vertex becomes optimal
Fig. 1 The optimum of max 3x₁ + 4x₂ plotted against the right-hand side of its first constraint, the program re-solved exactly at every whole value from 2 to 32. Three straight pieces, breaking at b₁ = 5 and b₁ = 30, and on each piece the slope — taken from the two optima at its ends — was asserted equal to the dual variable y₁ computed independently at the middle of that piece.

The rate, and what “worth” means here

Each dual variable is attached to one constraint of the primal program, and the claim of this essay is that it measures exactly one thing:

The dual variable yiy_i is the rate at which the optimum changes when the $i$th constraint’s right-hand side is relaxed by one unit.

Relax the first constraint of the program above from b1=12b_1 = 12 to b1=13b_1 = 13 and the optimum rises by 4/54/5. The dual variable on that constraint is 4/54/5. Those are the same number and not by coincidence, and the figure above is that statement checked at thirty of its own intervals rather than asserted.

The word worth in the title carries no more than that. It means worth in units of the objective: the objective is 3x1+4x23x_1 + 4x_2, the right-hand side is a number on the other side of a \le, and a dual variable is a quantity of the first per unit of the second. It is not a cost, there is no market anywhere in this field, and nothing here is exchanged for anything. The rate is a property of a system of inequalities, in the same sense that a slope is a property of a curve, and the temptation to reach for currency should be resisted the whole way down — a program with the coefficients doubled has all its rates halved, which is a fact about arithmetic and about nothing else.

The consequence worth having is that the dual turns a solution into a list of rates: one number per constraint, saying what each one is doing to the answer. Two things happen to that list which are more interesting than the list itself. It is piecewise constant, so a rate is only a rate over an interval. And most of its entries are usually zero.

The program, and the stupidest possible solver

Everything below is decided on one program in two variables:

max 3x1+4x2subject to3x1+2x212,  x1+4x210,  x1,x20.\max\ 3x_1 + 4x_2 \quad\text{subject to}\quad 3x_1 + 2x_2 \le 12,\ \ x_1 + 4x_2 \le 10,\ \ x_1, x_2 \ge 0.

The vertex that maximises 3x₁ + 4x₂A two-variable linear program's feasible region, drawn from the exact intersection of every pair of its constraints, with the objective's contour lines and the optimal vertex marked.01234501234x₁x₂3x₁ + 4x₂ = 53x₁ + 4x₂ = 103x₁ + 4x₂ = 78/578/512100(14/5, 9/5)1: 3x₁ + 2x₂ ≤ 122: x₁ + 4x₂ ≤ 103: x₁ ≥ 04: x₂ ≥ 0rowsthey meet atfeasible?1 , 2(14/5, 9/5)yes · best1 , 3(0, 6)no1 , 4(4, 0)yes2 , 3(0, 5/2)yes2 , 4(10, 0)no3 , 4(0, 0)yes6 pairs of the 4 constraints were formed and 0 of them are parallel; 4 of the intersections satisfy every constraint exactly, and those are the4 verticesthe largest value of 3x₁ + 4x₂ over those 4 vertices is 78/5, at (14/5, 9/5) — and none of the 130 feasible points of a quarter-unit latticebeats it
Fig. 2 The feasible region as what survived. Every pair of the four constraints — the two inequalities and the two non-negativity conditions — was intersected in exact rational arithmetic, and the table records the verdict on each: 6 pairs formed, 4 of the intersections satisfying every constraint, and those 4 points are the region’s vertices. The best of them is (14/5, 9/5), worth 78/5, and no point of a quarter-unit lattice over the whole box beats it.

The solver is deliberately unimpressive. It forms every pair of constraints, solves each pair as a two-by-two system by Cramer’s rule, and throws away the points that violate something — which is how a corner of a cube gets found when the only tool available is checking all of them. Nobody would use it on a program of any size, and that is the point: no part of any picture here is about a clever procedure. How much work an optimiser does, and how that grows, is a question about cost, and cost belongs to another site in this fleet; this one owns duality as an equality and stops there.

The exactness is not fastidiousness either. A vertex is where two constraints hold with equality, and the question asked of it is whether it satisfies the others — several of which it lies exactly on. 3×14/5+2×9/5=123 \times 14/5 + 2 \times 9/5 = 12 is a true statement; the same sum in floating point is a lucky one, and a count of feasible vertices that depends on which of those the machine computed is a rounding wearing a decision’s clothes. Every comparison in this family is on rationals.

Where the second number comes from

The dual of that program is min 12y1+10y2\min\ 12y_1 + 10y_2 subject to 3y1+y233y_1 + y_2 \ge 3 and 2y1+4y242y_1 + 4y_2 \ge 4, with y0y \ge 0: the same coefficients read down the columns instead of along the rows, which is the transpose doing what a matrix does to a grid seen from the other side.

Two polytopes, two optima, one numberThe feasible regions of a linear program and of its dual, side by side, each with its optimal vertex, and a number line on which the gap between the two optima closes to nothing.primal: max 3x₁ + 4x₂dual: min 12y₁ + 10y₂3x₁ + 2x₂ ≤ 12x₁ + 4x₂ ≤ 103y₁ + y₂ ≥ 32y₁ + 4y₂ ≥ 401234501234x₁x₂78/512100(14/5, 9/5)00.511.522.5301234y₁y₂78/53024(4/5, 3/5)05101520253078/51210078/53024they meet at 78/5primal vertex values, from belowdual vertex values, from aboveweak duality checked on all 12 pairs — each of the 4 feasible primal vertices against each of the 3 feasible dual vertices — andcᵀx ≤ bᵀy held every timestrong duality is the equality of the two optima: max 3x₁ + 4x₂ = 78/5 = min 12y₁ + 10y₂, one number reached from below andfrom abovethe dual region is unbounded upward and the drawing cuts it at the box; the enumeration ignores the cut
Fig. 3 Both regions and both enumerations. Weak duality was checked on all 12 pairs — each of the 4 feasible primal vertices against each of the 3 feasible dual vertices — and the primal value was never above the dual value. The two optima are the same rational, 78/5, reached from below and from above.

The dual optimum is (4/5,3/5)(4/5, 3/5) and 12×4/5+10×3/5=78/512 \times 4/5 + 10 \times 3/5 = 78/5, which is what the primal is worth. The rung below stopped there, and it is worth noticing how little that settles about the two coordinates 4/54/5 and 3/53/5 individually. They are a certificate: a pair of non-negative multipliers that reproduce the objective out of the constraint rows and so bound the maximum from above. Nothing in that description says they mean anything.

Checked at every sample, not quoted

The hero figure is the claim that they do. One right-hand side is swept over a range of whole numbers, the whole program is re-solved from scratch at each of them, and the optimum is drawn as the function of b1b_1 that it is. Then, on each interval of the sweep, two numbers are computed by routes that share nothing:

  • the slope, from the difference of the two optima at the interval’s ends;
  • the dual variable y1y_1, from the certificate at the optimal vertex of the program solved at the interval’s midpoint.

They are asserted equal as exact rationals. Over the default sweep that is thirty intervals, and 322+1=3132 - 2 + 1 = 31 whole values with a midpoint solve between each consecutive pair, so 31+30=6131 + 30 = 61 programs are solved to draw one graph. That is a fact about this sweep and not a bound on anything.

The result is three pieces with slopes 22, 4/54/5 and 00. The middle piece is where the default program sits, and its algebra is short enough to see: with both inequalities binding, 3x1+2x2=b13x_1 + 2x_2 = b_1 and x1+4x2=10x_1 + 4x_2 = 10 give an optimum worth 4b1/5+64b_1/5 + 6, so at b1=12b_1 = 12 the value is 4×12/5+6=78/54 \times 12/5 + 6 = 78/5 and the slope is 4/54/5. The dual variable was 4/54/5. Two derivations that never met agree.

That is the sense in which a dual variable is a derivative — of the optimum with respect to a right-hand side, one-sided at the joints, and constant in between.

Two constraints, two lists

Sweeping the other constraint asks a different question of the same program, and the answer is a different rate.

What one more unit of constraint 2 is worthThe optimum of a linear program plotted against one of its right-hand sides, as an exact piecewise linear graph, with the breakpoints marked and each piece's slope named as a dual variable.510152025300510152025b₂max 3x₁ + 4x₂b₂ = 4b₂ = 24slope 3 = y₂slope 3/5 = y₂slope 0 = y₂one row per linear piecethe optimum sits onslope of the optimumdual variable y₂b₂ from 2 to 4b₂ from 4 to 24b₂ from 24 to 32row 2 and x₂ = 0(5/2, 0)33row 1 and row 2(39/10, 3/20)3/53/5row 1 and x₁ = 0(0, 6)00the optimum is piecewise linear in b₂ with 3 pieces, breaking at b₂ = 4 and 24on each piece the slope, taken from the optima at the two ends, equals the dual variable y₂ at the middleof that piece — 3, then 3/5, then 0 — and it changes exactly where a different vertex becomes optimal
Fig. 4 The same program, swept on its second constraint instead. Again three pieces, breaking at b₂ = 4 and b₂ = 24, with slopes 3, 3/5 and 0 — and again every slope was asserted equal to the dual variable y₂ at the midpoint of its piece. The optimum sits on a different pair of constraints on each piece, named in the table below the graph.

At b2=10b_2 = 10, the program’s own value, the second piece is in force and the rate is 3/53/5: this is the 3/53/5 of the dual optimum (4/5,3/5)(4/5, 3/5), arrived at from the other direction. The two rates are not comparable as measures of importance. Each is a quantity of objective per unit of its own right-hand side, and the two right-hand sides are numbers in different inequalities; a larger rate does not mean a more important constraint any more than one gradient being steeper makes one axis more important than another.

What is comparable is the shape. Both sweeps break twice, both end flat, and both begin steep. That is not an accident of the coefficients. The optimum as a function of one right-hand side is concave and piecewise linear for every linear program, because relaxing a constraint can only help and each successive unit can only help by less once other constraints begin to bind — convexity arriving as a property of the answer rather than of any drawn shape.

A rate is only a rate over an interval

The breakpoints are the whole of the caution. Below b1=5b_1 = 5 the first constraint is worth 22 per unit; above b1=30b_1 = 30 it is worth nothing at all, because by then the second constraint has taken over entirely and further relaxation of the first buys nothing. Anyone quoting “the value of constraint one” as a single number has quoted a value that is correct on one interval and wrong on two.

What one more unit of constraint 1 is worthThe optimum of a linear program plotted against one of its right-hand sides, as an exact piecewise linear graph, with the breakpoints marked and each piece's slope named as a dual variable.23456789101112051015b₁max 3x₁ + 4x₂b₁ = 5slope 2 = y₁slope 4/5 = y₁one row per linear piecethe optimum sits onslope of the optimumdual variable y₁b₁ from 2 to 5b₁ from 5 to 12row 1 and x₁ = 0(0, 5/4)22row 1 and row 2(1/5, 49/20)4/54/5the optimum is piecewise linear in b₁ with 2 pieces, breaking at b₁ = 5on each piece the slope, taken from the optima at the two ends, equals the dual variable y₁ at the middleof that piece — 2, then 4/5 — and it changes exactly where a different vertex becomes optimal
Fig. 5 The same sweep over a shorter window, from 2 to 12. Two pieces, one breakpoint at b₁ = 5, slopes 2 and 4/5 — every number here agrees with the wider sweep, and the second breakpoint simply is not in the window.

That is worth staring at, because both figures are correct and one of them cannot see something. The window decides which breakpoints appear; nothing in the narrow figure hints that the rate 4/54/5 eventually stops. A rate read off a graph is a statement about the interval it was read on and about nothing outside it.

The joints themselves have no rate. At b1=5b_1 = 5 the slope arriving is 22 and the slope leaving is 4/54/5, so the optimum has no derivative there in the ordinary sense — the function is continuous, kinked, and perfectly well behaved, but the question “what is the constraint worth at b1=5b_1 = 5” has two answers. The right-hand-side axis is cut into intervals by which pair of constraints wins, in the same way the plane is cut into regions by which point is nearest, and the boundary belongs to both sides.

Every product is zero

The second consequence is sharper and it is about which constraints matter at all.

Complementary slackness, product by productA table of a linear program's constraints and variables at the optimum, each with its slack, its dual variable and the product of the two, which is zero in every row.max 3x₁ + x₂ at (4, 0), worth 12the dual optimum is (1, 0), worth 121 pair of the 2 constraints binding there was tried, and 1 certified the optimumone row per constraintslack sᵢdual yᵢsᵢ × yᵢverdict3x₁ + 2x₂ ≤ 12x₁ + 4x₂ ≤ 10010binding600worth nothingone row per variablevalue xⱼreduced rⱼxⱼ × rⱼverdictx₁x₂400in use010held at 0exactly zerothe productpositiveall 4 products are exactly zero — 1 of the 2 constraints binds and so may carry a price, 1 is worth nothing, and 1 ofthe 2 variables is usedthe optimum is (4, 0) and both sides are worth 12; a zero on the left of a row and a zero on the right of it are differentfacts, and every row has one
Fig. 6 Complementary slackness for max 3x₁ + x₂ on the same region. One row per constraint with its slack and its dual variable, one row per variable with its value and its reduced cost, and the product in the third column. All 4 products are exactly zero. The optimum is (4, 0), the dual optimum is (1, 0), and both are worth 12.

The objective here is tilted to 3x1+x23x_1 + x_2, and that is deliberate. Run the same table on the untilted program and it is a true instance that illustrates nothing: at (14/5,9/5)(14/5, 9/5) both constraints bind with zero slack, both dual variables are positive — 4/54/5 and 3/53/5 — and both variables are in use with zero reduced cost, so all four products are zero for the same reason and there is no second reason on display. Tilted, the optimum moves to (4,0)(4, 0) and the four rows divide two and two.

Read the table row by row. The first constraint binds — 3×4+2×0=123 \times 4 + 2 \times 0 = 12, no room to spare — and carries a dual variable of 11. The second has slack 66, since 4+6=104 + 6 = 10, and its dual variable is exactly 00. The variable x1x_1 is 44 and its reduced cost is 00; the variable x2x_2 is held at 00 and its reduced cost is 11. Every row multiplies to zero, and the two zeroes are not the same zero:

  • a constraint with room to spare has a dual variable of zero, because relaxing something that is not pressing changes nothing;
  • a variable sitting at zero has a strictly positive reduced cost, because it is sitting at zero for a reason.

That is complementary slackness, and it is an exact statement with no inequality left in it: for every ii, either the slack is zero or the dual variable is, and never neither.

What one more unit of constraint 2 is worthThe optimum of a linear program plotted against one of its right-hand sides, as an exact piecewise linear graph, with the breakpoints marked and each piece's slope named as a dual variable.0246810121416182002468101214b₂max 3x₁ + x₂b₂ = 4slope 3 = y₂slope 0 = y₂one row per linear piecethe optimum sits onslope of the optimumdual variable y₂b₂ from 0 to 4b₂ from 4 to 20row 2 and x₂ = 0(1/2, 0)33row 1 and x₂ = 0(4, 0)00the optimum is piecewise linear in b₂ with 2 pieces, breaking at b₂ = 4on each piece the slope, taken from the optima at the two ends, equals the dual variable y₂ at the middleof that piece — 3, then 0 — and it changes exactly where a different vertex becomes optimal
Fig. 7 The same tilted program, swept on the constraint the table says is worth nothing. Two pieces, breaking at b₂ = 4; past the break the slope is 0, and the program’s own b₂ = 10 sits well inside that flat stretch. A dual variable of zero and a flat graph are one fact seen twice.

The two figures are the same sentence in two grammars, and that is the counting-two-ways of this essay. The table says the second constraint’s dual variable is 00; the sweep says the optimum does not move when the second constraint is relaxed. Neither was computed from the other.

The constraints that could be deleted

Complementary slackness is therefore a statement about which constraints are doing work, and it is unusually blunt. A constraint with a dual variable of zero can be deleted from the program without moving the optimum. So can the whole crowd of them.

Complementary slackness, product by productA table of a linear program's constraints and variables at the optimum, each with its slack, its dual variable and the product of the two, which is zero in every row.max 3x₁ + x₂ at (4, 0), worth 12the dual optimum is (1, 0, 0), worth 121 pair of the 2 constraints binding there was tried, and 1 certified the optimumone row per constraintslack sᵢdual yᵢsᵢ × yᵢverdict3x₁ + 2x₂ ≤ 12x₁ + 4x₂ ≤ 10x₁ + x₂ ≤ 6010binding600worth nothing200worth nothingone row per variablevalue xⱼreduced rⱼxⱼ × rⱼverdictx₁x₂400in use010held at 0exactly zerothe productpositiveall 5 products are exactly zero — 1 of the 3 constraints binds and so may carry a price, 2 are worth nothing, and 1 ofthe 2 variables is usedthe optimum is (4, 0) and both sides are worth 12; a zero on the left of a row and a zero on the right of it are differentfacts, and every row has one
Fig. 8 A third constraint added to the same tilted program. All 5 products are zero, 1 of the 3 constraints binds and so may carry a price, and 2 are worth nothing — their slacks are 6 and 2 and their dual variables are both exactly 0. The optimum, (4, 0) worth 12, is the one the two-constraint program already had.

The optimum did not move, and the table says in advance that it could not have. Two constraints out of three are invisible to the answer: the optimum is determined by one inequality and one non-negativity condition, and everything else in the program is scenery. In two variables at most two constraints can be doing the work at any one vertex, however many are written down, and the dual is the object that says which two.

That is the same move as the invention of throwing things away — the observation that a question has a small skeleton and that the rest of the description can be discarded without changing the answer, provided the discarding is justified rather than guessed. Here the justification is a table of products, checked entry by entry, and it is available before anything is deleted.

What the family refuses to draw

Two cases are refused by name rather than drawn badly, and both refusals say something.

The first is a degenerate optimum: three or more constraints passing through the same point. Add 4x1+x2134x_1 + x_2 \le 13 to the original program and it passes exactly through (14/5,9/5)(14/5, 9/5), where the two original constraints already meet. The optimum does not move, but the dual optimum stops being a single point — the certificates (4/5,3/5,0)(4/5, 3/5, 0) and (0,13/15,8/15)(0, 13/15, 8/15) both reproduce the objective, both are non-negative, and both are worth the same, since 10×13/15+13×8/15=78/510 \times 13/15 + 13 \times 8/15 = 78/5. There is then no such thing as the dual variable of a constraint, and no honest single-valued table of products. The generator tries every pair of binding rows, finds two certificates that disagree, and refuses. Drawing the case is not possible, because what would have to be drawn is a whole set of prices where the picture has one column.

The second refusal is finer. The sweep visits whole numbers, and a breakpoint need not be at a whole number. Sweeping the third constraint of the three-constraint program above meets one at b3=5/2b_3 = 5/2, where the second constraint begins to bind, and the generator stops rather than drawing a straight segment across it. It can tell, because the optimum is solved at each interval’s midpoint too, and a concave function with a kink inside an interval is strictly above the average of its endpoints there. A hidden breakpoint is the only way this drawing could lie, and it is exactly the thing the extra solve is for.

What the picture cannot show

The theorem is a statement about every linear program with a bounded optimum. The figures are one program, or three, and what they establish is finite: on this program, at these sampled right-hand sides, the slope of the optimum equalled the dual variable computed independently, every time, and every complementary product was exactly zero. That is a genuine exhaustion of a small claim, not a small sample of a large one — but it is a small claim.

A finer sweep would add something real and something else not at all. It would add resolution about where the breakpoints are: a sweep in half-units would locate b3=5/2b_3 = 5/2 rather than refusing, and a sweep in tenths would place a breakpoint at any tenth. It would not make the equality of slope and dual variable any more general, because that equality is being checked at points, and no number of points is a proof over a continuum. Nor would it reach the theorem’s actual content, which is a claim about programs in any number of variables — where a region has no drawing at all and the argument is a separating hyperplane with no picture in it.

What the drawing does settle is the part most often taken on trust: that the sentence “the dual variable is the rate of change” is a checkable identity between two computed rationals and not a gloss. It has been checked, on every interval of every sweep here, and it has never once been off.

Where the ladder goes next

Two rungs of this anchor have now produced a number that both sides reach, and a reading of the dual’s coordinates as rates that vanish on everything not doing work. The table has only so many shapes a row can take — a constraint with slack and no rate, or a constraint with a rate and no slack; a variable in use with nothing to spare, or a variable held down with something to spare — and a rigid little list of possibilities like that, exhausted rather than sampled, is the same pleasure as three gap lengths and never a fourth.

The next rung takes the same equality into a setting where the two sides are not a program and its transpose but two cautious parties choosing against each other, and the number they meet at acquires a second name. Nothing new is proved there. What changes is what the two numbers are called, and that is exactly the kind of re-labelling that counting one object twice has been doing to this collection from the beginning.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Complementary slacknessConvexityDerivativeDualityFeasible regionLinear programShadow price