Generator

polytope

A generator in the applied library, called 16 times across 2 essays. Below: what it draws at its defaults and at each mode an essay asks for, what it checks while drawing, and everywhere it is used.

polytope is one function. Everything below came out of it during this build, at parameters taken from the essays rather than invented for this page — so a figure here is the same figure a reader meets in an essay, and if the generator changes, this page changes with it.

At its defaults

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

show: "dual"

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

show: "primal"

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

show: "slack"

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

show: "shadow"

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

What it checks while it draws

Collected by running the family and recording what it asserted, not written here. The count is how many separate times the claim was put to the test while these drawings were made.

Where it is called

Changing this generator changes every figure on this list. That is what makes the list worth publishing rather than keeping in a check script.

The whole library · What the figures prove