1

Lets say I have this primal problem:

maximize $z = 6x_1 + 10x_2$

subject to:

$2x_1+8x_2\leq 60$

$3x_1+5x_2\leq45$

$x_1, x_2 \geq 0$

With slack variables in matrix notation ($Ax=b$) I get:

$A =\begin{pmatrix} 2 & 8 & 1 & 0\\ 3 & 5 & 0 & 1 \end{pmatrix}$

$b =\begin{pmatrix} 60\\ 45 \end{pmatrix}$

$c = \begin{pmatrix} 6\\ 10\\ 0\\ 0 \end{pmatrix}$

$x = \begin{pmatrix} 0\\ 0\\ 60\\ 45 \end{pmatrix}$

But how will this notation look like for the dual problem? The slack variables makes me a bit confussed to be honest.Because for the primal, let us for example add slack variables ($x_3$) to the first constraint:

$2x_1+8x_2 + x_3 = 60$

The first constraint of the dual will however be:

$2y_1+3y_2\geq 6$

If I add a slack variable $y_3$

$2y_1+3y_2 + y_3= 6$

Then the slack variable must be less or equal to zero. A for the dual problem can well not be:

$A =\begin{pmatrix} 2 & 3 & 1 & 0\\ 8 & 5 & 0 & 1 \end{pmatrix}$ ?

1 Answers1

1

When you add slack variables, the dual program isn't affected.

In the original primal program, there are two variables $x_1, x_2$, corresponding to two constraints in the dual; there are two constraints, corresponding to two dual variables which we'll call $u_1$ and $u_2$. Because the constraints are inequalities, $u_1$ and $u_2$ will be nonnegative variables. Here is the primal-dual pair: \begin{array}{rrll rrll} \text{maximize } & 6x_1 + 10x_2 & & & \text{minimize} & 60u_1 + 45u_2 \\ & 2x_1 + 8x_2 & \le 60 & (u_1) & & 2u_1 + 3u_2 & \ge 6 & (x_1) \\ & 3x_1 + 5x_2 & \le 45 & (u_2) & & 8u_1 + 5 u_2 & \ge 10 & (x_2) \\ & x_1, x_2 & \ge 0 & & & u_1, u_2 & \ge 0 \end{array}

When we add slack variables in the primal, two things change. First, the constraints become equations, which means $u_1, u_2$ are now unrestricted variables (with no nonnegativity constraints). Second, there are now two more dual constraints corresponding to the slack variables $s_1$ and $s_2$. Those dual constraints turn out to be exactly the constraints $u_1 \ge 0$ and $u_2 \ge 0$ which we lost from the first change. So we get an identical dual:

\begin{array}{rrll rrll} \text{maximize } & 6x_1 + 10x_2 & & & \text{minimize} & 60u_1 + 45u_2 \\ & 2x_1 + 8x_2 + s_1 & = 60 & (u_1) & & 2u_1 + 3u_2 & \ge 6 & (x_1) \\ & 3x_1 + 5x_2 + s_2 & = 45 & (u_2) & & 8u_1 + 5 u_2 & \ge 10 & (x_2) \\ & x_1, x_2, s_1, s_2 & \ge 0 & & & u_1 & \ge 0 & (s_1) \\ & & & & & u_2 & \ge 0 & (s_2) \end{array}

If you like, you can write both dual programs in matrix notation as $\mathbf u^{\mathsf T}\!A \ge \mathbf c^{\mathsf T}$. This gives us $$ \begin{bmatrix}u_1 & u_2\end{bmatrix} \begin{bmatrix}2 & 3 \\ 8 & 5\end{bmatrix} \ge \begin{bmatrix}6 & 10 \end{bmatrix} $$ in the first dual, and $$ \begin{bmatrix}u_1 & u_2\end{bmatrix} \begin{bmatrix}2 & 3 & 1 & 0 \\ 8 & 5 & 0 & 1\end{bmatrix} \ge \begin{bmatrix}6 & 10 & 0 & 0\end{bmatrix} $$ in the second dual. The change is because in the first dual, we're thinking of $u_1 \ge 0$ and $u_2 \ge 0$ as nonnegativity constraints (treated as a special case), while in the second dual, they are just two linear constraints like any others.


