The document summarizes a lesson on the simplex method for solving linear programming problems. It provides an example problem of maximizing output for a baker given constraints on ingredients. It introduces slack variables to transform inequalities to equations. The simplex method works by starting at an initial basic feasible solution and iteratively moving to adjacent basic feasible solutions that increase the objective function. It walks through applying the simplex method to the baker example, showing how to create the simplex tableau and move to new basic feasible solutions by choosing entering and departing variables at each step.
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Lesson 31: The Simplex Method, I
1. Lesson 31 (KH, Section 11.2)
The Simplex Method
Math 20
December 5, 2007
Announcements
Pset 11 due December 10. Pset 12 due December 17.
ML OH: Today 1–3 (SC 323)
SS OH: Tonight 8:30–9:30 in Quincy dining hall
HW coming
Midterm II review slides online
Midterm II: tomorrow 7–8:30pm in Hall A
2. Outline
Setup
Illustrative Problem
Slack Variables
The Simplex Method, By Example
The Initial Basic Feasible Solution
Creating a New Tableau
Recap of Steps
Example
3. Setup
A standard linear programming problem is to maximize the
quantity
c1 x1 + c2 x2 + . . . cn xn = c x
subject to constraints
a11 x1 + a12 x2 +. . .+ a1n xn ≤ b1
a21 x1 + a22 x2 +. . .+ a2n xn ≤ b2
...
am1 x1 +am2 x2 +. . .+amn xn ≤ bm
or
Ax ≤ b.
We usually include the nonnegativity constraint x ≥ 0. Today we
will also assume b ≥ 0.
4. Any vector x which satifies all the inequalities is called a feasible
solution to the given problem, and a feasible solution maximizing
the objective function is called an optimal solution.
5. Outline
Setup
Illustrative Problem
Slack Variables
The Simplex Method, By Example
The Initial Basic Feasible Solution
Creating a New Tableau
Recap of Steps
Example
6. Illustrative Problem
We will use the baker of before. He is trying to maximize
z = 8x + 10y
subject to the constraints
2x+ y ≤50
x+ 2y ≤70
x≥ 0
y ≥ 0.
7. Slack Variables
We can turn the inequalities into equalities by inserting new
variables, which are called slack variables. Thus the first equation
of constraint becomes
2x + y ≤ 50 =⇒ 2x + y + u = 50,
and the second
x + 2y ≤ 70 =⇒ x + 2y + v = 70.
But u and v are nonnegative. So the new problem is to maximize
8x + 10y subject to constraints
2x+ y +u =50
x+2y +v =70
x ≥0 y ≥0 u≥0 v ≥0
8. In general, we insert slack variables u1 , u2 , . . . , um and the
equations of constraint become
Ax + u = b,
along with x ≥ 0, u ≥ 0.
Definition
The vector x in Rn+m is called a basic solution if its obtained by
setting n of the variables in this equation equal to zero and solving
for the remaining n variables. The m variables are we solve for are
called the basic variables, and the n variables set equal to zero are
called the nonbasic variables. The vector x is called a basic
feasible solution if it is a basic solution that also satisfies the
inequalities x ≥ 0.
9. Why are basic feasible solutions necessary?
Theorem
If a LP problem has an optimal solution, then it has a basic
optimal solution.
This is just a restatement of the corner principle. So we only need
to find the basic feasible solutions!
10. Back to the Baker
y
(0, 50)
50
40 (0, 35)
(10, 30)
30
x+
2x
2y
20
+y
=7
0
=5
10
0
(0, 0) (25, 0) (70, 0)
x
10 20 30 40 50 60 70
11. Back to the Baker
y
50 not feasible
40 (0, 35)
(10, 30)
30
v=
20
0
u=
0
10
(0, 0) (25, 0) not feasible
x
10 20 30 40 50 60 70
12. How many basic feasible solutions are there? Out of the m + n
variables, we choose n to set equal to zero, and solve for the rest.
This can be done
n+m (n + m)!
=
m m! n!
ways. That’s a lot!
The simplex method is a way to arrive at an optimal solution by
traversing the vertices of the feasible set, in each step increasing
the objective function by as much as possible.
13. Outline
Setup
Illustrative Problem
Slack Variables
The Simplex Method, By Example
The Initial Basic Feasible Solution
Creating a New Tableau
Recap of Steps
Example
14. We’ll work with the illustrative problem. We can start with the
basic feasible solution x = 0, y = 0. Thus u = 50 and v = 70.
This is our initial basic solution.
We’ll start writing everything in a table (or tableau), so let’s also
write the objective function with a right-hand side of zero. Thus
−8x − 10y + z = 0.
We put this all together, forming what is called the initial tableau:
x y u v z value
u 2 1 1 0 0 50
v 1 2 0 1 0 70
z −8 −10 0 0 1 0
15. x y u v z value
u 2 1 1 0 0 50
v 1 2 0 1 0 70
z −8 −10 0 0 1 0
Is the solution u = 50, v = 70 (i.e., x = 0, y = 0 optimal?)
16. x y u v z value
u 2 1 1 0 0 50
v 1 2 0 1 0 70
z −8 −10 0 0 1 0
Is the solution u = 50, v = 70 (i.e., x = 0, y = 0 optimal?) No,
increasing x or y would increase z.
17. x y u v z value
u 2 1 1 0 0 50
v 1 2 0 1 0 70
z −8 −10 0 0 1 0
Is the solution u = 50, v = 70 (i.e., x = 0, y = 0 optimal?) No,
increasing x or y would increase z.
Optimality Criterion
If the objective row of a tableau has no negative entries in the
columns labeled with variables, then the indicated solution is
optimal and we can stop our computation.
18. x y u v z value
u 2 1 1 0 0 50
v 1 2 0 1 0 70
z −8 −10 0 0 1 0
Move from one basic solution to another
One of the zero (nonbasic) variables becomes nonzero and
one of nonzero (basic) variables becomes zero
Do this as efficiently as possible
19. x y u v z value
u 2 1 1 0 0 50
v 1 2 0 1 0 70
z −8 −10 0 0 1 0
Move from one basic solution to another
One of the zero (nonbasic) variables becomes nonzero and
one of nonzero (basic) variables becomes zero
Do this as efficiently as possible
Which of x or y would you most like to increase?
20. x y u v z value
u 2 1 1 0 0 50
v 1 2 0 1 0 70
z −8 −10 0 0 1 0
Move from one basic solution to another
One of the zero (nonbasic) variables becomes nonzero and
one of nonzero (basic) variables becomes zero
Do this as efficiently as possible
Which of x or y would you most like to increase? An increase of 1
in y gives an increase of 10 in z. Let’s make y > 0. y enters the
set of basic variables, so it’s called the entering variable for this
step.
21. How much can we increase y ? Well, since x is still zero, the
equations of constraint can be written
u = 50 − y
v = 70 − 2y
22. How much can we increase y ? Well, since x is still zero, the
equations of constraint can be written
u = 50 − y
v = 70 − 2y
We still need u ≥ 0 and v ≥ 0, so the most we can increase y is to
35. This is the smallest of the ratios 50 = 50 and 70 = 35. So
1 2
we’re going to increase y to 35. This will make v = 0. We call v
the departing variable.
23. How much can we increase y ? Well, since x is still zero, the
equations of constraint can be written
u = 50 − y
v = 70 − 2y
We still need u ≥ 0 and v ≥ 0, so the most we can increase y is to
35. This is the smallest of the ratios 50 = 50 and 70 = 35. So
1 2
we’re going to increase y to 35. This will make v = 0. We call v
the departing variable.
The new basic solution therefore has y = 35, v = 0, u = 15, and
x = 0. The new value of the objective function is z = 10y = 350.
24. Creating a New Tableau
We are exchanging the basic variable v for y . This means the ob-
jective row has to be replaced with one that has a zero in the y
columns. We can do this by adding multiples of row 2. Since y is
an entering variable, we might as well normalize row 2 to have a
one.
So we scale the second row to have a one in the y column.
x y u v z value
u 2 1 1 0 0 50
v 1 2 0 1 0 70
z −8 −10 0 0 1 0
25. Creating a New Tableau
Now we zero out the rest of this column by adding 10 times row 2
to row 3, and subtracting row 2 from row 1.
x y u v z value
2 1 1 0 0 50
1/2 1 0 1/2 0 35
−8 −10
z 0 0 1 0
26. Creating a New Tableau
The new tableau. By looking at the columns, we see y and u are
the basic variables. The value of the objective function has also
changed.
x y u vz value
1 −1/2 0
u 3/2 0 15
y 1/2 1 0 1/2 0 35
z −3 0 0 51 350
27. Rinse, Lather, Repeat
The x column in the objective row has a negative entry, so increasing
x will increase z.
xy u vz value
1−
u 3/2
0 1/2 0 15
y 1/2 1 0 1/2 0 35
z −3 0 0 51 350
28. Rinse, Lather, Repeat
The x column in the objective row has a negative entry, so increasing
x will increase z. How much can we increase it?
xy u vz value
1−
u 3/2
0 1/2 0 15
y 1/2 1 0 1/2 0 35
z −3 0 0 51 350
29. Rinse, Lather, Repeat
The x column in the objective row has a negative entry, so increasing
x will increase z. How much can we increase it? The minimum of
15 35
the two ratios 3/2 = 10 and 1/2 = 70.
xy u vz value
1−
u 3/2
0 1/2 0 15
y 1/2 1 0 1/2 0 35
z −3 0 0 51 350
30. Rinse, Lather, Repeat
The x column in the objective row has a negative entry, so increasing
x will increase z. How much can we increase it? The minimum
15 35
of the two ratios 3/2 = 10 and 1/2 = 70. So x in the entering
variable and u is the departing variable.
↓x y u vz value
←u 1−
3/2 0 1/2 0 15
y 1/2 1 0 1/2 0 35
−3
z 0 0 51 350
31. Rinse, Lather, Repeat
The x column in the objective row has a negative entry, so increasing
x will increase z. How much can we increase it? The minimum
15 35
of the two ratios 3/2 = 10 and 1/2 = 70. So x in the entering
variable and u is the departing variable.
We scale row one by 2/3 to make it one in the basic column.
xy u vz value
1−
u 3/2
0 1/2 0 15
y 1/2 1 0 1/2 0 35
z −3 0 0 51 350
32. Rinse, Lather, Repeat
The x column in the objective row has a negative entry, so increasing
x will increase z. How much can we increase it? The minimum
15 35
of the two ratios 3/2 = 10 and 1/2 = 70. So x in the entering
variable and u is the departing variable.
We scale row one by 2/3 to make it one in the basic column.
And we zero out the rest of the column by subtracting half of row
1 from row 2, and adding 3 times row 1 to row 3.
x y u v z value
−1/3
u 1 0 2/3 0 10
y 1/2 1 0 1/2 0 35
−3 0 0 51 350
33. Rinse, Lather, Repeat
The x column in the objective row has a negative entry, so increasing
x will increase z. How much can we increase it? The minimum
15 35
of the two ratios 3/2 = 10 and 1/2 = 70. So x in the entering
variable and u is the departing variable.
We scale row one by 2/3 to make it one in the basic column.
And we zero out the rest of the column by subtracting half of row
1 from row 2, and adding 3 times row 1 to row 3.
x y u v z value
−1/3
u 1 0 2/3 0 10
y 1/2 1 0 1/2 0 35
−3 0 0 51 350
34. Rinse, Lather, Repeat
The x column in the objective row has a negative entry, so increasing
x will increase z. How much can we increase it? The minimum
15 35
of the two ratios 3/2 = 10 and 1/2 = 70. So x in the entering
variable and u is the departing variable.
We scale row one by 2/3 to make it one in the basic column.
And we zero out the rest of the column by subtracting half of row
1 from row 2, and adding 3 times row 1 to row 3.
x y u vz value
2/3 −1/3 0
x 1 0 10
1 −1/3
y 0 2/3 0 30
0 0 2 41 380
35. x y u vz value
2/3 −1/3 0
x 1 0 10
1 −1/3
y 0 2/3 0 30
0 0 2 41 380
Now any increase in the decision variables or slack variables would
result in a decrease of z. We are done!
36. Outline
Setup
Illustrative Problem
Slack Variables
The Simplex Method, By Example
The Initial Basic Feasible Solution
Creating a New Tableau
Recap of Steps
Example
37. Recap of Steps
1. Set up the initial tableau.
2. Apply the optimality test. If the objective row has no negative
entries in the columns labeled with variables, then the
indicated solution is optimal; we can stop.
3. Choose a pivotal column by determining the column with the
most negative entry in the objective row. If there are several
candidates for a pivotal column, choose any one.
4. Choose a pivotal row. Form the ratios of the entries above the
objective row in the rightmost column by the corresponding
entries of the pivotal column for those entries in the pivotal
column which are positive. The pivotal row is the row for
which the smallest of these ratios occurs. If there is a tie,
choose any one of the qualifying rows. If none of the entries
in the pivotal column above the objective row is positive, the
problem has no finite optimum. We stop.
5. Perform pivotal elimination to construct a new tableau and
return to Step 2.
38. Outline
Setup
Illustrative Problem
Slack Variables
The Simplex Method, By Example
The Initial Basic Feasible Solution
Creating a New Tableau
Recap of Steps
Example
39. Another Example
Example
Maximize z = 3x1 − x2 + 6x3 subject to the constraints
2x1 +4x2 + x3 ≤ 4
−2x1 +2x2 −3x3 ≥−4
2x1 + x2 − x3 ≤ 8
x1 ≥ 0
x2 ≥ 0
x3 ≥ 0.
Negating row two puts this problem into standard form.
40. Another Example
Example
Maximize z = 3x1 − x2 + 6x3 subject to the constraints
2x1 +4x2 + x3 ≤ 4
−2x1 +2x2 −3x3 ≥−4
2x1 + x2 − x3 ≤ 8
x1 ≥ 0
x2 ≥ 0
x3 ≥ 0.
Negating row two puts this problem into standard form.
Answer.
x1 = 0, x2 = 4/7, x3 = 12/7, z = 687.
41. We insert slack variables u1 , u2 , and u3 .
The equations of constraint become
≤4
2x1 +4x2 + x3 +u1
2x1 −2x2 +3x3 ≤4
+u2
2x1 + x2 − x3 +u3 ≤8
with all variables nonnegative.