Learn
Lesson · Duality and Sensitivity Analysis · The second problem

The Dual Problem

Every linear programme carries a second one with a variable for each of its constraints and a constraint for each of its variables. The transformation is not a table to memorise: each direction and each sign restriction is forced by the single requirement that the prices, multiplied through the rows and added up, must bound the objective. Take the dual twice and the programme you started with comes back.

primal max 3x1 + 5x2 x1 ≤ 4, 2x2 ≤ 12, 3x1 + 2x2 ≤ 18, x ≥ 0 dual min 4y1 + 12y2 + 18y3 y1 + 3y3 ≥ 3, 2y2 + 2y3 ≥ 5, y ≥ 0 one price per ROW, one constraint per COLUMN, and A becomes its transpose in a max: ≤ row → y ≥ 0 ≥ row → y ≤ 0 = row → y free x ≥ 0 → dual row ≥ x free → dual row = units of y for a row = the objective's units ÷ that row's units
The workshop, its dual, and the rules that fixed every sign

Core ideas

What this lesson establishes

The transpose is the easy half and nobody gets it wrong. The three ideas here are about the half that decides the directions and the signs.

1

One price per row, one constraint per column

A programme with m constraints and n variables has a dual with n constraints and m variables, and the pairing is fixed: the i-th row creates yᵢ, the j-th column creates the j-th dual constraint. The dual's objective coefficients are the primal's right-hand sides, and its right-hand sides are the primal's objective coefficients — the two vectors swap places.

2

Every direction is forced, not chosen

Multiply each row by a number of its own and add the results. For that to be a valid bound on cᵀx, two things must hold: the multipliers must have signs that preserve the inequality when they multiply through, and the resulting combination must dominate c on every variable that can be positive. Those two requirements produce the whole table, row rules and column rules alike.

3

The units are the check that costs ten seconds

A dual variable's units are the objective's units divided by its row's units: pounds per hour for an hours row, pounds per kilogram for a kilograms row. A price whose units you cannot state out loud is a price you have paired with the wrong constraint, and that is the commonest construction error there is.

The material

Building the second programme out of the requirement that it bound the first

One derivation, then the four row rules and the three column rules it produces, then the cases that are not the textbook case.

Definition · The dual problem

Given a maximisation max cᵀx subject to Ax ≤ b and x ≥ 0, its dual is the minimisation min bᵀy subject to Aᵀy ≥ c and y ≥ 0. The original programme is called the primal. There is one dual variable for each primal constraint and one dual constraint for each primal variable.

The dual variables are called prices throughout this course, because that is what their units make them: a quantity of objective per unit of right-hand side.

That definition is the clean case, and reading it as a recipe is how the mixed-form cases go wrong. So here is where it comes from, on the workshop programme above: three resources, two products, and the question of how large 3x1 + 5x2 could possibly be.

choose y1, y2, y3 ≥ 0 and multiply each row by its own price: y1 ( x1 ) ≤ 4y1 y2 ( 2x2 ) ≤ 12y2 y3 ( 3x1 + 2x2 ) ≤ 18y3 ----------------------------------------------------- (y1 + 3y3) x1 + (2y2 + 2y3) x2 ≤ 4y1 + 12y2 + 18y3 the left side is at least 3x1 + 5x2 for every x ≥ 0 exactly when y1 + 3y3 ≥ 3 2y2 + 2y3 ≥ 5 and then, for every feasible x, 3x1 + 5x2 ≤ 4y1 + 12y2 + 18y3 so the best bound this construction can give is min 4y1 + 12y2 + 18y3 subject to those two rows, y ≥ 0

Every line of that is forced. y ≥ 0 is needed at the first step, because a negative multiplier would turn each ≤ into a ≥ and the sum would bound nothing. x ≥ 0 is needed at the second step, because (y1 + 3y3)x1 ≥ 3x1 requires x1 not to be negative. And the dual is a minimisation because a bound is only worth having as small as it can be made. The dual is not the transpose of the primal; it is the cheapest certificate the primal admits, and the transpose is what that turns out to look like.

Theorem · The transformation rules

Let the primal be a maximisation. Then each row contributes a price whose sign its direction fixes: a ≤ row gives y ≥ 0, a ≥ row gives y ≤ 0, and an = row gives a y with no sign restriction at all. Each column contributes a dual constraint whose direction its variable's sign fixes: x ≥ 0 gives a ≥ row, x free gives an = row, and x ≤ 0 gives a ≤ row.

