We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Simplex Tableau – Slack Variables

The Tableau is basically just a matrix of coefficients, which makes it a system of equations. The nice thing about systems of equations is that we can do mathematical operations on them, and because we know they share variables, one equation can provide information about another.

-5x - y + profit  = 0
1x  + 0y         <= 250
0x  + 1y         <= 200
1x  + 1y         <= 300

Slack Variables

For each inequality constraint, we need to add a new variable, called a slack variable. The purpose of the slack variable is to change the inequality constraint to an equality constraint. This variable represents the difference between the two sides of the inequality and is assumed to be non-negative. For example, the inequalities

1x + 0y <= 250
0x + 1y <= 200
1x + 1y <= 300

become

1x + 0y + s1 = 250
0x + 1y + s2 = 200
1x + 1y + s3 = 300

By adding a slack variable for each inequality, the size of our tableau will grow, because instead of two variables, x and y, we now have 5 variables, x, y, s1, s2, and s3.

Assignment

Complete the add_slack_variables method. It should add all the slack variables to the tableau, along with the constraints.

This tableau:

  x     y
[1.0,  0.0]
[0.0,  1.0]
[1.0,  1.0]
[-5.0, -1.0]

should be extended to:

  x     y    s1   s2   s3   constraint
[1.0,  0.0,  1.0, 0.0, 0.0, 250.0]
[0.0,  1.0,  0.0, 1.0, 0.0, 200.0]
[1.0,  1.0,  0.0, 0.0, 1.0, 300.0]
[-5.0, -1.0, 0.0, 0.0, 0.0, 0.0]

Notice that there's one slack variable per row. Each row has its slack variable in its own column represented by a coefficient of 1.