Every LP has a twin problem called its dual. The two are closely linked, and solving one gives the solution of the other.

Primal and Dual

The original problem is the primal. For a primal of the form: maximise Z = c1x1 + … + cnxn subject to Σ a(ij)x(j) ≤ b(i) for i = 1 to m, x ≥ 0, the dual is: minimise W = b1y1 + … + bmym subject to Σ a(ij)y(i) ≥ c(j) for j = 1 to n, y ≥ 0. The rules are: a maximisation becomes a minimisation; the right-hand side constants become the objective coefficients, and the objective coefficients become the right-hand sides; the matrix of coefficients is transposed; ≤ constraints become ≥; each primal constraint gives a dual variable, and each primal variable gives a dual constraint. The dual of the dual is the primal.

Definition: Dual problem. The linear programming problem associated with a given (primal) problem, formed by exchanging the roles of the objective coefficients and the right-hand-side constants and transposing the constraint matrix.

Duality Theorems

The weak duality theorem states that for any feasible x of the primal (max) and any feasible y of the dual (min), Z ≤ W. The strong duality theorem states that if one problem has an optimal solution, so does the other, and the optimal values are equal: Z = W. If one is unbounded, the other is infeasible. The complementary slackness conditions state that if a primal constraint is slack at the optimum, the matching dual variable is zero, and if a dual variable is positive, the matching primal constraint is tight.

Meaning of the Dual Variables

The dual variables are called shadow prices. y(i) is the increase in the optimal profit if one more unit of resource i were available. It tells a manager how much an extra unit of each resource is worth, and the most that should be paid for it. The optimal dual values can be read from the Cj − Zj row of the final simplex table, under the slack columns.

Table 4.4: Primal and dual

Primal (max) Dual (min) Link
Objective coefficients c Right-hand sides Swap
Right-hand sides b Objective coefficients Swap
Matrix A Matrix Aᵀ Transpose
≤ constraints ≥ constraints Reverse

Example 4.4: Writing and solving the dual

Problem: Write the dual of: maximise Z = 50x1 + 60x2 subject to 2x1 + 3x2 ≤ 120, 4x1 + 2x2 ≤ 160, x ≥ 0. Find its optimum.

Solution:

  1. Dual: minimise W = 120y1 + 160y2 subject to 2y1 + 4y2 ≥ 50, 3y1 + 2y2 ≥ 60, y1, y2 ≥ 0.
  2. Both primal constraints are tight at the optimum (30, 20), and both x's are positive, so both dual constraints are tight.
  3. Solve 2y1 + 4y2 = 50 and 3y1 + 2y2 = 60: y1 = 17.5, y2 = 3.75.
  4. W = 120(17.5) + 160(3.75) = 2100 + 600 = 2700.

Result: The dual optimum is W = 2700 = Z*. A unit of wood is worth Rs 17.50 and an hour of labour Rs 3.75.

y1, y2 = 17.5, 3.75
print(2 * y1 + 4 * y2, 3 * y1 + 2 * y2, 120 * y1 + 160 * y2)

Output

50.0 60.0 2700.0

Common mistakes

  • Forgetting to transpose the coefficient matrix.
  • Keeping ≤ in the dual of a maximisation problem with ≤ constraints. They become ≥.
  • Mixing up which dual variable belongs to which constraint.

Key takeaways

  • Max becomes min, b and c swap, A is transposed, ≤ becomes ≥.
  • Weak duality: Z ≤ W. Strong duality: Z = W.
  • Dual variables are shadow prices of the resources.
  • The dual of the dual is the primal.

Practice questions

  1. State the strong duality theorem.
  2. What is a shadow price?
  3. How many dual variables are there?

Answers to the practice questions

  1. If either the primal or the dual has an optimal solution, so does the other, and their optimal values are equal.
  2. The increase in the optimal objective value from one more unit of a resource.
  3. One for each primal constraint.

Sources

  • Official BCA syllabus Mathematics Foundations to Computer Science II, course code 25BCA402DS01, Unit IV