How to Convert a Primal Linear Program to Its Dual
At a glance
- 1. Record the primal
Identify the objective, coefficient matrix, right-hand side, constraint senses, and variable bounds.
- 2. Reverse the objective
A primal maximization becomes a dual minimization, and a primal minimization becomes a dual maximization.
- 3. Transpose the matrix
Use the primal right-hand side as dual objective coefficients; each primal variable gives one dual constraint.
- 4. Apply sign rules
Primal row senses determine dual-variable signs; primal variable bounds determine dual constraint senses.
Converting a primal linear program to its dual is mostly a matter of organizing the coefficients and applying sign rules. The most common case has a maximization objective, upper-bound constraints, and nonnegative variables; mixed inequalities and unrestricted variables use the same principles with adjusted signs.
The standard primal–dual pair
Write the primal in the standard maximization form
Here, each row of is one constraint, and each column corresponds to one variable. Its dual is
The dimensions switch: if the primal has constraints and variables, the dual has variables and constraints. The entries of become the dual objective coefficients, the entries of become the right-hand sides of the dual constraints, and the constraint matrix becomes .
A reliable conversion procedure
For a primal maximization problem:
- Make one dual variable for each primal constraint.
- Make one dual constraint for each primal variable.
- Set the dual objective coefficients equal to the primal right-hand side.
- Transpose the primal coefficient matrix. The right-hand side of each dual constraint is the coefficient of the corresponding primal variable in the objective.
- Determine signs and inequality directions from the rules below.
The objective direction reverses: a primal maximum gives a dual minimum. For a primal minimum, the dual is a maximum.
Sign rules for mixed forms
The table gives the rules for a maximization primal. A row constraint means one constraint in the primal; its dual variable appears in the dual objective. A primal variable bound determines the inequality in the corresponding dual constraint.
| Maximization-primal feature | Corresponding dual feature |
|---|---|
| Constraint | Dual variable |
| Constraint | Dual variable |
| Constraint | Dual variable unrestricted in sign |
| Variable | Dual constraint is |
| Variable | Dual constraint is |
| Variable unrestricted in sign | Dual constraint is an equality |
For a minimization primal, reverse these signs and inequality directions: a primal row gives a nonpositive dual variable, and a nonnegative primal variable gives a dual constraint. Equality rows still give unrestricted dual variables, and unrestricted primal variables still give equality constraints.
These rules assume the objective and constraints are written consistently as a maximization or minimization problem. You can also multiply a constraint by to reverse its inequality, but you must change the signs of every coefficient in that row, including its right-hand side.
Worked example
Consider the primal problem
There are two primal constraints, so introduce dual variables and . The primal is a maximization with rows, so . The dual objective uses the primal right-hand sides, 4 and 5:
There are two primal variables, so the dual has two constraints. Read each dual constraint from the corresponding column of the primal matrix:
- The column has coefficients 1 and 2, and its objective coefficient is 3. Since , its dual constraint is .
- The column has coefficients 1 and 1, and its objective coefficient is 2. Since , its dual constraint is .
Thus the dual is
Why the standard signs make sense
If satisfies and , then . If also and , then . Therefore every feasible primal objective value is at most every feasible dual objective value. This is the weak duality property, and it explains why the standard primal maximum pairs with a dual minimum.
Common mistakes
- Using instead of . Each dual constraint comes from a column of the primal matrix, not a row.
- Keeping the same objective direction. The dual reverses maximum and minimum.
- Setting every dual variable nonnegative. That is true for rows in a maximization primal, but not for or equality rows.
- Forgetting variable bounds. A free primal variable creates an equality in the dual; it does not create a one-sided inequality.
- Changing an inequality without changing its whole row. Multiplying by also changes the right-hand side and all coefficients.
References
- Introduction to Linear Optimization, Dimitris Bertsimas and John N. Tsitsiklis
- Linear Programming, Vasek Chvátal
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.