Recovering a Dual Solution from a Primal Solution

Given an optimal primal solution to a linear program, use the complementary slackness conditions to set up and solve a linear system that recovers the optimal dual solution.

Step 1 of 157%

Tutorial

Recovering the Dual via Complementary Slackness

Given an optimal primal solution x,\mathbf{x}^*, we can recover the optimal dual solution y\mathbf{y}^* by solving a small linear system built from the complementary slackness conditions.

For a primal of the form

max cTxsubject toAxb, x0,\max\ \mathbf{c}^T\mathbf{x} \quad \text{subject to} \quad A\mathbf{x} \leq \mathbf{b},\ \mathbf{x} \geq \mathbf{0},

the dual is

min bTysubject toATyc, y0.\min\ \mathbf{b}^T\mathbf{y} \quad \text{subject to} \quad A^T\mathbf{y} \geq \mathbf{c},\ \mathbf{y} \geq \mathbf{0}.

Complementary slackness gives two rules:

  1. (Positive primal variable.) If xj>0,x_j^* > 0, then the jj-th dual constraint is tight: (ATy)j=cj.(A^T\mathbf{y}^*)_j = c_j.
  2. (Slack primal constraint.) If (Ax)i<bi,(A\mathbf{x}^*)_i < b_i, then yi=0.y_i^* = 0.

To recover y,\mathbf{y}^*, write one equation for each positive xjx_j^* and one equation for each slack primal constraint, and solve the linear system in y.\mathbf{y}.

For example, consider the primal

max 2x1+x2s.t.x1+x23, x12, x0,\max\ 2x_1 + x_2 \quad \text{s.t.} \quad x_1 + x_2 \leq 3,\ x_1 \leq 2,\ \mathbf{x} \geq \mathbf{0},

with optimal x=(2,1).\mathbf{x}^* = (2, 1). Both primal constraints are tight, and both variables are positive. The dual constraints (one per primal variable) are

y1+y22andy11.y_1 + y_2 \geq 2 \quad \text{and} \quad y_1 \geq 1.

Rule 1 forces both to be tight:

y1+y2=2(from x1>0)y1=1(from x2>0).\begin{align*} y_1 + y_2 &= 2 \quad (\text{from } x_1 > 0)\\ y_1 &= 1 \quad (\text{from } x_2 > 0). \end{align*}

Solving gives y=(1,1).\mathbf{y}^* = (1, 1).

navigate · Enter open · Esc close · ⌘K/Ctrl K toggle