We don't typically add slack variables to the dual, but if we did, it would have an identical (but slightly sillier) effect on the primal.

I think the cleanest way to do it is to add a nonpositive slack variable: turn $2u_1 + 3u_2 \ge 6$ into $2u_1 + 3u_2 + w_1 = 6$, where $w_1 \le 0$. A nonpositive slack variable in the dual will correspond to a $\ge$ constraint in the primal, which will replace the nonnegativity constraint on $x_1$. We'll get: \begin{array}{rrll rrll} \text{maximize } & 6x_1 + 10x_2 & & & \text{minimize} & 60u_1 + 45u_2 \\ & 2x_1 + 8x_2 + s_1 & = 60 & (u_1) & & 2u_1 + 3u_2 + w_1 & = 6 & (x_1) \\ & 3x_1 + 5x_2 + s_2 & = 45 & (u_2) & & 8u_1 + 5 u_2 + w_2 & = 10 & (x_2) \\ & x_1 & \ge 0 & (w_1) & & u_1 & \ge 0 & (s_1) \\ & x_2 & \ge 0 & (w_2) & & u_2 & \ge 0 & (s_2) \\ & s_1, s_2 & \ge 0 & & & w_1, w_2 & \le 0 \end{array}

Note that $s_1, s_2$ still have special-cased nonnegativity constraints, just like $w_1, w_2$ still have special-cased nonpositivity constraints.

If we really wanted to do terrible, unnatural things to our primal-dual pair, we could add slack variables to the constraints $x_1 \ge 0, x_2 \ge 0, u_1 \ge 0, u_2 \ge 0$. This would turn the nonnegativity constraints on $s_1, s_2$ and the nonpositivity constraints on $w_1, w_2$ into ordinary constraints, make the matrix even bigger, and add more variables to both programs. You can keep going like this indefinitely, creating bloated primal-dual pairs that are ultimately equivalent to the original.

Misha Lavrov
  • 142,276
  • Thank you for a great answer! So as long as I specify that the slack variables of the dual problem are negative? I can write the matrix A like this: $A =\begin{pmatrix} 2 & 3 & 1 & 0\ 8 & 5 & 0 & 1 \end{pmatrix}$ ? – Mathomat55 Oct 23 '22 at 10:42
  • No, by the time you add nonpositive slack variables to the dual, $A$ will become $\begin{bmatrix}2&3&1&0\8&5&0&1\1&0&0&0\0&1&0&0\end{bmatrix}$. Or, if you add nonnegative slack variables (as $2u_1 + 3u_2 - w_1 = 6$ where $w_1 \ge 0$ you will have $A=\begin{bmatrix}2&3&1&0\8&5&0&1\-1&0&0&0\0&-1&0&0\end{bmatrix}$. Both of these are weird; are you really sure you want to add slack variables to the dual?? – Misha Lavrov Oct 23 '22 at 14:31
  • I was asked to write the dual problem in matrix form, given the primal problem in matrix form. So must I not then add slack variables? – Mathomat55 Oct 23 '22 at 15:53
  • Any kind of constraints can be written in matrix form. If we write your primal program as $\begin{bmatrix}2&3\8&5\end{bmatrix}\begin{bmatrix}x_1\x_2\end{bmatrix}\le\begin{bmatrix}60\45\end{bmatrix}$, that's already in matrix form, even though there are no slack variables. It's necessary to add slack variables if you want to put a linear program in equational form - but the primal and the dual cannot simultaneously be in that form. – Misha Lavrov Oct 23 '22 at 15:56
  • Oh, I think I meant I want to write the dual in equational form given the primal in equational form. So if the primal is in equational form, the dual can not be in equational form simultaneously? – Mathomat55 Oct 23 '22 at 15:59
  • Exactly. The linear programs will always need to have inequalities somewhere. If one program is in equational form, the other will have unrestricted variables, so its constraints will need to contain inequalities. (My other point is that maybe for practice you want to write the dual in equational form, but there is usually no point in doing that.) – Misha Lavrov Oct 23 '22 at 16:02
  • Ok, I see! Thank you for your time and help :) I really appreciate it! – Mathomat55 Oct 23 '22 at 16:03