Chapter 4 The Simplex Algorithm – Part IIise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Chapter...

53
L. Ntaimo (c) 2005 INEN420 TAMU 1 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

Transcript of Chapter 4 The Simplex Algorithm – Part IIise.tamu.edu/INEN420/INEN420_2005Spring/SLIDES/Chapter...

L. Ntaimo (c) 2005 INEN420 TAMU1

Chapter 4The Simplex Algorithm – Part II

Based onIntroduction to Mathematical Programming: Operations Research, Volume 1

4th edition, by Wayne L. Winston and Munirpallam Venkataramanan

Lewis Ntaimo

L. Ntaimo (c) 2005 INEN420 TAMU2

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 TAMU3

Degeneracy and Convergence of the Simplex Algorithm

L. Ntaimo (c) 2005 INEN420 TAMU4

4.11 Convergence of the Simplex Method

0 s.t.

zMax

≥=

=

xbAx

xcTRecall:

Where,

⎥⎥⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢⎢⎢

=

mnmm

n

n

aaa

aaaaaa

A

............

...

...

21

22221

11211

⎥⎥⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢⎢⎢

=

nx

xx

x

.

.

.2

1

⎥⎥⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢⎢⎢

=

nc

cc

c

.

.

.2

1

⎥⎥⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢⎢⎢

=

mb

bb

b

.

.

.2

1

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 TAMU5

4.11 Convergence of the Simplex MethodRecall 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?

!)!(!

mmnn

mn

−=⎟⎟

⎞⎜⎜⎝

Thus an LP can have at most basic solutions!⎟⎟⎠

⎞⎜⎜⎝

⎛mn

L. Ntaimo (c) 2005 INEN420 TAMU6

4.11 Convergence of the Simplex Method

• For n = 20 and m = 10 we have:

?!10)!1020(

!201020

=−

=⎟⎟⎠

⎞⎜⎜⎝

⎛ 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 TAMU7

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 TAMU8

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) < 0 and (value of entering variable in new bfs) >= 0.

Two Facts:(1) If (value of entering variable in new bfs) > 0), then

