Transcript Document

Simplex Method

MSci331—Week 3~4 1

Simplex Algorithm

• Consider the following LP, solve using Simplex:

MAX Z

 , 3

x

1  2

x

1 

x

1  2

x

1   0 2

x

2

x x x

2 2 2    100 80 40 2

Step 1: Preparing the LP LP Model •Is the LP model in normal form?

LP in a standard form •All constraints are “=“ •All RHS >0 •All variables>0 If there are = or > •Add an artificial variables to these constraints Write Row 0 •Move all variables in the objective function equation to LHS. Keep all constants in the RHS •A min problem can be treated as a –MAX problem Obtain an initial BFS •If the original LP is not in normal form apply the Big M method to obtain the initial BFS.

3

Step 2: Express the LP in a tableau form Row 0 Row 1 Row 2 Row 3

Z

1 -

X1

-3 2 1 1

X2

-2 1 1 0

S1

0 1 0 0

S2

0 0 1 0

S3

0 0 0 1

RHS

0 100 80 40

Ratio

- 4

Step 3: Obtain the initial basic feasible solution (if available) a) Set

n

-

m

variables equal to 0 These

n

-

m

variables the NBV b) Check if the remaining

m

variables satisfy the condition of BV = If yes, the initial feasible basic solution (bfs) is readily a available = else, carry on some ERO to obtain the initial bfs Row 0 Row 1 Row 2 Row 3

Z

1 -

X1

-3 2 1 1

X2

-2 1 1 0

S1

0 1 0 0

S2

0 0 1 0

S3

0 0 0 1

RHS

0 100 80 40

Ratio

- 5

Step 4: Apply the Simplex Algorithm a) Is the initial bfs optimal? (Will bringing a NBV improve the value of Z?) b) If yes, which variable from the set of NBV to bring into the set of BV? - The entering NBV defines the pivot column c) Which variable from the set of BV has to become NBV? - The exiting BV defines the pivot row Row 0 Row 1 Row 2 Row 3

Z

1 -

X1

-3 2 1 1

X2

-2 1 1 0

S1

0 1 0 0

S2

0 0 1 0

S3

0 0 0 1

Pivot cell

RHS

0 100 80 40

Ratio

- 100/2 80/1 40/1 6

Summary of Simplex Algorithm for Papa Louis Set: n-m =0 m ≠0 BFS (intial) BFS (1) BFS (2) BFS (3)

1

The optimal solution is

x

1 =20,

x

2 =60 The optimal value is Z=180 The BFS at optimality

x

1 =20,

x

2 =60,

s

3 =20 7

Geometric Interpretation of Simplex Algorithm 8

Class activity

• Consider the following LP: This is a maximizing LP, in normal form. So an initial BFS exists.

9

Class activity

10

Class activity

Z

1

x

1

-3 1 1 2 -1

x

2

-3 1 2 -3 2

s

1

0 1 0 0 0

s

2

0 0 1 0 0

s

3

0 0 0 1 0

s

4

0 0 0 0 1

RHS

100 ---- 4 6 2 4 11

Class activity

Make this coefficient equal 1 and pivot all other rows relative to it

Z

1

x

1

-3 1 1 2 -1

x

2

-3 1 2 -3 2

s

1

0 1 0 0 0

s

2

0 0 1 0 0

s

3

0 0 0 1 0

s

4

0 0 0 0 1

RHS

100 ---- 4 4/1 6 2 4 6/1 2/2* -- 12

Class activity

Z

1

x

1

x

2

s

1

0

1

0

1 -3/2 0

1

s

2

s

3

0 1/2

s

4 RHS

0

3 5

4 6 1

5

4 13

Class activity

Make this coefficient equal 1 and pivot all other rows relative to it

Z

1

x

1

x

2

s

1

0

1

0

1 -3/2 0

1

s

2

s

3

0 1/2

s

4 RHS

0

3 5

4 6 1

5

4 3/2.5* 5/3.5

-- 5/0.5

14

Class activity

Z

1

x

1 0

x

2 1

s

1 2/5

s

2 0

s

3 -1/5

s

4 RHS

-----

0 0 0 0 0 1 1 6/5

15

Example: LP model with Minimization Objective • Solve the following LP model:

Min z

 2

x

1  3

x

2

MAX z

2

x

1  3

x

2 •

x

1 

x

2  4

x

1 

x x

1 , 2

x

2   0 6 Initial Tableau Row 0 1 2 Basic Variable s 1 s 2 Z -1 0 0 x 1 2 1 1 x 2 -3 1 -1 s 1 0 1 0 s 2 0 0 1

x

1 

x

2  4

x

1 

x x

1 , 2

x

2   0 6 0 4 6 16

Example: LP model with Minimization Objective • • Iteration 0 Row Iteration 1 0 1 2 Row 0 1 2 Basic Variable s 1 s 2 Basic Variable x 2 s 2 • Optimality test: Z -1 0 0 Z -1 0 0

z