If the primal is a minimisation every one of those turns over: now ≥ rows give y ≥ 0, ≤ rows give y ≤ 0, x ≥ 0 gives a ≤ dual row, and the dual is a maximisation.

Each rule is the derivation above run on that shape. A ≥ row in a maximisation is a floor; relaxing a floor cannot improve a maximum, so its price cannot be positive. An = row binds in both directions, so nothing restricts the sign of its price. A free variable can be made negative, so the domination step must hold as an equality rather than as an inequality.

Example · The workshop and its dual, side by side

The primal reads max 3x1 + 5x2 subject to x1 ≤ 4 (cutting), 2x2 ≤ 12 (glazing), 3x1 + 2x2 ≤ 18 (assembly), x ≥ 0. Its dual reads min 4y1 + 12y2 + 18y3 subject to y1 + 3y3 ≥ 3 (the x1 column), 2y2 + 2y3 ≥ 5 (the x2 column), y ≥ 0.

Read the first dual row aloud: the cutting and assembly capacity that one unit of x1 consumes must be worth at least the 3 that unit earns. That sentence is the dual constraint, and it is why the direction is ≥ rather than ≤.

The three cases that are not the textbook case

A programme with only ≤ rows and only non-negative variables is the one every textbook prints, and it is the one that teaches least, because in it the rules are invisible. The lab ships a preset with a cap, a floor, a quota and a variable free to go negative precisely so that all three of the awkward rules have to be applied at once.

Example · A cap, a floor, a quota and a free variable

max 4u + 3v subject to 2u + v ≤ 10 (capacity), u − v ≥ 1 (balance), u + v = 4 (quota), u ≥ 0 and v free. The dual is min 10y1 + y2 + 4y3 subject to 2y1 + y2 + y3 ≥ 4 (the u column) and y1 − y2 + y3 = 3 (the v column), with y1 ≥ 0, y2 ≤ 0 and y3 free.

Three separate rules did that. The ≥ row turned y2 non-positive, the = row left y3 unrestricted, and the free v turned its dual row into an equality. The lab prints the sentence that fixed each one on the link joining the pair, and the programme solves to z* = 18 at u = 6, v = −2 — a negative variable at the optimum, which is what declaring it free was for.

Take the dual of that dual and the original programme comes back, sign for sign and direction for direction. That is not a special case of the tidy shape: it is a property of the four rules, and it holds on the minimisation, on the floor, on the quota and on the free variable alike. The lab's last control runs the construction twice and reports whether the result agrees with what it started from — and on every preset it does.

Example · A minimisation, where every direction turns over

min 2x + 3y subject to x + y ≥ 4 (protein), x ≤ 3 (supply), y ≥ 1 (oats), x, y ≥ 0 has the dual max 4y1 + 3y2 + y3 subject to y1 + y2 ≤ 2 (the x column) and y1 + y3 ≤ 3 (the y column), with y1 ≥ 0, y2 ≤ 0, y3 ≥ 0.

Everything has flipped and nothing has been memorised. In a minimisation the requirement to be met is the ≥ row, so that is the row with a non-negative price; the ≤ row is now the cap whose relaxation cannot help, so its price is non-positive; and the dual constraints say that what a unit is worth must not exceed what it costs.

Interactive

One price per row, one constraint per variable

the dual built pairing by pairing, and the dual of the dual returning the primal

Writing the dualone price per row, one constraint per variable, and the rule that fixed each direction
a row, and the price it createsa variable, and the constraint it createsa sign with no restriction on it

Method

Writing the dual of something you have been handed

Count first, then transpose, then apply one rule per row and one per column. The units are the last step and they catch the pairing errors.

1

Count the rows and the columns before writing anything

m rows means m dual variables; n variables means n dual constraints. If your dual has a different count in either direction you have paired a price with a variable, which is the error the count catches for free.

2

Swap the objective and the right-hand sides, and turn the objective over

The primal's b becomes the dual's objective coefficients and the primal's c becomes the dual's right-hand sides. A maximisation becomes a minimisation and the other way round.

3

Give each row its price, with the sign its direction forces