(z-value for new bfs) > (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 TAMU9

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 TAMU10

4.11 Degeneracy and Convergence of the Simplex Method

Example: Solve the following LP using the simplex tableau method.

0, 0 6 s.t.

25Max

21

21

21

21

≥≤−≤+

+=

xxxxxx

xxz

Converting to standard form:

0,,, 0 6 s.t.

25Max

2121

221

121

21

≥=+−=++

+=

ssxxsxx

sxxxxz

L. Ntaimo (c) 2005 INEN420 TAMU11

4.11 Degeneracy and Convergence of the Simplex MethodExample: Solve using the simplex tableau methodInitial Tableau Solution

Row z x1 x2 s1 s2 RHS BV MRT0 1 -5 -2 0 0 0 z = 0 z = 01 0 1 1 1 0 6 s1 = 6 6 x1 = 02 0 1 -1 0 1 0 s2 = 0 0* x2 = 0

Second TableauRow z x1 x2 s1 s2 RHS BV MRT

0 1 0 -7 0 5 0 z = 0 z = 01 0 0 2 1 -1 6 s1 = 6 3* x1 = 02 0 1 -1 0 1 0 x1 = 0 None x2 = 0

Cycling: We encounter same bfs twice!

Third (Optimal) TableauRow z x1 x2 s1 s2 RHS BV MRT

0 1 0 0 3.5 1.5 21 z = 21 z = 211 0 0 1 0.5 -0.5 3 x2 = 3 x1 = 32 0 1 0 0.5 0.5 3 x1 = 3 x2 = 3

Optimal Solution: z = 21, x1 = 3, x2 =3

L. Ntaimo (c) 2005 INEN420 TAMU12

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 methodThe extreme points of the feasible region are B,C and D. Three sets of basic variables correspond to extreme point C.

021 ≤− xx

621 ≤+ xx

102510

21 =+⇒=xx

z

B

D

AC x1

x2

2 4 6

2

6

4

21=z

BV's BFS Extreme Pointx1, x2 x1 = x2 = 3, s1 = s2 = 0 Dx1, s1 x1 = 0, s1 = 6, x2 = s2 = 0 Cx1, s2 x1 = 6, s2 = -6, x2 = s1 = 0 Infeasiblex2, s1 x2 = 0, s1 = 6, x1 = s2 = 0 Cx2, s2 x2 = 6, s2 = 6, s1 = x1 = 0 Bs1, s2 s1 = 6, s2 = 0, x1 = x2 = 0 C

L. Ntaimo (c) 2005 INEN420 TAMU13

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 TAMU14

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 TAMU15

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 TAMU16

The Big M Method

L. Ntaimo (c) 2005 INEN420 TAMU17

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 TAMU18

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¢ to produce an ounce of orange soda and 3¢ to produce an ounce of orange juice. Bevco’s marketing department has decided that each 10-oz 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 canmeet the marketing department’s requirements at minimum cost.

L. Ntaimo (c) 2005 INEN420 TAMU19

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 z = 2x1 + 3x2

s.t. 0.5x1 + 0.25x2 ≤ 4 (sugar constraint)

x1 + 3x2 ≥ 20 (vitamin C constraint)

x1 + x2 = 10 (10 oz in 1 bottle of Oranj)

x1, x2 ≥ 0

L. Ntaimo (c) 2005 INEN420 TAMU20

4.12 The Big M Method

The LP in standard:

Min z = 2x1 + 3x2

s.t. 0.5x1 + 0.25x2 + s1 = 4

x1 + 3x2 - e2 = 20

x1 + x2 = 10x1, 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 TAMU21

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 aiaccording to the row i in which they are used as follows.

Row 0: z - 2x1 - 3x2

Row 1: 0.5x1 + 0.25x2 + s1 = 4

Row 2: x1 + 3x2 - e2 + a2 = 20

Row 3: x1 + x2 + a3 = 10

L. Ntaimo (c) 2005 INEN420 TAMU22

4.12 The Big M MethodIn 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 + 3x2 + Ma2 + Ma3

s.t. 0.5x1 + 0.25x2 + s1 = 4

x1 + 3x2 - e2 + a2 = 20

x1 + x2 + a3 = 10x1, 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 TAMU23

4.12 The Big M MethodThe rows of the simplex tableau would then be:

Row 0: z - 2x1 - 3x2 - Ma2 - Ma3 = 0Row 1: 0.5x1 + 0.25x2 + s1 = 4Row 2: x1 + 3x2 - e2 + a2 = 20Row 3: x1 + x2 + a3 = 10

But observe that to have canonical form we need to eliminate a2 and a3from row 0! Simply set new Row 0 to Row 0 + M(Row 2) + M(Row 3)

z - 2x1 - 3x2 - Ma2 - Ma3 = 0M( x1 + 3x2 - e2 + a2 = 20)

+ M( x1 + x2 + a3 = 10)z + (2M-2)x1 +(4M-3)x2 – Me2 = 30M

L. Ntaimo (c) 2005 INEN420 TAMU24

4.12 The Big M Method

Description of the Big M Method1. 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 slackvariable 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 TAMU25

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 TAMU26

4.12 The Big M Method

Iteration 1 z x1 x2 s1 e2 a2 a3 rhs ratio ero

0 1.00 2M - 2 4M -3 -M 30M Row 0 + M(Row 2) + M(Row 3)

1 0.50 0.25 1.00 4.00 162 1.00 3 -1.00 1.00 20.00 6.673 1.00 1.00 1.00 10.00 10

ero 1 z x1 x2 s1 e2 a2 a3 rhs ero0 1.00 2M - 2 4M -3 -M 30M 1 0.50 0.25 1.00 4.002 0.33 1 -0.33 0.33 6.67 Row 2 x 1/33 1.00 1.00 1.00 10.00

ero 2 z x1 x2 s1 e2 a2 a3 rhs ero0 1.00 (2M-3)/3 (M-3)/3 (3-4M)/3 (60+10M)/3 Row 0 - (4M-3)*(Row 2)1 0.50 0.25 1.00 4.002 0.33 1 -0.33 0.33 6.673 1.00 1.00 1.00 10.00

ero 3 z x1 x2 s1 e2 a2 a3 rhs ero0 1.00 (2M-3)/3 (M-3)/3 (3-4M)/3 (60+10M)/3 1 0.42 1.00 0.08 -0.08 2.33 Row 1 - 0.25*(Row 2)2 0.33 1 -0.33 0.33 6.673 1.00 1.00 1.00 10.00

ero 4 z x1 x2 s1 e2 a2 a3 rhs ero0 1.00 (2M-3)/3 (M-3)/3 (3-4M)/3 (60+10M)/31 0.42 1.00 0.08 -0.08 2.332 0.33 1 -0.33 0.33 6.673 0.67 0.33 -0.33 1.00 3.33 Row 3 - Row 2

The Bevco example continued (Using Method 2 for Min LP): Details

L. Ntaimo (c) 2005 INEN420 TAMU27

4.12 The Big M MethodIteration

2 z x1 x2 s1 e2 a2 a3 rhs ratio

0 1.00 (2M-3)/3 (M-3)/3 (3-4M)/3 (60+10M)/31 0.42 1.00 0.08 -0.08 2.33 5.602 0.33 1 -0.33 0.33 6.67 20.003 0.67 0.33 -0.33 1.00 3.33 5.00

ero 1 z x1 x2 s1 e2 a2 a3 rhs ero0 1.00 (2M-3)/3 (M-3)/3 (3-4M)/3 (60+10M)/31 0.42 1.00 0.08 -0.08 2.332 0.33 1 -0.33 0.33 6.673 1.00 0.50 -0.50 1.50 5.00 (Row 3)*(3/2)

ero 2 z x1 x2 s1 e2 a2 a3 rhs ero0 1.00 -0.50 (1-2M)/2 (3-2M)/2 25.00 Row 0 + (3-2M)*(Row 3)/31 0.42 1.00 0.08 -0.08 2.332 0.33 1.00 -0.33 0.33 6.673 1.00 0.50 -0.50 1.50 5.00

ero 3 z x1 x2 s1 e2 a2 a3 rhs ero0 1.00 -0.50 (1-2M)/2 (3-2M)/2 25.001 1.00 -0.13 0.13 -0.63 0.25 Row 1 - (5/12)*Row 3)2 0.33 1.00 -0.33 0.33 6.673 1.00 0.50 -0.50 1.50 5.00