x 1 2 1 1 x 1 5 1 2 x 2 -3 1 -1 x 2 0 1 0 s 1 0 1 0 s 1 3 1 1   

x

1  3

s

1 s 2 0 0 1 s 2 0 0 1 0 4 6 12 4 10 4 - 17

> Constraint

40

x

2 35 30

s t

25 Constraint 1 20 Constraint 3 15 Z 10 Constraint 2 5 Constraint 4 5 10 15 20 25 30 35 40

x

1 New feasible region 3.5

x

1  5

x

2

x

1 1 , ,

x

2 2   0 0  35 18

Equality Constraint

40

x

2 15 10 5 35 30 25 20

s t

Constraint 1 Constraint 3 Z Constraint 2 5 10 15 20 25 30 35 40

x

1 New feasible region 1 1 , , 2 2   0 0 19

The Problem of Finding an Initial Feasible BV An LP Model Max

Z

 2

x x

1

x

1 2 1 1 ,

x

1 2

x x

, 

x

2 2 2 3 3

x

2 3 2  

x

3

x x

0 3 3 4 

x

3 30   60 20 Standard Form Max

Z

 2 1 2

x

1

x x

1 1

x

1 

x

 

x

2 2 2 3

x

2 2 , 2

x

3 3 

x

3 4

x

3 

x

3 

s

1  0

e

2

s

1    0 30

e

60 2

x s e

1 3 2  0  20 Cannot find an initial basic variable that is feasible. 20

Example: Solve Using the Big M Method MAX 3 3

x x x x

1 1 1 1    

x

2

x

2  

y

1 3

x

2  

y

4

y

1 1

z

 

x

2 

y

1  5

z

2

z z

   25 12 0

x x y z

1 , 2 , 1 ,  0 Write in standard form MAX 3

x

1

x

1 3

x

1

x

1

x

1 , 

x

2   3

x

2 

x

2

x

2

x

2 ,    4

y

1

y

1 

y

1

y

1

y

1 , 

z

 5

z

 2

z

z z

, 

s

1

s

1 , 

e

3

e

3    25  12 0 0 21

Example: Solve Using the Big M Method MAX 3

x

1

x

1 3

x

1

x

1

x

1 , 

x

2 

x

2  3

x

2 

x

2

x

2 ,    4

y

1

y

1 

y

1

y

1

y

1 , 

z

 5

z

 2

z

z z

, 

s

1

s

1 , 

e

3

e

3  25  12  0  0 Adding artificial variables MAX 3

x

1

x

1 3

x

1

x

1

x

1 , 

x

2 

x

2  3

x

2 

x

2

x

2 , 

y

1 

y

1  4

y

1 

y

1

y

1 , 

z

 5

z

 2

z

z z

,  0

s

1 

s

1  0

e

3

s

1 , 

e

3

e

, 3 

Ma

2 

Ma

3 

a

2

a

2 , 

a a

3 3     25 12 0 0 22

Example: Solve Using the Big M Method MAX 3

x

1

x

1 3

x

1

x

1

x

1 , 

x

2 

x

2  3

x

2 

x

2

x

2 ,    4

y

1

y

1 

y

1

y

1

y

1 , 

z

 5

z

 2

z

z z

,  0

s

1 

s

1  0

e

3

s

1 , 

e

3

e

, 3 

Ma

2 

Ma

3  

a

2 

a

3  

a

2 ,

a

3  25 12 0 0 Put in tableau form

Basic Row/Eq. no.

s

1

a

2

a

3 0 1 2 3 W 1 0 0 0

x

1 -3 1 3 1

x

2 1 -1 -3 -1 Coefficient of

y

1

z s

1 1 1 0 1 -4 -1 5 2 -1 1 0 0

a

2 M 0 1 0

e

3 0 0 0 -1

a

3 M 0 0 1 RHS MRT 0 25 12 0 23

Example: Solve Using the Big M Method Eliminating a2 from row 0 by operations: new Row 0 = old Row 0 -M*old Row 2

Basic Row/Eq. no.

s

1

a

2

a

3 0 1 2 3 W 1 0 0 0

x

1 -3 1 3 1

x

2 1 -1 -3 -1 Coefficient of

y

1

z s

1 1 1 0 1 5 1 -4 2 0 -1 -1 0

a

2 M 0 1 0

e

3 0 0 0 -1

a

3 M 0 0 1 RHS MRT 0 25 12 0

Basic Row/Eq. no.

a a s

1 2 3 0 1 2 3 W 1 0 0 0 Coefficient of

x

1

x

2

y

1

z

-3-3M 1+3M 1+4M 1-2M 1 3 -1 -3 1 -4 5 2 1 -1 -1 -1

s

1 0 1 0 0

a

2 0 0 1 0

e

3 0 0 0 -1

a

3 M 0 0 1 RHS -12M 25 12 0 MRT 24

Example: Solve Using the Big M Method Eliminating a3 from the new row 0 by operations: new Row=old Row-M*old Row 3

Basic Row/Eq. no.

a s

1

a

2 3 0 1 2 3 W 1 0 0 0 Coefficient of

