# I don't understand how I can solve the dual of a linear programming model knowing the solution to the primal.

If we know the optimal solution for a primal model how can I find the optimal solution for the dual of that primal model?

I heard about complementary slackness which to my understanding is that the slack variables from the primal model can be used in the dual. The example I've seen is when the slack variables are 0. What would happen if we have slack variables that are non-zero?

To give a primal model as an example: $$\max Z = 0.56x_1 + 0.46x_2$$ the constraints are

\begin{align} x_1 &\leq 110000 \\ x_1 + 2x_2 &\leq 240000 \\ 3/2x_1 + x_2 &\leq 180000 \end{align}

The optimal solution for this model is $$x_1 = 60000$$ and $$x_2 = 90000$$.

Now here is the dual model of this primal: $$\min Z = 110000y_1 + 240000y_2 + 180000y_3$$

The constraints are :

\begin{align} y_1 + y_2 + 1.5y_3 &\geq 0.56 \\ 2y_2 + y_3 &\geq 0.46 \end{align}

Assume constraints of non-negativity for both models.

Now I calculated the slack variables of the primal model.

\begin{align} x_{s1} &= 50000 \\ x_{s2} &= 0 \\ x_{s3} &= 0 \end{align}

The problem is I don't know what to do with them to get the solution of the dual model.

• Your $x_1$ and $x_2$ are off by a factor of $10$, and your dual constraints are the wrong sense. Sep 28, 2020 at 17:22
• Oups sorry! I corrected everything. Sep 28, 2020 at 17:27

By complementary slackness:

• $$x_1 < 110000$$ (equivalently, $$x_{s1}>0$$) implies $$y_1=0$$
• $$x_1 > 0$$ implies that the first dual constraint is satisfied with equality
• $$x_2 > 0$$ implies that the second dual constraint is satisfied with equality

Now solve these two equations for $$y_2$$ and $$y_3$$.

Note: the second and third bullets use the fact that the primal variables are the dual variables of the dual constraints.

• I don't understand the implication that result in $y_1 = 0$ could you explain it like I'm 5? Sep 28, 2020 at 17:30
• Complementary slackness says that either the slack or the dual is $0$. You know that the slack is not $0$, so... Sep 28, 2020 at 17:34
• Ok but how does the slack variables in the primal model affect the solution in the dual model. That's what I'm trying to understand. So, because $x_s1 > 0$ this implies that $y_1 = 0$? What happens with $y_2$ and $y_3$? Ah! We just need to solve the equations in the dual model knowing that $y_1 = 0$. This will give us the values of $y_2$ and $y_3$ am I right? Sep 28, 2020 at 17:38
• Yes, and as a sanity check, the resulting dual objective value should match the primal objective value. Sep 28, 2020 at 17:40
• It's really strange. I get that that Z = 71400 instead of 75000 and I don't know what went wrong? I found that $y_2 = 0.035$ and $y_3 = 0.35$. Do you know why it's not matching? Sep 28, 2020 at 18:43