Simplex Method MSci331—Week 3~4 1 Simplex Algorithm • Consider the following LP, solve using Simplex: MAX Z 3x1 2 x2 s.t. 2 x1 x2 100 x1 x2 80 x1 x2 40 x1 , x2 0 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 Z 1 - X1 -3 2 1 X2 -2 1 1 S1 0 1 0 S2 0 0 1 S3 0 0 0 RHS 0 100 80 Row 3 - 1 0 0 0 1 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 Pivot cell Z 1 X1 -3 X2 -2 S1 0 S2 0 S3 0 RHS 0 Ratio -- - 2 1 1 1 1 0 1 0 0 0 1 0 0 0 1 100 80 40 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 x1=20, x2=60 The optimal value is Z=180 The BFS at optimality x1=20, x2=60, s3=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 RHS 100 ----- x1 -3 x2 -3 s1 0 s2 0 s3 0 s4 0 1 1 2 1 2 -3 1 0 0 0 1 0 0 0 1 0 0 0 4 6 2 -1 2 0 0 0 1 4 11 Class activity Make this coefficient equal 1 and pivot all other rows relative to it Z 1 x1 -3 x2 -3 s1 0 s2 0 s3 0 s4 0 1 1 2 1 2 -3 1 0 0 0 1 0 0 0 1 0 0 0 -1 2 0 0 0 1 RHS 100 ----4/1 4 6 2 6/1 4 --- 2/2* 12 Class activity Z 1 RHS 103 100 ----- x1 0 -3 x2 -7.5 -3 s1 00 s2 00 s3 3/2 0 s4 00 10 10 1 2.5 1 00 11 0 -1/2 0 1/2 00 00 0 34 -3/2 11 00 0 0 -1 1/2 2 00 00 1/2 0 11 54 3.5 2 -1/2 0 56 1 13 Class activity Make this coefficient equal 1 and pivot all other rows relative to it Z 1 x1 0 -3 x2 -7.5 -3 s1 00 s2 00 s3 3/2 0 s4 00 10 10 1 2.5 1 00 11 0 -1/2 0 -3/2 11 00 0 1/2 00 00 0 0 -1 1/2 2 00 00 1/2 0 11 3.5 2 -1/2 0 RHS 103 100 ----3/2.5* 34 56 5/3.5 1 --- 54 5/0.5 14 Class activity Z 1 x1 x2 s1 s2 s3 s4 RHS 0 -7.5 0 03 0 3/2 0 0 103 112 0 1 2/5 0 -1/5 0 6/5 0 3.5 0 -1.4 0 11 -1/2 1/5 00 0.8 5 1 -3/2 0 0 3/5 0 1/2 0.8 00 1 2.8 0 0 1/2 -1/5 0 0 0.6 1/2 11 4.4 5 ----- 15 Example: LP model with Minimization Objective • • Solve the following LP model: Min z 2 x1 3 x2 MAX z 2 x1 3x2 s.t. s.t. x1 x2 4 x1 x2 4 x1 x2 6 x1 x2 6 x1 , x2 0 x1 , x2 0 Initial Tableau Row 0 1 2 Basic Variable s1 s2 Z x1 x2 s1 s2 RHS -1 0 0 2 1 1 -3 1 -1 0 1 0 0 0 1 0 4 6 Ratio test 16 Example: LP model with Minimization Objective • Iteration 0 Row Basic Variable 0 1 2 s1 s2 Z x1 x2 s1 s2 RHS -1 0 0 2 1 1 -3 1 -1 0 1 0 0 0 1 0 4 6 Z x1 x2 s1 s2 RHS -1 0 0 5 1 2 0 1 0 3 1 1 0 0 1 12 4 10 Ratio test 4 - • Iteration 1 Row Basic Variable 0 1 2 • Optimality test: x2 s2 Ratio test z 12 5x1 3s1 17 > Constraint x2 Max 40 Z 2 x1 3 x2 s.t. x1 x2 35 5 30 x1 3 x2 35 25 x1 Constraint 1 3.5 x1 5 x2 35 20 Constraint 3 15 20 20 xx11,,xx22 00 Z 10 Constraint 2 5 5 Constraint 4 10 15 20 25 30 New feasible region 35 40 x1 18 Equality Constraint x2 Max s.t. 40 35 30 25 Constraint 1 Z 2 x11 3 x22 x1 x22 x1 3 x22 5 35 x1 20 20 20 Constraint 3 15 xx11,,xx22 00 Z 10 Constraint 2 5 5 10 15 20 25 30 New feasible region 35 40 x1 19 The Problem of Finding an Initial Feasible BV An LP Model Max Z 2 x1 3x2 4 x3 s.t. x1 x2 x3 30 2 x1 x2 3x3 60 x1 x2 2 x3 20 x1, x2 , x3 0 Standard Form Max Z 2 x1 3x2 4 x3 0s1 0e2 s.t. x1 x2 x3 s1 30 2 x1 x2 3x3 e2 60 x1 x2 2 x3 20 x1, x2 , x3, s1, e2 0 Cannot find an initial basic variable that is feasible. 20 Example: Solve Using the Big M Method MAX 3 x1 x2 y1 z s.t. x1 x2 y1 5 z 25 3 x1 3 x2 4 y1 2 z 12 x1 x2 y1 z 0 x1 , x2 , y1 , z 0 MAX s.t. 3x1 x2 x1 x2 3x1 3x2 x1 x2 x1 , x2 , Write in standard form y1 z y1 5 z s1 4 y1 2 z y1 z e3 y1 , z, s1 , e3 25 12 0 0 21 Example: Solve Using the Big M Method MAX s.t. 3x1 x2 x1 x2 3x1 3x2 x1 x2 x1 , x2 , y1 z y1 5 z s1 4 y1 2 z y1 z e3 y1 , z, s1 , e3 25 12 0 0 Adding artificial variables MAX s.t. 3x1 x2 x1 x2 3x1 3x2 x1 x2 x1 , x2 , y1 z 0s1 0e3 y1 5 z s1 4 y1 2 z y1 z e3 y1 , z, s1 , e3 , Ma2 Ma3 a2 a2 , 25 12 a3 0 a3 0 22 Example: Solve Using the Big M Method 3x1 x2 x1 x2 3x1 3x2 x1 x2 x1 , x2 , MAX s.t. y1 z 0s1 0e3 y1 5 z s1 4 y1 2 z y1 z e3 y1 , z, s1 , e3 , Ma2 Ma3 25 12 a3 0 a3 0 a2 a2 , Put in tableau form W x1 x2 Coefficient of y1 s1 z 0 1 -3 1 1 1 0 M 0 M 0 s1 1 0 1 -1 1 5 1 0 0 0 25 a2 2 0 3 -3 -4 2 0 1 0 0 12 a3 3 0 1 -1 -1 -1 0 0 -1 1 0 Basic Row/Eq. no. RHS a2 e3 a3 MRT 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 W x1 x2 Coefficient of y1 s1 z 0 1 -3 1 1 1 0 M 0 M 0 s1 1 0 1 -1 1 5 1 0 0 0 25 a2 2 0 3 -3 -4 2 0 1 0 0 12 a3 3 0 1 -1 -1 -1 0 0 -1 1 0 Basic Basic Row/Eq. no. Row/Eq. no. RHS a2 e3 a3 Coefficient of y1 z RHS s1 a2 e3 a3 M 0 -12M 25 W x1 x2 0 1 -3-3M 1+3M 1+4M 1-2M 0 0 s1 1 0 1 -1 1 5 1 0 0 0 a2 2 0 3 -3 -4 2 0 1 0 0 12 a3 3 0 1 -1 -1 -1 0 0 -1 1 0 MRT 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. Coefficient of y1 z RHS s1 a2 e3 a3 M 0 -12M 25 W x1 x2 0 1 -3-3M 1+3M 1+4M 1-2M 0 0 s1 1 0 1 -1 1 5 1 0 0 0 a2 2 0 3 -3 -4 2 0 1 0 0 12 a3 3 0 1 -1 -1 -1 0 0 -1 1 0 Basic Row/Eq. no. Coefficient of y1 z RHS s1 a2 e3 a3 0 0 -12M 25 W x1 x2 0 1 -3-4M 1+4M 1+5M 1-M 0 0 s1 1 0 1 -1 1 5 1 0 M 0 a2 2 0 3 -3 -4 2 0 1 0 0 12 a3 3 0 1 -1 -1 -1 0 0 -1 1 0 MRT 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. Coefficient of y1 z RHS s1 a2 e3 a3 0 0 -12M 25 W x1 x2 0 1 -3-4M 1+4M 1+5M 1-M 0 0 s1 1 0 1 -1 1 5 1 0 M 0 a2 2 0 3 -3 -4 2 0 1 0 0 12 a3 3 0 1 -1 -1 -1 0 0 -1 1 0 MRT The initial Tableau Basic Row/Eq. no. Coefficient of y1 z RHS MRT s1 a2 e3 a3 0 0 -12M 25 25 W x1 x2 0 1 -3-4M 1+4M 1+5M 1-M 0 0 s1 1 0 1 -1 1 5 1 0 M 0 a2 2 0 3 -3 -4 2 0 1 0 0 12 4 a3 3 0 1 -1 -1 -1 0 0 -1 1 0 0 26 Example: Solve Using the Big M Method Using EROs change the column of x1 into a unity vector. Basic Row/Eq. no. Coefficient of y1 z RHS MRT s1 a2 e3 a3 0 0 -12M 25 25 W x1 x2 0 1 -3-4M 1+4M 1+5M 1-M 0 0 s1 1 0 1 -1 1 5 1 0 M 0 a2 2 0 3 -3 -4 2 0 1 0 0 12 4 a3 3 0 1 -1 -1 -1 0 0 -1 1 0 0 Iteration 1 Basic Row/Eq. no. Coefficient of s1 z W x1 x2 y1 0 1 0 -2 -2+M -2-5M s1 1 0 0 0 2 a2 2 0 0 0 x1 3 0 1 -1 RHS MRT a2 e3 a3 0 0 -3-3M -3+4M -12M 7 1 0 1 -1 25 3.57 -1 5 0 1 3 -3 12 2.4 -1 -1 0 0 -1 1 0 -27 Example: Solve Using the Big M Method Using EROs change the column of z into a unity vector. Basic Row/Eq. no. Coefficient of s1 z W x1 x2 y1 0 1 0 -2 -2+M -2-5M s1 1 0 0 0 2 a2 2 0 0 0 x1 3 0 1 -1 RHS MRT a2 e3 a3 0 0 -3-3M -3+4M -12M 7 1 0 1 -1 25 3.57 -1 5 0 1 3 -3 12 2.4 -1 -1 0 0 -1 1 0 -- Iteration 2 Basic s1 z x1 Row/Eq. no. Coefficient of s1 a2 z W x1 x2 y1 0 1 0 -2 -12/5 0 0 1 2 3 0 0 0 0 0 1 0 0 -1 17/5 -1/5 -6/5 0 1 0 1 0 0 RHS e3 a3 (2+5M)/5 -9/5 (-21/5)+M 4.8 -7/5 1/5 1/5 -16/5 3/5 --2/5 16/5 -3/5 2/5 8.2 2.4 2.4 MRT 2.35 --- Students to try more iterations. The solution is infeasible. See the attached solution. 28 Special case 1: Alternative Optima Max z x1 0.5 x2 s.t. 2 x1 x2 4 x1 2 x2 3 x1 , x2 0 . See Notes on this slide (below) for more information 29 Special case 1: Alternative Optima Max z x1 0.5 x2 s.t. 2 x1 x2 4 x1 2 x2 3 x1 , x2 0 30 Special case 2: Unbounded LPs MAX z 2 x1 x2 s.t. x1 x2 1 x1 2 x2 2 x1, x 2 0 s1 x1 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