ero 4 z x1 x2 s1 e2 a2 a3 rhs ero0 1.00 -0.50 (1-2M)/2 (3-2M)/2 25.001 1.00 -0.13 0.13 -0.63 0.252 1.00 -0.50 0.50 -0.50 5.00 Row 2 -(1/3)*Row 33 1.00 0.50 -0.50 1.50 5.00

Optimal Solution: z = 25, x1 = 5, x2 =5

L. Ntaimo (c) 2005 INEN420 TAMU28

4.12 The Big M MethodThe Bevco example continued (Using Method 2 for Min LP):

Initial TableauRow z x1 x2 s1 e2 a2 a3 RHS BV MRT

0 1 2M-2 4M-3 0 -M 0 0 30M z = 30M1 0 0.5 0.25 1 0 0 0 4 s1 = 4 162 0 1 3 0 -1 1 0 20 a2 = 20 6.67*3 0 1 1 0 0 0 1 10 a3 = 10 10

Second TableauRow z x1 x2 s1 e2 a2 a3 RHS BV MRT

0 1 (2M-3)/3 0 0 (M-3)/3 (3-4M)/3 0 (60+10M)/3 z = (60+10M)/31 0 5/12 0 1 1/12 -1/12 0 7/3 s1 = 7/3 5.62 0 1/3 1 0 -1/3 1/3 0 20/3 x2 = 20/3 203 0 2/3 0 0 1/3 -1/3 1 10/3 a3 = 10/3 5*

Third (Optimal) TableauRow z x1 x2 s1 e2 a2 a3 RHS BV MRT

0 1 0 0 0 -1/2 (1-2M)/2 (3-2M)/2 25 z = 251 0 0 0 1 -1/8 1/8 -5/8 1/4 s1 = 1/42 0 0 1 0 -1/2 1/2 -1/2 5 x2 = 53 0 1 0 0 1/2 -1/2 3/2 5 x1 = 5

Optimal Solution: z = 25, x1 = 5, x2 =5

L. Ntaimo (c) 2005 INEN420 TAMU29

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 TAMU30

4.12 The Big M Method

Problem (10 pts). Get with your team and solve the following LP usingthe Big M method :

0, 32

6 2 s.t.3Min

21

21

21

1

≥=+−≤−−

=

xxxxxx

xz

L. Ntaimo (c) 2005 INEN420 TAMU31

4.12 The Big M MethodSolution to Problem (10 pts):

LP is standard form:

0,, 3 2 6 2 s.t.

3Min

121

21

121

1

≥=+=−+

=

exxxx

exx xz

Big M Formulation:

0,,,, 3 2 6 2 s.t.

3Min

21121

221

1121

211

≥=++=+−+

++=

aaexxaxx

aexx MaMaxz

L. Ntaimo (c) 2005 INEN420 TAMU32

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 - Ma1 - Ma2 = 0M( 2x1 + x2 - e1 + a1 = 6)

+ M( x1 + 2x2 + a2 = 3)z + (3M-3)x1 + (3M)x2 – Me1 = 9M

L. Ntaimo (c) 2005 INEN420 TAMU33

