display | more...
Slack variables are used in Linear Optimization to turn constraints stated as inequalities into equalities and a constraint that the slack variable be non-negative. Linear programming problems should be set up so that all variables must be non-negative anyway, so this last constraint isn't so important. The variable can grow to take up the 'slack' in the inequality, but never shrinks small enough (i.e. goes negative) to break the inequality.

You'll normally be using slack variables to set up a problem in matrix form so that you can run it through the Simplex method or some similar algorithm, almost all of which will require constraints to be stated as equalities (but where slack variables can easily be added.)

Starting with an inequality:

x + y >= 10

We either add or subtract a slack variable so that if the statement is an equality, the slack variable is zero, and the slack would have to be negative if the inequality weren't satisfied:

x + y - s = 10, s >= 0

Here, if x+y < 10, s will have to be negative to satisfy the inequality. Thus the second pair of constraints is equivalent to the first.

Some other sample slack variable additions:

3x + 5y <=100
3x + 5y + c1 = 100, c1 >= 0

100 x1 - 150 x2 + 5 x5 >= 100
100 x1 - 150 x2 + 5 x5 - x7 = 100, x7 >= 0

Log in or register to write something here or to contact authors.