In a maximisation: ≤ gives y ≥ 0, ≥ gives y ≤ 0, = gives y free. Reach for the reason rather than the table — a floor you would like to relax cannot be worth a positive amount — because the reason survives a minimisation and the table does not.

4

Give each column its constraint, with the direction its variable forces

The j-th dual row has the j-th column of A as its coefficients and cⱼ as its right-hand side. A non-negative variable gives ≥ in a maximisation's dual; a free variable gives =.

5

Put units on every price, and then take the dual again

State each price's units aloud: objective units per unit of that row. Then run the construction on what you have written. If it does not return the programme you started from, the error is in the sign or direction of whichever row or column has changed.

Rows, columns, directions and signs

Score 0 / 0

The dual of the workshop, derived rather than looked up

Nothing below is taken from a table. The two dual constraints appear as the conditions under which the combination of rows is a bound at all, and the objective appears as the wish to make that bound small.

primal max 3x1 + 5x2 cutting x1 ≤ 4 glazing 2x2 ≤ 12 assembly 3x1 + 2x2 ≤ 18 x1, x2 ≥ 0 count 3 rows → 3 prices y1, y2, y3 2 columns → 2 dual constraints combine y1(x1) + y2(2x2) + y3(3x1 + 2x2) ≤ 4y1 + 12y2 + 18y3 needs y ≥ 0 collect x1 coefficient: y1 + 3y3 x2 coefficient: 2y2 + 2y3 dominate y1 + 3y3 ≥ 3 needs x1 ≥ 0 2y2 + 2y3 ≥ 5 needs x2 ≥ 0 dual min 4y1 + 12y2 + 18y3 y1 + 3y3 ≥ 3 the x1 column 2y2 + 2y3 ≥ 5 the x2 column y1, y2, y3 ≥ 0 units profit is in pounds; cutting is in hours y1 is pounds per hour of cutting check take the dual of that dual: 3 dual columns → 3 variables 2 dual rows → 2 prices max 3x1 + 5x2 subject to the three original rows ✓

The two needs annotations are the whole content of the sign rules. Drop y ≥ 0 and the first line stops being an inequality in the right direction; drop x ≥ 0 and the domination step stops being valid. Everything else is bookkeeping.

For a faded rehearsal, do the same on the bakery: max 5x + 4y subject to 6x + 4y ≤ 24, x + 2y ≤ 6, x + y ≥ 2, x, y ≥ 0. The supplied first move is that the third row, being a floor in a maximisation, gets the price the derivation cannot allow to be positive. Write both dual rows, state the sign of all three prices, and then check your answer against the lab's bakery preset before opening the quiz.

If you want the harder rehearsal, take the dual of the minimisation preset and then take the dual of your answer. Everything reverses twice, which is the only way to be sure you applied rules rather than recalled a shape.

Common mistakes

1
Transposing the matrix and copying everything else acrossThis is the error the lesson exists for. A becomes Aᵀ, b and c swap, and then the objective is left maximising and the rows left pointing the same way. The result is a programme that bounds nothing at all, and you find out only when its optimal value comes out below the primal's. Every direction and every sign has to be decided separately, from the requirement that the combination be a bound.
2
Pairing a price with a variable instead of a rowA programme with three rows and two variables has a dual with three variables and two rows, and getting that backwards produces a dual of the wrong size. Count before you write: the dual's variable count is the primal's row count, always. The units check catches the same error a second way, because a price paired with a variable has no sensible units.
3
Giving an equality row a non-negative priceAn = row binds from both sides, so nothing in the derivation restricts the sign of its price, and at a real optimum it often is negative. Writing y ≥ 0 there silently removes feasible dual points, and the dual you have written then has a larger minimum than the primal's maximum — a gap that looks like an arithmetic slip and is a modelling one.

Check your understanding

✓
Finish when you can write the dual of a mixed-form programme without looking at a table of rules.

You should be able to take the dual of a maximisation and of a minimisation, apply the ≥ and = row rules and the free-variable column rule from the reason rather than from recall, state the units of every price, and take the dual of your own answer to get back what you started with.

Note: A price has units, and stating them takes ten seconds. Pounds per hour of cutting, pounds per kilogram of flour: a dual variable whose units you cannot say is a dual variable you have attached to the wrong constraint. The next lesson, “Weak Duality and Certificates”, is where the bound this construction was built to produce becomes a proof about the primal that costs nothing to check.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.