Slack variables

Slack Variables

A slack variable converts a $\le$ inequality into an equality.

It measures unused capacity.

Basic Rule

For a constraint:

\[a^Tx\le b\]

introduce a new variable:

\[s\ge 0\]

and write:

\[a^Tx+s=b\]

The slack variable is:

\[s=b-a^Tx\]

Because $a^Tx\le b$, we have:

\[s\ge 0\]

Interpretation

Slack is the difference between what is available and what is used.

For a resource constraint:

\[\text{resource used}\le \text{resource available}\]

slack means:

\[\text{unused resource}\]

Example

Suppose:

\[6x_1+2x_2\le 12\]

Add slack variable $s_1\ge 0$:

\[6x_1+2x_2+s_1=12\]

Then:

\[s_1=12-6x_1-2x_2\]

If $s_1=0$, the resource is fully used.

If $s_1>0$, some resource is unused.

Multiple Slack Variables

For:

\[x_2\le 4\]

add:

\[s_2\ge 0\]

and write:

\[x_2+s_2=4\]

Each $\le$ constraint gets its own slack variable.

Standard Form Example

Original problem:

\[\max 3x_1+x_2\]

subject to:

\[x_2\le 4\] \[6x_1+2x_2\le 12\] \[x_2\ge 0\]

After converting max to min and adding slacks:

\[\min -3x_1-x_2\]

subject to:

\[x_2+s_1=4\] \[6x_1+2x_2+s_2=12\] \[x_1,x_2,s_1,s_2\ge 0\]

Slack and Active Constraints

If a constraint is active, then the slack variable is zero.

For:

\[a^Tx+s=b\]

if:

\[a^Tx=b\]

then:

\[s=0\]

If the constraint is not active, then:

\[s>0\]

Slack Variables in Matrix Form

Slack variables add columns to the matrix $A$.

For several $\le$ constraints, these columns often form an identity matrix.

Example:

\[\begin{aligned} 6x_1+2x_2+s_1&=12\\ x_2+s_2&=4 \end{aligned}\]

has matrix:

\[A=\begin{bmatrix} 6&2&1&0\\ 0&1&0&1 \end{bmatrix}\]

The slack columns are:

\[\begin{bmatrix}1\\0\end{bmatrix}, \qquad \begin{bmatrix}0\\1\end{bmatrix}\]

Common Mistake

For a $\le$ constraint, add slack.

Do not subtract it.

Correct:

\[a^Tx+s=b, \qquad s\ge 0\]

Wrong:

\[a^Tx-s=b, \qquad s\ge 0\]

because that would imply $a^Tx\ge b$.

Checklist

You understand slack variables if you can:

  • convert $a^Tx\le b$ into $a^Tx+s=b$
  • explain slack as unused capacity
  • add one slack variable per $\le$ constraint
  • identify active constraints by zero slack
  • write slack columns in matrix form

See Also

Exam checkpoint

For standard-form questions, use the course convention $\min c^Tx$ subject to $Ax=b$, $x\ge0$. Convert max objectives, add slack to $\le$, subtract surplus from $\ge$, and split free variables.

25

25
Ready to start
Slack variables
Session: 1 | Break: Short
Today: 0 sessions
Total: 0 sessions