x

1

x

2

y

1

z

-3-3M 1+3M 1+4M 1-2M 1 3 -1 -3 1 -4 5 2 1 -1 -1 -1

s

1 0 1 0 0

a

2 0 0 1 0

e

3 0 0 0 -1

a

3 M 0 0 1 RHS -12M 25 12 0 MRT

Basic Row/Eq. no.

s

1

a a

2 3 0 1 2 3 W 1 0 0 0 Coefficient of

x

1

x

2

y

1

z

-3-4M 1+4M 1+5M 1-M 1 3 -1 -3 1 -4 5 2 1 -1 -1 -1

s

1 0 1 0 0

a

2 0 0 1 0

e

3 M 0 0 -1

a

3 0 0 0 1 RHS -12M 25 12 0 MRT 25

Example: Solve Using the Big M Method The initial basic variables are s1=25, a2=12, and a3=0. Now ready to proceed for the simplex algorithm.

Basic Row/Eq. no.

s

1

a

2

a

3 0 1 2 3 W 1 0 0 0

x

1

x

2 Coefficient of

y

1

z

-3-4M 1+4M 1+5M 1-M 1 3 1 -1 -3 -1 1 -4 -1 5 2 -1

s

1 0 1 0 0

a

2 0 0 1 0

e

3 M 0 0 -1

a

3 0 0 0 1 RHS -12M 25 12 0 MRT The initial Tableau

Basic Row/Eq. no.

a

2

a

3

s

1 0 1 2 3 W 1 0 0 0

x

1

x

2 Coefficient of

y

1

z

-3-4M 1+4M 1+5M 1-M 1 -1 1 5 3 1 -3 -1 -4 -1 2 -1

s

1 0 1 0 0

a

2 0 0 1 0

e

3 M 0 0 -1

a

3 0 0 0 1 RHS -12M 25 12 0 MRT 25 4 0 26

Example: Solve Using the Big M Method Using EROs change the column of x1 into a unity vector.

Basic Row/Eq. no.

s

1

a

2

a

3 0 1 2 3 W 1 0 0 0

x

1

x

2 Coefficient of

y

1

z

-3-4M 1+4M 1+5M 1-M 1 -1 1 5 3 1 -3 -1 -4 -1 2 -1

s

1 0 1 0 0

a

2 0 0 1 0

e

3 M 0 0 -1

a

3 0 0 0 1 RHS -12M 25 12 0 MRT 25 4 0 Iteration 1

Basic Row/Eq. no.

s

1

a x

2 1 0 1 2 3 W 1 0 0 0

x

1 0 0 0 1

x

2 -2 0 0 -1

y

1 Coefficient of

z

-2+M -2-5M

s

1 0 2 -1 -1 7 5 -1 1 0 0

a

2 0 0 1 0

e

3

a

3 RHS -3-3M -3+4M -12M 1 -1 25 3 -1 -3 1 12 0 MRT 3.57 2.4 -- 27

Example: Solve Using the Big M Method Using EROs change the column of z into a unity vector.

Basic Row/Eq. no.

s

1

a

2

x

1 0 1 2 3 W 1 0 0 0

x

1 0 0 0 1

x

2 -2 0 0 -1

y

1 Coefficient of

z

-2+M -2-5M

s

1 0 2 -1 -1 7 5 -1 1 0 0

a

2 0 0 1 0

e

3

a

3 RHS -3-3M -3+4M -12M 1 -1 25 3 -1 -3 1 12 0 MRT 3.57 2.4 -- Iteration 2

Basic Row/Eq. no.

s

1

z x

1 0 1 2 3 W 1 0 0 0

x

1 0 0 0 1

x

2 -2 0 0 -1

y

1 -12/5 17/5 -1/5 -6/5 0 1 0

z

Coefficient of

s

1

a

2 0 0 (2+5M)/5 1 0 0 -7/5 1/5 1/5

e

3 -9/5 -16/5 3/5 --2/5

a

3 (-21/5)+M 16/5 -3/5 2/5 RHS MRT 4.8 8.2 2.4 2.4 2.35 -- -- Students to try more iterations. The solution is infeasible. See the attached solution.

28

Special case 1: Alternative Optima

Max z

  1 2

x

1 0.5

x

2 

x

2 

x

1 

x x

1 , 2 2

x

2  0  4 3 .

See Notes on this slide (below) for more information 29

Special case 1: Alternative Optima

Max z

  1 2

x

1 0.5

x

2 

x

2 

x

1 

x x

1 , 2 2

x

2  0  4 3 30

Special case 2: Unbounded LPs

MAX

z

 2

x

1    1

x

2

x

2

x

1  2

x

 2  1  0 2

s 1 x 1 0 1

See Notes on this slide (below) for more information 31

Special Case 3: Degeneracy

32

Special Case 5: Degeneracy

Iteration 0 Iteration 1 Iteration 2 33

Special Case 5: Degeneracy

Degeneracy reveals from practical standpoint that the model has at least one redundant constraint.

34