4.12 The Big M MethodUsing Method 2 of the simplex algorithm for min LPs:Initial Tableau

Row z x1 x2 e1 a1 a2 RHS BV MRT0 1 3M-3 3M -M 0 0 9M z = 9M1 0 2 1 -1 1 0 6 a1 = 6 62 0 1 2 0 0 1 3 a2 = 3 3/2*

2 pts

Second TableauRow z x1 x2 e1 a1 a2 RHS BV MRT

0 1 (3M-6)/2 0 -M 0 -3/2M 4.5M z = 4.5M1 0 1.5 0 -1 1 -1 4.5 a1 = 4.5 3*2 0 0.5 1 0 0 0.5 1.5 x2 = 1.5 3

3 pts

Third (Optimal) TableauRow z x1 x2 e1 a1 a2 RHS BV MRT

0 1 0 0 -2 2-M -(4+M)/2 9 z = 91 0 1 0 -2/3 2/3 -2/3 3 x1 = 32 0 0 1 0.5 -0.5 1 0 x2 = 0

3 pts

Optimal Solution: z = 9, x1 = 3, x2 = 0 2 pts

L. Ntaimo (c) 2005 INEN420 TAMU34

The Two-Phase Simplex Method

L. Ntaimo (c) 2005 INEN420 TAMU35

4.13 The Two-Phase Simplex Method

• When an initial basic feasible solution is not available, the two-phase 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 TAMU36

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 TAMU37

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 z = 2x1 + 3x2

s.t. 0.5x1 + 0.25x2 ≤ 4 (sugar constraint)

x1 + 3x2 ≥ 20 (vitamin C constraint)

x1 + x2 = 10 (10 oz in 1 bottle of Oranj)

x1, x2 ≥ 0

L. Ntaimo (c) 2005 INEN420 TAMU38

4.13 The Two-Phase Simplex Method

The LP in standard:

Min z = 2x1 + 3x2

s.t. 0.5x1 + 0.25x2 + s1 = 4

x1 + 3x2 - e2 = 20

x1 + x2 = 10x1, 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 TAMU39

4.13 The Two-Phase Simplex MethodAdding artificial variables we get the following:

Min z = 2x1 + 3x2

s.t. 0.5x1 + 0.25x2 + s1 = 4

x1 + 3x2 - e2 + a2 = 20

x1 + x2 + a3 = 10

x1, x2, s1, e2, a2, a3 ≥ 0

Then the Phase I LP is:

Min w’ = a2 + a3

s.t. 0.5x1 + 0.25x2 + s1 = 4

x1 + 3x2 - e2 + a2 = 20

x1 + x2 + a3 = 10

x1, x2, s1, e2, a2, a3 ≥ 0

L. Ntaimo (c) 2005 INEN420 TAMU40

4.13 The Two-Phase Simplex MethodNote that row 0 for this tableau contains the basic variables a2 and a3:

Row 0: w’ - a2 - a3 = 0Row 1: 0.5x1 + 0.25x2 + s1 = 4Row 2: x1 + 3x2 - e2 + a2 = 20Row 3: x1 + x2 + 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:

w’ - a2 - a3 = 0x1 + 3x2 - e2 + a2 = 20

+ x1 + x2 + a3 = 10w’ + 2x1 + 4x2 – e2 = 30

L. Ntaimo (c) 2005 INEN420 TAMU41

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 TAMU42

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’ > 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 TAMU43

4.13 The Two-Phase Simplex MethodThe Bevco example continued (Using Method 2 for Min LP):

Second Phase I TableauRow w' x1 x2 s1 e2 a2 a3 RHS BV MRT

0 1 2/3 0 0 1/3 -4/3 0 10/3 w' = 10/31 0 5/12 0 1 1/12 -1/12 0 7/3 s1 = 7/3 28/52 0 1/3 1 0 -1/3 1/3 0 20/3 x2 = 20/3 20.003 0 2/3 0 0 1/3 -1/3 1 10/3 a3 = 10/3 5*

Initial Phase I TableauRow w' x1 x2 s1 e2 a2 a3 RHS BV MRT

0 1 2 4 0 -1 0 0 30 w' = 301 0 0.5 0.25 1 0 0 0 4 s1 = 4 162 0 1 3 0 -1 1 0 20 a2 = 20 6.67*3 0 1 1 0 0 0 1 10 a3 = 10 10

Third (Optimal) Phase I TableauRow w' x1 x2 s1 e2 a2 a3 RHS BV MRT

