# Chapter 4 The Simplex Algorithm – Part II

advertisement
```Chapter 4
The Simplex Algorithm – Part II
Based on
Introduction to Mathematical Programming: Operations Research, Volume 1
4th edition, by Wayne L. Winston and Munirpallam Venkataramanan
Lewis Ntaimo
L. Ntaimo (c) 2005 INEN420 TAMU
1
So Far …
•
•
•
•
Modeling LPs
Solving 2-variable LPs graphically
Simplex method - Max LPs
Simplex method - Min LPs
– Method 1: Multiply objective function by -1
– Method 2: Modify Step 3 of simplex algorithm for Max LPs
•
Simplex method – Special cases:
– Alternative optimal solutions
– Unbounded LPs
L. Ntaimo (c) 2005 INEN420 TAMU
2
Degeneracy and Convergence of the Simplex
Algorithm
L. Ntaimo (c) 2005 INEN420 TAMU
3
4.11 Convergence of the Simplex Method
Recall:
Max z = cT x
s.t.
Ax = b
x≥0
Where,
⎡ x1 ⎤
⎢x ⎥
⎢ 2⎥
⎢.⎥
x=⎢ ⎥
⎢.⎥
⎢.⎥
⎢ ⎥
⎢⎣ xn ⎥⎦
⎡ c1 ⎤
⎢c ⎥
⎢ 2⎥
⎢.⎥
c=⎢ ⎥
⎢.⎥
⎢.⎥
⎢ ⎥
⎢⎣cn ⎥⎦
⎡ a11
⎢a
⎢ 21
⎢ .
A=⎢
⎢ .
⎢ .
⎢
⎣⎢am1
a12
.
.
.
a22
.
.
.
.
.
.
.
.
.
am 2
a1n ⎤
a2 n ⎥⎥
. ⎥
⎥
. ⎥
. ⎥
⎥
amn ⎦⎥
⎡ b1 ⎤
⎢b ⎥
⎢ 2⎥
⎢.⎥
b=⎢ ⎥
⎢.⎥
⎢.⎥
⎢ ⎥
⎢⎣bm ⎥⎦
Assumption: Constraint matrix A has n columns and m linearly
independent rows. So we can form an m x m square matrix called the
basis by setting (n - m) variables to zero (nonbasic variables or nbv’s).
The remaining variables are the basic variables or bv’s.
L. Ntaimo (c) 2005 INEN420 TAMU
4
4.11 Convergence of the Simplex Method
Recall that for any LP with m constraints, two bfs are said to be
adjacent if their sets of bv’s have (m - 1) bv’s in common.
e.g. bfs of two immediate simplex tableaus are adjacent bfs.
If an LP in standard form has m constraints and n variables, then
there may be a basic solution for each choice of nonbasic variables.
•
From n variables, in how many different ways can a set of (n - m)
nonbasic variables (or equivalently, m basic variables) be chosen?
•
⎛n⎞
n!
⎜⎜ ⎟⎟ =
⎝ m ⎠ (n − m)!m!
Thus an LP can have at most
⎛n⎞
⎜⎜ ⎟⎟
⎝ m⎠
basic solutions!
L. Ntaimo (c) 2005 INEN420 TAMU
5
4.11 Convergence of the Simplex Method
•
For n = 20 and m = 10 we have:
⎛ 20 ⎞
20!
⎜⎜ ⎟⎟ =
=?
10
(
20
−
10
)!
10
!
⎝ ⎠
184,756 bfs!
Assuming that no bfs is repeated the simplex algorithm will
find the optimal bfs after a finite number of iterations.
Vast experience with the simplex algorithm indicates that an
optimal solution is found after examining fewer than 3m bfs
(e.g. 3(10) = 30).
•
Compared with examining 184,756 bfs, the simplex algorithm
is quite efficient!
•
L. Ntaimo (c) 2005 INEN420 TAMU
6
4.11 Degeneracy and Convergence of the Simplex Method
Definition: An LP is degenerate if it has at least one bfs in
which a basic variable is equal to zero.
•
We say that an LP is nondegenerate if all bfs are positive.
Theoretically, the simplex algorithm (as you have learned it
so far) can fail to find the optimal solution to an LP.
•
However, LPs arising from actual applications seldom exhibit
this behavior.
•
L. Ntaimo (c) 2005 INEN420 TAMU
7
4.11 Degeneracy and Convergence of the Simplex Method
•
Consider the following relationship for a max LP:
z-value for new bfs = z-value for current bfs – (value of entering
variable in new bfs)*(coefficient of entering variable in row 0 of
current bfs).
Recall: (coefficient of entering variable in row 0) &lt; 0 and
(value of entering variable in new bfs) &gt;= 0.
Two Facts:
(1) If (value of entering variable in new bfs) &gt; 0), then
(z-value for new bfs) &gt; (z-value for current bfs).
(2) If (value of entering variable in new bfs) = 0), then
(z-value for new bfs) = (z-value for current bfs).
L. Ntaimo (c) 2005 INEN420 TAMU
8
4.11 Degeneracy and Convergence of the Simplex Method
Fact 1 implies that each iteration of the simplex algorithm will
increase z for a nondegenerate LP. This means that it is impossible
to encounter the same bfs twice. So if we use the simplex algorithm
to solve a nondegenerate LP, we are guaranteed to find the optimal
solution in a finite number of iterations.
Fact 2 implies that the simplex algorithm may fail for a degenerate
LP. In this case the algorithm will encounter the same bfs at
least twice. This occurrence is called cycling. If cycling occurs
then the algorithm can loop, or cycle, forever among a set of bfs
and never get to the optimal solution!
L. Ntaimo (c) 2005 INEN420 TAMU
9
4.11 Degeneracy and Convergence of the Simplex Method
Example: Solve the following LP using the simplex tableau method.
Max z = 5 x1 + 2 x2
s.t.
x1 + x2 ≤ 6
x1 − x2 ≤ 0
x1 , x2 ≥ 0
Converting to standard form:
Max z = 5 x1 + 2 x2
s.t.
x1 + x2 + s1
x1 − x2
=6
+ s2 = 0
x1 , x2 , s1 , s2 ≥ 0
L. Ntaimo (c) 2005 INEN420 TAMU
10
4.11 Degeneracy and Convergence of the Simplex Method
Example: Solve using the simplex tableau method
Initial Tableau
Row
0
1
2
Solution
z
1
0
0
x1
-5
1
1
x2
-2
1
-1
s1
0
1
0
s2
0
0
1
RHS
0
6
0
BV
z=
s1 =
s2 =
Second Tableau
z
Row
1
0
0
1
0
2
x1
0
0
1
x2
-7
2
-1
s1
0
1
0
s2
5
-1
1
RHS
0
6
0
BV
z=
s1 =
x1 =
MRT
0
6
0
6
0*
z=0
x1 = 0
x2 = 0
MRT
0
6
0
3*
None
z=0
x1 = 0
x2 = 0
Cycling: We encounter same bfs twice!
Third (Optimal) Tableau
z
Row
1
0
0
1
0
2
x1
0
0
1
x2
0
1
0
s1
3.5
0.5
0.5
s2
1.5
-0.5
0.5
RHS
21
3
3
BV
z=
x2 =
x1 =
MRT
21
3
3
z = 21
x1 = 3
x2 = 3
Optimal Solution: z = 21, x1 = 3, x2 =3
L. Ntaimo (c) 2005 INEN420 TAMU
11
4.11 Degeneracy and Convergence of the Simplex Method
If an LP has many degenerate bfs (or a bfs with many bv’s equal to
zero), then the simplex algorithm is often very inefficient
Example: Solve the previous example using the graphical method
The extreme points of the feasible
region are B,C and D. Three sets
of basic variables correspond to
extreme point C.
x2
6
B
x1 − x2 ≤ 0
4
D
x1 + x2 ≤ 6
2
C
A
2
4
z = 10 ⇒
5 x1 + 2 x2 = 10
6
z = 21
x1
BV's
x1, x2
x1, s1
x1, s2
x2, s1
x2, s2
s1, s2
BFS
x1 = x2 = 3, s1 = s2 = 0
x1 = 0, s1 = 6, x2 = s2 = 0
x1 = 6, s2 = -6, x2 = s1 = 0
x2 = 0, s1 = 6, x1 = s2 = 0
x2 = 6, s2 = 6, s1 = x1 = 0
s1 = 6, s2 = 0, x1 = x2 = 0
L. Ntaimo (c) 2005 INEN420 TAMU
Extreme Point
D
C
Infeasible
C
B
C
12
4.11 Degeneracy and Convergence of the Simplex Method
For an LP with n decision variables to be degenerate, (n+1) or more
of the LP’s constraints (including the sign restrictions xi ≥ 0 as
constraints) must be binding at an extreme point.
Fortunately, the simplex method can be modified to ensure that
cycling will never occur.
Apply the so called anti-cycling rules.
L. Ntaimo (c) 2005 INEN420 TAMU
13
4.11 Degeneracy and Convergence of the Simplex Method
Bland’s Rules for Anti-Cycling: Smallest Subscript Pivoting Rule
(Assume that slack and excess variables are numbered xn+1, xn+2, ...).
Step 1. Choose as the entering variable (in a max problem) the
variable with a negative coefficient in row 0 that has the
smallest subscript.
Step 2. If there is a tie in the minimum ratio test, then break the tie by
choosing the winner of the ratio test so that the variable
leaving the basis has the smallest subscript.
L. Ntaimo (c) 2005 INEN420 TAMU
14
4.11 Degeneracy and Convergence of the Simplex Method
Additional homework problems have been posted on the course
website on degeneracy and convergence of the simplex method.
L. Ntaimo (c) 2005 INEN420 TAMU
15
The Big M Method
L. Ntaimo (c) 2005 INEN420 TAMU
16
4.12 The Big M Method
Recall that the simplex method algorithm requires a starting
bfs. In all the LPs we have considered so far, we have found
starting bfs by using the slack variables as our basic variables.
•
If an LP has ≥ or = constraints, however, a starting bfs may not
be readily apparent. In such a case, we need another method to
solve the problem.
•
L. Ntaimo (c) 2005 INEN420 TAMU
17
4.12 The Big M Method
Consider the following problem:
Bevco manufactures an orange-flavored soft drink called Oranj by
combining orange soda and orange juice. Each orange soda contains
0.5 oz of sugar and 1 mg of vitamin C. Each ounce of orange juice
contains 0.25 oz of sugar and 3 mg of vitamin C. It costs Bevco 2&cent; to
produce an ounce of orange soda and 3&cent; to produce an ounce of
orange juice. Bevco’s marketing department has decided that each 10oz bottle of Oranj must contain at least 20 mg of vitamin C and at most
4 oz of sugar. Use linear programming to determine how Bevco can
meet the marketing department’s requirements at minimum cost.
L. Ntaimo (c) 2005 INEN420 TAMU
18
4.12 The Big M Method
Decision variables:
x1 = number of ounces of orange soda in a bottle of Oranj
x2 = number of ounces of orange juice in a bottle of Oranj
LP:
Min
s.t.
z = 2x1 +
3x2
0.5x1 + 0.25x2 ≤ 4
x1 +
3x2 ≥ 20
x1 +
x2 = 10
(sugar constraint)
(vitamin C constraint)
(10 oz in 1 bottle of Oranj)
x1, x2 ≥ 0
L. Ntaimo (c) 2005 INEN420 TAMU
19
4.12 The Big M Method
The LP in standard:
Min z = 2x1 +
s.t.
3x2
0.5x1 + 0.25x2 + s1
= 4
x1 +
3x2
- e2 = 20
x1 +
x2
= 10
x1, x2, s1, e2 ≥ 0
The LP in standard form has z and s1 which could be used for BVs
but row 2 would violate sign restrictions and row 3 has no readily
apparent basic variable.
L. Ntaimo (c) 2005 INEN420 TAMU
20
4.12 The Big M Method
In order to use the simplex method, a bfs is needed. The idea of the Big
M method is to create artificial variables to provide an initial bfs and then
eliminate them from the final solution. The variables will be labeled ai
according to the row i in which they are used as follows.
Row 0:
Row 1:
z - 2x1 -
3x2
0.5x1 + 0.25x2 + s1
Row 2:
x1 +
3x2
Row 3:
x1 +
x2
= 4
- e2 + a2
= 20
+ a3 = 10
L. Ntaimo (c) 2005 INEN420 TAMU
21
4.12 The Big M Method
In the optimal solution, all artificial variables must be set equal to zero.
To accomplish this, in a min LP, a term Mai is added to the objective
function for each artificial variable ai. For a max LP, the term –Mai is
added to the objective function for each ai. M represents some very
large number. The modified Bevco LP in standard form then becomes:
Min z = 2x1 +
s.t.
3x2 + Ma2 + Ma3
0.5x1 + 0.25x2 + s1
x1 +
3x2
x1 +
x2
= 4
- e2 + a2
= 20
+ a3 = 10
x1, x2, s1, e2, a2, a3 ≥ 0
Modifying the objective function this way makes it extremely costly for
an artificial variable to be positive. The optimal solution should force
a2 = a3 =0.
L. Ntaimo (c) 2005 INEN420 TAMU
22
4.12 The Big M Method
The rows of the simplex tableau would then be:
Row 0: z - 2x1 Row 1:
3x2
- Ma2 - Ma3 = 0
0.5x1 + 0.25x2 + s1
Row 2:
x1 +
3x2
Row 3:
x1 +
x2
= 4
- e2 +
a2
= 20
+
a3 = 10
But observe that to have canonical form we need to eliminate a2 and a3
from row 0! Simply set new Row 0 to Row 0 + M(Row 2) + M(Row 3)
z -
2x1 -
M(
x1 +
+ M(
x1 +
3x2
- Ma2 - Ma3 = 0
3x2 - e2 +
a2
x2
z + (2M-2)x1 +(4M-3)x2 – Me2
L. Ntaimo (c) 2005 INEN420 TAMU
= 20)
+
a3 = 10)
= 30M
23
4.12 The Big M Method
Description of the Big M Method
1. Modify the constraints so that the rhs of each constraint is
nonnegative. Identify each constraint that is now an = or ≥ constraint.
2. Convert each inequality constraint to standard form (add a slack
variable for ≤ constraints, add an excess variable for ≥ constraints).
3. For each ≥ or = constraint, add artificial variables. Add sign restriction
ai ≥ 0.
4. Let M denote a very large positive number. Add (for each artificial
variable) Mai to min problem objective functions or -Mai to max
problem objective functions.
5. Since each artificial variable will be in the starting basis, all artificial
variables must be eliminated from row 0 before beginning the simplex.
Remembering M represents a very large number, solve the
transformed problem by the simplex.
L. Ntaimo (c) 2005 INEN420 TAMU
24
4.12 The Big M Method
If all artificial variables in the optimal solution equal zero,
the solution is optimal.
If any artificial variables are positive in the optimal solution,
the problem is infeasible.
L. Ntaimo (c) 2005 INEN420 TAMU
25
4.12 The Big M Method
The Bevco example continued (Using Method 2 for Min LP): Details
Iteration
1
z
x1
x2
0
1.00
2M - 2
4M -3
0.50
1.00
1.00
x1
2M - 2
0.50
0.33
1.00
x1
(2M-3)/3
0.50
0.33
1.00
x1
(2M-3)/3
0.42
0.33
1.00
x1
(2M-3)/3
0.42
0.33
0.67
0.25
3
1.00
x2
4M -3
0.25
1
1.00
x2
1
2
3
ero
0
1
2
3
ero
0
1
2
3
ero
0
1
2
3
ero
0
1
2
3
1
2
3
4
z
1.00
z
1.00
z
1.00
z
1.00
0.25
1
1.00
x2
s1
a3
-1.00
s1
1.00
e2
-M
a2
-0.33
0.33
1.00
a3
1.00
s1
e2
a2
(M-3)/3 (3-4M)/3
1.00
a3
1.00
-0.33
s1
s1
rhs
ratio
30M
1.00
1.00
1
a2
-M
1.00
1
1.00
x2
e2
0.33
e2
a2
(M-3)/3 (3-4M)/3
0.08
-0.08
-0.33
0.33
e2
a2
(M-3)/3 (3-4M)/3
0.08
-0.08
-0.33
0.33
0.33
-0.33
1.00
a3
1.00
a3
1.00
4.00
20.00
10.00
rhs
30M
4.00
6.67
10.00
rhs
(60+10M)/3
4.00
6.67
10.00
rhs
(60+10M)/3
2.33
6.67
10.00
rhs
(60+10M)/3
2.33
6.67
3.33
ero
Row 0 + M(Row 2) + M(Row 3)
16
6.67
10
L. Ntaimo (c) 2005 INEN420 TAMU
ero
Row 2 x 1/3
ero
Row 0 - (4M-3)*(Row 2)
ero
Row 1 - 0.25*(Row 2)
ero
Row 3 - Row 2
26
4.12 The Big M Method
Iteration
2
0
1
2
3
ero 1
0
1
2
3
ero 2
0
1
2
3
ero 3
0
1
2
3
ero 4
0
1
2
3
z
x1
1.00
(2M-3)/3
0.42
0.33
0.67
x1
(2M-3)/3
0.42
0.33
1.00
x1
z
1.00
z
1.00
z
1.00
0.42
0.33
1.00
x1
x2
s1
1.00
1
x2
s1
1.00
1
x2
s1
1.00
1.00
x2
s1
1.00
z
1.00
0.33
1.00
x1
1.00
x2
s1
1.00
1.00
1.00
e2
(M-3)/3
0.08
-0.33
0.33
e2
(M-3)/3
0.08
-0.33
0.50
e2
-0.50
0.08
-0.33
0.50
e2
-0.50
-0.13
-0.33
0.50
e2
-0.50
-0.13
-0.50
0.50
a2
a3
(3-4M)/3
-0.08
0.33
-0.33
1.00
a2
a3
(3-4M)/3
-0.08
0.33
-0.50
1.50
a2
a3
(1-2M)/2 (3-2M)/2
-0.08
0.33
-0.50
1.50
a2
a3
(1-2M)/2 (3-2M)/2
0.13
-0.63
0.33
-0.50
1.50
a2
a3
(1-2M)/2 (3-2M)/2
0.13
-0.63
0.50
-0.50
-0.50
1.50
rhs
(60+10M)/3
2.33
6.67
3.33
rhs
(60+10M)/3
2.33
6.67
5.00
rhs
25.00
2.33
6.67
5.00
rhs
25.00
0.25
6.67
5.00
rhs
25.00
0.25
5.00
5.00
ratio
5.60
20.00
5.00
ero
(Row 3)*(3/2)
ero
Row 0 + (3-2M)*(Row 3)/3
ero
Row 1 - (5/12)*Row 3)
ero
Row 2 -(1/3)*Row 3
Optimal Solution: z = 25, x1 = 5, x2 =5
L. Ntaimo (c) 2005 INEN420 TAMU
27
4.12 The Big M Method
The Bevco example continued (Using Method 2 for Min LP):
Initial Tableau
Row
0
1
2
3
z
1
0
0
0
Second Tableau
z
Row
1
0
0
1
0
2
0
3
x1
2M-2
0.5
1
1
x2
4M-3
0.25
3
1
s1
0
1
0
0
e2
-M
0
-1
0
a2
0
0
1
0
a3
0
0
0
1
RHS
30M
4
20
10
x1
(2M-3)/3
5/12
1/3
2/3
x2
0
0
1
0
s1
0
1
0
0
e2
(M-3)/3
1/12
-1/3
1/3
a2
(3-4M)/3
-1/12
1/3
-1/3
a3
0
0
0
1
RHS
(60+10M)/3
7/3
20/3
10/3
x2
0
0
1
0
s1
0
1
0
0
e2
-1/2
-1/8
-1/2
1/2
a2
(1-2M)/2
1/8
1/2
-1/2
a3
(3-2M)/2
-5/8
-1/2
3/2
RHS
25
1/4
5
5
Third (Optimal) Tableau
z
Row
1
0
0
1
0
2
0
3
x1
0
0
0
1
BV
z=
s1 =
a2 =
a3 =
MRT
30M
4
20
10
16
6.67*
10
MRT
BV
z = (60+10M)/3
s1 =
7/3
5.6
x2 =
20/3
20
a3 =
10/3
5*
BV
z=
s1 =
x2 =
x1 =
MRT
25
1/4
5
5
Optimal Solution: z = 25, x1 = 5, x2 =5
L. Ntaimo (c) 2005 INEN420 TAMU
28
4.12 The Big M Method
Issues with the Big M Method
1) It is difficult to determine how large M should be
Generally chosen to be at least 100 times the largest
coefficient in the objective function.
2) Introduction of such large numbers cause round off errors and other
computational difficulties (numerical instability). Read section on
Scaling of LPs on page 167.
This motivates the need for yet another method!
L. Ntaimo (c) 2005 INEN420 TAMU
29
4.12 The Big M Method
Problem (10 pts). Get with your team and solve the following LP using
the Big M method :
Min
s.t.
z = 3 x1
− 2 x1 − x2 ≤ −6
x1 + 2 x2 = 3
x1 , x2 ≥ 0
L. Ntaimo (c) 2005 INEN420 TAMU
30
4.12 The Big M Method
Solution to Problem (10 pts):
LP is standard form:
Min z = 3x1
s.t.
2 x1 + x2 − e1 = 6
x1 + 2 x2
=3
x1 , x2 , e1 ≥ 0
Big M Formulation:
Min z = 3x1 + Ma1 + Ma2
s.t.
2 x1 + x2 − e1 + a1
x1 + 2 x2
=6
+ a2 = 3
x1 , x2 , e1 , a1 , a2 ≥ 0
L. Ntaimo (c) 2005 INEN420 TAMU
31
4.12 The Big M Method
Eliminate a1 and a2 from row 0. Simply set new Row 0 to Row 0 + M(Row 2) + M(Row 3):
z -
3x1
M(
2x1 +
+ M(
x1 +
- Ma1 - Ma2 = 0
x2 - e1 +
2x2
z + (3M-3)x1 + (3M)x2 – Me1
a1
= 6)
+
a2 = 3)
= 9M
L. Ntaimo (c) 2005 INEN420 TAMU
32
4.12 The Big M Method
Using Method 2 of the simplex algorithm for min LPs:
2 pts
3 pts
3 pts
Initial Tableau
Row
0
1
2
z
1
0
0
Second Tableau
z
Row
1
0
0
1
0
2
x1
3M-3
2
1
x2
3M
1
2
e1
-M
-1
0
a1
0
1
0
a2
0
0
1
RHS
9M
6
3
x1
(3M-6)/2
1.5
0.5
x2
0
0
1
e1
-M
-1
0
a1
0
1
0
a2
-3/2M
-1
0.5
RHS
4.5M
4.5
1.5
BV
z=
a1 =
x2 =
4.5M
4.5
1.5
x2
0
0
1
e1
-2
-2/3
0.5
a1
2-M
2/3
-0.5
a2
-(4+M)/2
-2/3
1
RHS
9
3
0
BV
z=
x1 =
x2 =
9
3
0
Third (Optimal) Tableau
z
Row
1
0
0
1
0
2
x1
0
1
0
Optimal Solution: z = 9, x1 = 3, x2 = 0
L. Ntaimo (c) 2005 INEN420 TAMU
BV
z=
a1 =
a2 =
MRT
9M
6
3
6
3/2*
MRT
3*
3
MRT
2 pts
33
The Two-Phase Simplex Method
L. Ntaimo (c) 2005 INEN420 TAMU
34
4.13 The Two-Phase Simplex Method
•
When an initial basic feasible solution is not available, the twophase simplex method can be used as an alternative to the Big
M method.
•
In this method we can add artificial variables, and then focus
entirely on obtaining an initial basic feasible solution, any basic
feasible solution (This is called Phase I).
•
We can then start the simplex algorithm with the basic feasible
solution we have found (This is called Phase II)
L. Ntaimo (c) 2005 INEN420 TAMU
35
4.13 The Two-Phase Simplex Method
•
Observe that if all we want is a basic feasible solution, then we
can select any objective function.
•
Once we find a basic feasible solution, we can reconsider the
original cost coefficients.
•
Also note that it is easy to bring cost coefficients into canonical
form.
•
It is desirable to choose an objective function such that solving
the Phase I LP will force the artificial variables to be zero.
•
Minimize the sum of artificial variables!
L. Ntaimo (c) 2005 INEN420 TAMU
36
4.13 The Two-Phase Simplex Method
Consider solving the Bevco problem using the two-phase simplex
method:
Decision variables:
x1 = number of ounces of orange soda in a bottle of Oranj
x2 = number of ounces of orange juice in a bottle of Oranj
LP:
Min
s.t.
z = 2x1 +
3x2
0.5x1 + 0.25x2 ≤ 4
x1 +
3x2 ≥ 20
x1 +
x2 = 10
(sugar constraint)
(vitamin C constraint)
(10 oz in 1 bottle of Oranj)
x1, x2 ≥ 0
L. Ntaimo (c) 2005 INEN420 TAMU
37
4.13 The Two-Phase Simplex Method
The LP in standard:
Min z = 2x1 +
s.t.
3x2
0.5x1 + 0.25x2 + s1
= 4
x1 +
3x2
- e2 = 20
x1 +
x2
= 10
x1, x2, s1, e2 ≥ 0
Note again that the LP in standard form has z and s1 which could be
used for BVs but row 2 would violate sign restrictions and row 3 has
no readily apparent basic variable.
L. Ntaimo (c) 2005 INEN420 TAMU
38
4.13 The Two-Phase Simplex Method
Adding artificial variables we get the following:
Min z = 2x1 +
s.t.
3x2
0.5x1 + 0.25x2 + s1
x1 +
3x2
x1 +
x2
= 4
- e2 + a2
= 20
+ a3 = 10
x1, x2, s1, e2, a2, a3 ≥ 0
Then the Phase I LP is:
Min w’ =
s.t.
a2 + a3
0.5x1 + 0.25x2 + s1
x1 +
3x2
x1 +
x2
= 4
- e2 + a2
= 20
+ a3 = 10
x1, x2, s1, e2, a2, a3 ≥ 0
L. Ntaimo (c) 2005 INEN420 TAMU
39
4.13 The Two-Phase Simplex Method
Note that row 0 for this tableau contains the basic variables a2 and a3:
Row 0: w’
Row 1:
- a 2 - a3
0.5x1 + 0.25x2 + s1
Row 2:
x1 +
3x2
Row 3:
x1 +
x2
=0
= 4
- e2 + a2
= 20
+ a3 = 10
As in the Big M method, we need to eliminate a2 and a3 from row 0 to
get a canonical form.
Simply add Row 2+ Row 3 to Row 0:
- a 2 - a3 = 0
w’
x1 + 3x2 - e2 + a2
+
x1 + x2
w’ + 2x1 + 4x2 – e2
= 20
+ a3 = 10
= 30
L. Ntaimo (c) 2005 INEN420 TAMU
40
4.13 The Two-Phase Simplex Method
Description of the Two-Phase Simplex Method
1. Modify the constraints so that the rhs of each constraint is nonnegative.
Identify each constraint that is now an = or ≥ constraint.
2. Convert each inequality constraint to standard form (add a slack variable
for ≤ constraints, add an excess variable for ≥ constraints).
3. For each ≥ or = constraint, add artificial variables. Add sign restriction ai ≥
0.
4. For now, ignore the original LP’s objective function. Instead solve an LP
whose objective function is min w’ = (sum of all artificial variables). This is
the Phase I LP. Solving the Phase I LP will force the artificial variables to
be zero.
L. Ntaimo (c) 2005 INEN420 TAMU
41
4.13 The Two-Phase Simplex Method
Description of the Two-Phase Simplex Method cont…
Since each ai ≥ 0, solving the Phase I LP will result in one of the following three
cases:
Case 1: The optimal value of w’ &gt; 0. In this case the original LP is infeasible.
Case 2: The optimal value of w’ = 0 and no artificial variables are in the optimal Phase I
basis. Drop all columns in the optimal Phase I tableau that correspond to the artificial
variables. In this case, combine the original objective function with the constraints
from the optimal Phase I tableau. This yields the Phase II LP. The optimal solution to
the Phase II LP is the optimal solution to the original LP.
Case 3: The optimal value of w’ = 0 and at least one artificial variable is in the optimal
Phase I basis. In this case, we can find the optimal solution to the original LP if at the
end of Phase I we drop from the optimal Phase I tableau all nonbasic artificial
variables and any variable from the original problem that has a negative coefficient in
row 0 of the optimal Phase I tableau.
L. Ntaimo (c) 2005 INEN420 TAMU
42
4.13 The Two-Phase Simplex Method
The Bevco example continued (Using Method 2 for Min LP):
Initial Phase I Tableau
w'
Row
0
1
1
0
2
0
3
0
x1
2
0.5
1
1
x2
4
0.25
3
1
s1
0
1
0
0
e2
-1
0
-1
0
a2
0
0
1
0
a3
0
0
0
1
RHS
30
4
20
10
BV
w' =
s1 =
a2 =
a3 =
Second Phase I Tableau
w'
x1
Row
1
2/3
0
0
5/12
1
0
1/3
2
0
2/3
3
x2
0
0
1
0
s1
0
1
0
0
e2
1/3
1/12
-1/3
1/3
a2
-4/3
-1/12
1/3
-1/3
a3
0
0
0
1
RHS
10/3
7/3
20/3
10/3
BV
w' =
s1 =
x2 =
a3 =
Third (Optimal) Phase I Tableau
w'
x1
Row
1
0
0
0
0
1
0
0
2
0
1
3
x2
0
0
1
0
s1
0
1
0
0
e2
0
-1/8
-1/2
1/2
a2
-1
1/8
1/2
-1/2
a3
-1
-5/8
-1/2
3/2
RHS
0
1/4
5
5
BV
w' =
s1 =
x2 =
x1 =
MRT
30
4
20
10
16
6.67*
10
MRT
10/3
7/3
20/3
10/3
28/5
20.00
5*
MRT
0
1/4
5
5
We will now drop columns a2 and a3.
L. Ntaimo (c) 2005 INEN420 TAMU
43
4.13 The Two-Phase Simplex Method
We begin Phase II with the following set of equations:
Row 0: z - 2x1 – 3x2
=0
s1 - 1/8e2 = 1/4
Row 1:
Row 2:
x2
Row 3:
- 1/2e2 = 5
+ 1/2e2 = 5
x1
We need to eliminate x1 and x2 from row 0 to get a canonical form.
Add 3(Row 2) + 2(Row 3) to Row 0:
z - 2x1 – 3x2
3(
x2
+ 2(
x1
z
=0
- 1/2e2 = 5)
+ 1/2e2 = 5)
- 1/2e2 = 25
L. Ntaimo (c) 2005 INEN420 TAMU
44
4.13 The Two-Phase Simplex Method
Initial (Optimal) Phase II Tableau
z
x1
Row
1
0
0
0
0
1
0
0
2
0
1
3
x2
0
0
1
0
s1
0
1
0
0
e2
-1/2
-1/8
-1/2
1/2
RHS
0
1/4
5
5
BV
MRT
z = 25
s1 = 1/4
x2 = 5
x1 = 5
In this case Phase II requires no pivots to find an optimal solution. If the Phase II
row 0 does not indicate an optimal tableau, then simply continue with the simplex
until an optimal row 0 is obtained.
The optimal Phase II tableau shows that the optimal solution to the Bevco problem
is:
Optimal Solution: z = 25, x1 = 5, x2 = 5
Note that we obtained the same solution using the Big M Method.
L. Ntaimo (c) 2005 INEN420 TAMU
45
4.13 The Two-Phase Simplex Method
•
For examples of Case 1 and Case 3 of the two-phase simplex
method read Example 6 and 7 of Chapter 4.
•
Important note: Example 7 should be a max problem and not a
min problem!
L. Ntaimo (c) 2005 INEN420 TAMU
46
4.13 The Two-Phase Simplex Method
Problem (10 pts). Get with your team and solve the following LP using
the two-phase simplex method :
Min
s.t.
z = 3 x1
− 2 x1 − x2 ≤ −6
x1 + 2 x2 = 3
x1 , x2 ≥ 0
L. Ntaimo (c) 2005 INEN420 TAMU
47
4.13 The Two-Phase Simplex Method
Solution to Problem (10 pts):
Maintaining nonegative RHS:
Min z = 3 x1
s.t.
2 x1 + x2 ≥ 6
x1 + 2 x2 = 3
x1 , x2 ≥ 0
LP is standard form:
Min z = 3 x1
s.t.
2 x1 + x2 − e1 = 6
x1 + 2 x2
=3
x1 , x2 ≥ 0
Phase I Formulation:
Min w' =
s.t.
a1 + a2
2 x1 + x2 − e1 + a1
x1 + 2 x2
=6
+ a2 = 3
x1 , x2 ≥ 0
L. Ntaimo (c) 2005 INEN420 TAMU
48
4.13 The Two-Phase Simplex Method
Eliminate a1 and a2 from row 0. Add Row 2 + Row 3 to Row 0:
w’
- a 1 - a2 = 0
2x1 + x2 - e1 + a1
+
x1 + 2x2
w’ + 3x1 + 3x2 - e1
=6
+ a2 = 3
=9
L. Ntaimo (c) 2005 INEN420 TAMU
49
4.13 The Two-Phase Simplex Method
Using Method 2 of the simplex algorithm for min LPs:
2 pts
Initial Phase I Tableau
w'
Row
1
0
0
1
0
2
x1
3
2
1
x2
3
1
2
e1
-1
-1
0
a1
0
1
0
a2
0
0
1
RHS
9
6
3
BV
w' =
a1 =
a2 =
2 pts
Second Phase I Tableau
w'
Row
1
0
0
1
0
2
x1
0
1
0
x2
3/2
1/2
3/2
e1
1/2
-1/2
1/2
a1
-3/2
1/2
-1/2
a2
0
0
1
RHS
0
3
0
BV
w' =
x1 =
a2 =
x2
0
0
1
e1
0
-5/6
1/3
a1
-1/2
7/12
-1/6
a2
-1
-1/3
2/3
RHS
0
3
0
BV
w' =
x1 =
x2 =
Third (Optimal) Phase I Tableau
w'
x1
Row
1
0
0
2 pts
0
1
1
0
0
2
MRT
9
6
3
3*
3
MRT
0
3
0
6
0*
MRT
0
3
0
We will now drop columns a1 and a2.
L. Ntaimo (c) 2005 INEN420 TAMU
50
4.13 The Two-Phase Simplex Method
We begin Phase II with the following set of equations:
Row 0: z - 3x1
Row 1:
x1
Row 2:
=0
- 5/6e1 = 3
x2 + 1/3e2 = 0
We need to eliminate x1 from row 0 to get a canonical form.
Add 3(Row 1) to Row 0:
=0
z - 3x1
+ 3(
x1 - 5/6e1 = 3)
z
- 5/2e1 = 9
L. Ntaimo (c) 2005 INEN420 TAMU
51
4.13 The Two-Phase Simplex Method
2 pts
Initial Phase II Tableau
z
x1
Row
0
1
0
1
0
1
2
0
0
x2
0
0
1
e1
-5/2
-5/6
1/3
RHS
0
3
0
BV
z=
x1 =
x2 =
MRT
9
3
0
In this case Phase II requires no pivots to find an optimal solution. If the Phase II
row 0 does not indicate an optimal tableau, then simply continue with the simplex
until an optimal row 0 is obtained.
The optimal Phase II tableau shows that the optimal solution to the problem is:
Optimal Solution: z = 9, x1 = 3, x2 = 0
2 pts
Note that we obtained the same solution using the Big M Method.
L. Ntaimo (c) 2005 INEN420 TAMU
52
4.13 The Two-Phase Simplex Method
Summary
•
To get started with the simplex method, add an artificial basis,
but ensure that the artificial variables do not occur in an
optimal solution.
•
Big M method: place a large cost (penalty) on each of the
artificial variables
•
Two-phase method: In phase I minimize the sum of the
artificial variables. At the end of phase I, we will have a basic
feasible solution to the original problem. Use this as a starting
point for Phase II, which solves the original problem.
L. Ntaimo (c) 2005 INEN420 TAMU
53
```