0 1 0 0 0 0 -1 -1 0 w' = 01 0 0 0 1 -1/8 1/8 -5/8 1/4 s1 = 1/42 0 0 1 0 -1/2 1/2 -1/2 5 x2 = 53 0 1 0 0 1/2 -1/2 3/2 5 x1 = 5

We will now drop columns a2 and a3.

L. Ntaimo (c) 2005 INEN420 TAMU44

4.13 The Two-Phase Simplex MethodWe begin Phase II with the following set of equations:

Row 0: z - 2x1 – 3x2 = 0Row 1: s1 - 1/8e2 = 1/4Row 2: x2 - 1/2e2 = 5Row 3: x1 + 1/2e2 = 5

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 = 03( x2 - 1/2e2 = 5)

+ 2( x1 + 1/2e2 = 5)

z - 1/2e2 = 25

L. Ntaimo (c) 2005 INEN420 TAMU45

4.13 The Two-Phase Simplex Method

Initial (Optimal) Phase II TableauRow z x1 x2 s1 e2 RHS BV MRT

0 1 0 0 0 -1/2 0 z = 251 0 0 0 1 -1/8 1/4 s1 = 1/42 0 0 1 0 -1/2 5 x2 = 53 0 1 0 0 1/2 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 TAMU46

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 TAMU47

4.13 The Two-Phase Simplex Method

Problem (10 pts). Get with your team and solve the following LP usingthe two-phase simplex method :

0, 32

6 2 s.t.3Min

21

21

21

1

≥=+−≤−−

=

xxxxxx

xz

L. Ntaimo (c) 2005 INEN420 TAMU48

4.13 The Two-Phase Simplex MethodSolution to Problem (10 pts):

0, 3 2 6 2 s.t.

3Min

21

21

121

1

≥=+=−+

=

xxxx

exx xzLP is standard form:

0, 32 6 2 s.t.

3Min

21

21

21

1

≥=+≥+

=

xxxxxx

xzMaintaining nonegative RHS:

0, 3 2 6 2 s.t.

'Min

21

221

1121

21

≥=++=+−+

+=

xxaxx

aexx aawPhase I Formulation:

L. Ntaimo (c) 2005 INEN420 TAMU49

4.13 The Two-Phase Simplex Method

Eliminate a1 and a2 from row 0. Add Row 2 + Row 3 to Row 0:

w’ - a1 - a2 = 02x1 + x2 - e1 + a1 = 6

+ x1 + 2x2 + a2 = 3w’ + 3x1 + 3x2 - e1 = 9

L. Ntaimo (c) 2005 INEN420 TAMU50

4.13 The Two-Phase Simplex MethodUsing Method 2 of the simplex algorithm for min LPs:

Initial Phase I TableauRow w' x1 x2 e1 a1 a2 RHS BV MRT

0 1 3 3 -1 0 0 9 w' = 91 0 2 1 -1 1 0 6 a1 = 6 3*2 0 1 2 0 0 1 3 a2 = 3 3

2 pts

Second Phase I TableauRow w' x1 x2 e1 a1 a2 RHS BV MRT

0 1 0 3/2 1/2 -3/2 0 0 w' = 01 0 1 1/2 -1/2 1/2 0 3 x1 = 3 62 0 0 3/2 1/2 -1/2 1 0 a2 = 0 0*

2 pts

Third (Optimal) Phase I TableauRow w' x1 x2 e1 a1 a2 RHS BV MRT

0 1 0 0 0 -1/2 -1 0 w' = 01 0 1 0 -5/6 7/12 -1/3 3 x1 = 32 0 0 1 1/3 -1/6 2/3 0 x2 = 0

2 pts

We will now drop columns a1 and a2.

L. Ntaimo (c) 2005 INEN420 TAMU51

4.13 The Two-Phase Simplex MethodWe begin Phase II with the following set of equations:

Row 0: z - 3x1 = 0Row 1: x1 - 5/6e1 = 3Row 2: x2 + 1/3e2 = 0

We need to eliminate x1 from row 0 to get a canonical form.

Add 3(Row 1) to Row 0:

z - 3x1 = 0+ 3( x1 - 5/6e1 = 3)

z - 5/2e1 = 9

L. Ntaimo (c) 2005 INEN420 TAMU52

4.13 The Two-Phase Simplex Method

Initial Phase II TableauRow z x1 x2 e1 RHS BV MRT

0 1 0 0 -5/2 0 z = 91 0 1 0 -5/6 3 x1 = 32 0 0 1 1/3 0 x2 = 0

2 pts

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 TAMU53

4.13 The Two-Phase Simplex MethodSummary

• 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.