1.2 The Simplex Method n The simplex method is an iterative procedure for solving linear programming problems expressed in standard form. The simplex algorithm can be used to solve LPs in which the goal is to maximize the objective function. n n Step 1 Convert the LP to standard form. Step 2 Obtain a bfs (if possible) from the standard form. We will call this bfs the initial bfs. In general, the most recent bfs will be called the current bfs, so at the beginning of the problem, the initial bfs is the current bfs. n n n Step 3 Determine whether the current bfs is optimal. (If it is not, find an adjacent bfs that has a larger zvalue.) Step 4 If the current bfs is not optimal, determine which nonbasic variable should be come a basic variable and which basic variable should become a nonbasic variable to find a bfs with a better objective function value. Step 5 Use EROs to find a new bfs with a better objective function value. Go back to Step 3. n Initialization n Optimality test n If no if yes n iteration n stop 1. Initialization n “≤” constrains n “≥ ” constrains n “= ” constrains “≤” constrains n slack variable max Z =40x1+45x2+24x3 St. 2x1+3x2+x3 ≤100 2 3 1 3 3 2 3x1+3x2+2x3 ≤120 x1 ,x2 ≥0 max Z =40x1+45x2+24x3 S.t. 2x1+3x2+x3 +x4 3x1+3x2+2x3 =100 +x5 =120 x1 ,x2 ,x3 , x4,x5 ≥0 2 3 1 1 0 3 3 2 0 1 “≥ ” constrains n subtracting the excess variable ei from the i th constraint and adding the sign restriction ei ≥ 0. max Z = - 6x1 - 4x2 s.t. 2x1 + x2 ≥2 max Z = - 6x1 - 4x2 s.t. 2x1 + x2 –x3 =2 3x1 +4x2 ≥5 3x1 +4x2 -x4 =5 xj ≥ 0, j=1,2 xj ≥ 0, j=1,2,3,4 “≥ ” constrains max Z = - 6x1 - 4x2 - M x5- M x6 s.t. 2x1 + x2 –x3 3x1 +4x2 +x5 -x4 =2 +x6 =5 artificial variable xj ≥ 0 j=1,2,3,4,5,6 M represents a “very large” positive number (x1,x2, x3,x4, x5,x6)=(0, 0,0,0,2,5) “≥ ” constrains max Z = 10x1 + 8x2 + 7x3 s.t. 2x1 + x2 ≥6 x1 +x2 + x3 ≥4 xj ≥ 0 j=1,2 ,3 max Z = 10x1 + 8x2 + 7x3 - Mx6 s.t. 2x1+x2 x1+x2 + x3 - x4 + x6=6 - x5 xj ≥ 0 j=1,2,3,4,5 =4 “= ” constrains max Z =5x1 +2x2 +3x3 -x4 +x5 s.t. x1 +2x2 +2x3 +x4 3x1+ 4x2 +x3 =8 +x5 =7 xj≥0,i=1,2,…5 n Convert to “≥”and” ≤” 2X1+3X2-4X3=5 2X1+3X2-4X3≤5 2X1+3X2-4X3≥5 1.2.1 Example: Dakota Furniture Company(P134) n The Dakota Furniture company manufactures desks, tables, and chairs. n The manufacture of each type of furniture requires lumber and two types of skilled labor: finishing and carpentry. n The amount of each resource needed to make each type of furniture is given in the table below. Resource Desk Table Chair Lumber 8 board ft 6 board ft 1 board ft Finishing hours 4 hours 2 hours 1.5 hours Carpentry hours 2 hours 1.5 hours 0.5 hours Example – cont’d n n n At present, 48 board feet of lumber, 20 finishing hours, 8 carpentry hours are available. A desk sells for $60, a table for $30, and a chair for $ 20. Dakota believes that demand for desks and chairs is unlimited, but at most 5 tables can be sold. Since the available resources have already been purchased, Dakota wants to maximize total revenue. Example : Solution n n Define: n x1 = number of desks produced n x2 = number of tables produced n x3 = number of chairs produced The LP is: max z = 60x1 + 30x2 + 20x3 s.t. 8x1 + 6x2 + x3 ≤ 48 (lumber constraint) 4x1 + 2x2 + 1.5x3 ≤ 20 (finishing constraint) 2x1 + 1.5x2 + 0.5x3 ≤ 8 (carpentry constraint) x2 ≤ 5 (table demand constraint) x1, x2, x3 ≥ 0 Convert the LP to standard form n n n n Begin the simplex algorithm by converting the constraints of the LP to the standard form. To put the constraints in standard form, simply add slack variables s1, s2, s3, s4, respectively to the four constraints. Label the constraints row 1, row 2, row 3, row 4, and add the sign restrictions si ≥ 0 Then convert the LP’s objective function to the row 0 format. Example : Solution cont’d Basic Variable Canonical Form 0 Row 0 z – 60x1 – 30x2 – 20x3 Row 1 8x1 + 6x2 + Row 2 4x1 + 2x2 + 1.5x 3 Row 3 2x1 + 1.5x 2 + 0.5x 3 Row 4 x2 x 3 + s1 + s2 + s3 + s4 = 0 z= 0 = 48 s1 = 48 = 20 s2 = 20 = 8 s3 = 8 = 5 s4 = 5 Example: Solution cont’d n initial canonical form has: n n n BV = {z, s1, s2, s3, s4} n NBV = {x1, x2, x3} For this initial bfs, z=0, s1=48, s2= 20, s3=8, s4=5, x1=x2=x3=0 A slack variable can be used as a basic variable if the rhs of the constraint is nonnegative. Is the current Basic Feasible Solution Optimal? n if there is any way z can be increased by increasing some nonbasic variable from its current value of zero while holding all other nonbasic variables at their current values of zero. n Solving for z in row 0 yields: z = 60x1 + 30x2 + 20x3 n Observe x1 has the most negative coefficient in row 0 n entering variable Determine the Entering Variable n To keep all the basic variables nonnegative, the largest we can make x1 is min {(48/8)= 6, (20/4) =5, (8/2) =4} = 4, without forcing one of the constraints to be broken. Example : Solution cont’d n Rule for determining how large an entering variable can be. n When entering a variable into the basis, compute the ratio min{ Right − hand side of row Coefficient of entering variable in row } for every constraint in which the entering variable has a positive coefficient. n The constraint with the smallest ratio is called the winner of the ratio test. n The smallest ratio is the largest value of the entering variable that will keep all the current basic variables nonnegative. Pivot in the Entering Variable n To make x1 a basic variable in row 3, we use EROs to make x1 have a coefficient of 1 in row 3 and a coefficient of 0 in all other rows. n n This procedure is called pivoting on row 3; and row 3 is called the pivot row. The final result is that x1 replaces s3 as the basic variable for row 3. The term in the pivot row that involves the entering basic variable is called the pivot term. Example : Solution cont’d The result is: n Canonical Form 1 Row 0 z + 15x2 - Row 1 Row 2 Row 3 Row 4 Basic Variable 5x 3 - - x 3 + s1 x2 + 0.5 x3 x1 + 0.75x2 + 0.25x3 x2 + 30s3 - = 240 = 16 s1 = 16 2 s3 = 4 s2 = 4 + 0.5s3 = 4 x1 = 4 = 5 s4 = 5 + s2 - 4s3 z = 240 + s4 The procedure used to go from one bfs to a better adjacent bfs is called an iteration of the simplex algorithm. Example: Solution cont’d n n Attempt to determine if the current bfs is optimal. Rearranging row 0 from Canonical Form 1, and solving for z yields: z = 240 – 15x2 +5x3 -30s3 Example : Solution cont’d n n n Recall the rule for determining the entering variable is the row 0 coefficient with the greatest negative value. Since x3 is the only variable with a negative coefficient, x3 should be entered into the basis. Performing the ratio test using x3 as the entering variable yields the following results (holding other NBVs to zero): n From row 1, s1 ≥ 0 for all values of x3 since s1 = 16 + x3 n From row 2, s2 ≥ 0 if x3 > 4 / 0.5 = 8 n From row 3, x1 ≥ 0 if x3 >4 / 0.25 = 16 n From row 4, s4 ≥ 0 for all values of x3 since s4 = 5 Example : Solution cont’d So, row 2 becomes the pivot row. The result of using EROs, to make x3 a basic variable in row 2. n n Canonical Form 2 Row 0 Row 1 Row 2 Row 3 Row 4 z Basic Variable + 5x 2 + 10s2 + 10s3 = 280 - 2x 2 + s1 + 2s2 - 8s3 = 24 s1 = 24 - 4s3 = 8 x3 = 8 + 1.5s3 = 2 x1 = 2 = 5 s4 = 5 - 2x 2 + x 1 + 1.25x 2 x2 x3 + 2s2 - 0.5 s2 + s4 z = 280 Example : Solution cont’d n n n In Canonical Form 2: n BV = {z, s1, x3, x1, s4} n NBV = {s3, s2, x2 } n Yielding the bfs z = 280, s1=24, x3=8, x1=2, s4=5, s2=s3=x2=0 Solving for z in row 0 yields: z = 280 - 5x2 - 10s2 -10s3 We can see that increasing x2, s2, or s3 (while holding the other NBVs to zero) will cause the value of z to decrease. Example : Solution cont’d n The solution at the end of iteration 2 is therefore optimal. The following rule can be applied to determine whether a canonical form’s bfs is optimal. n A canonical form is optimal (for a max problem) if each nonbasic variable has a nonnegative coefficient in the canonical form’s row 0. 2. rule applied to determine whether the current bfs is optimal max z = c1 x1 + c2 x2 + ⋅ ⋅ ⋅ + cn xn a11 x1 + a12 x2 + ⋅ ⋅ ⋅ + a1n xn = b1 a x + a x + ⋅ ⋅ ⋅ + a x = b 2n n 2 21 1 22 2 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ a x + a x + ⋅ ⋅ ⋅ + a x = b mn n m m1 1 m 2 2 x1 , x2 ,⋅ ⋅ ⋅, xn ≥ 0 n n maxz= n s.t ∑a x j =1 n j i =1 n n ∑c x xj≥0 ij j j = bi , , j=1,2,…,n i=1,2,…,m n maxz= n ∑c x j i =1 n n n s.t ∑P x j =1 n xj≥0 j j j =b , j=1,2,…,n n x1 x2 n n n n n n n n + a1,m xm + a1,m+1 xm+1 + … + a1,n xn = b1 + a2,m xm + a2,m+1 xm+1 + … + a2,n xn = b2 …… …… xm+ am,m+1 xm+1 + a2,m+1 xm+1 + … + am,n xn = bm x1 ,x2 ,… ,xn ≥ 0 x1 = b1 - a1,m+1 xm+1 - … - a1n xn x2 = b2 -a2 ,m+1 xm+1 - … - a2n xn …… …… xm = bm - am ,m+1 xm+1 - … - amn xn xi = bi − n ∑ a x (i = 1,2,..., m) j = m +1 ij j xi = b i − n ' a ∑ ij x j (i = 1,2,..., m) ' n j = m +1 m z = ∑ c j x j = ∑ ci xi + j =1 i =1 m = ∑ ci b 'i + i =1 n ∑ j = m +1 n ∑c x j = m +1 j j = ... m (c j − ∑ ci a 'ij ) x j i =1 m z j = ∑ ci a 'ij ( j = m + 1,..., n) i =1 m z0 = ∑ ci b 'i i =1 n m σ j = c j − ∑ ci a 'ij = c j − z j ( j = m + 1,..., n) i =1 Theorem 1 P24 z = z0 + n ∑σ j = m +1 j xj xk' = 1 > 0 (m + 1 ≤ k ≤ n) ' x j = 0 (m + 1 ≤ j ≤ n, 且j ≠ k ) ' ' ' = − 1 x b a i ik (i = 1,2,..., m) i m z = z 0 + ( ck − z k ) = z 0 + σ k z k = ∑ ci a 'ik i =1 n Theorem 2 (P24) xk' = λ > 0 (m + 1 ≤ k ≤ n) ' x j = 0 (m + 1 ≤ j ≤ n, 且j ≠ k ) ' ' ' x = b − λ a i ik (i = 1,2,..., m ) i z = z0 + λσ k n Theorem 3 (P24) An unbounded LP occurs in a max problem if there is a nonbasic variable xj with cj-zj≥0 and there is no constraint that limits how large we can make this NBV. 3. Simplex Method in Tableau Form cj cB XB c1 x1 M M M cm M xm cj −zj n c1 L L c m c m +1 L L c n b b1 M M bm x1 L L 1 L L M M 0 L L 0L L x m x m +1 L L x n 0 a1,m+1 L L a1n M M M M M M 1 am,m+1 L L amn 0 σ j = c j − ∑ c i a ij θi θ1 M M θm cj is the coefficients of variables in objective function, CB is the coefficients of the initial basic variables in objective function. Example max z = 60x1 + 30x2 + 20x3 s.t. 8x1 + 6x2 + x3 ≤ 48 4x1 + 2x2 + 1.5x3 ≤ 20 2x1+ 1.5x2 + 0.5x3 ≤ 8 x2 ≤ 5 x1, x2, x3 ≥ 0 n (1) we can convert the LP to the following form to get the initial basic feasible solution X (0) = (0, 0, 0, 48, 20,8,5)T max z = 60x1 + 30x2 + 20x3 s.t. 8x1 + 6x2 + x3 + 4x1 + 2x2 + 1.5x3 + 2x1+ 1.5x2 + 0.5x3 + x2 + x1, x2, x3 , x4, x5, n n x4 = 48 x5 = 20 x6 = 8 x7= 5 x6 ≥ 0 x4 , x5 , x6 , x7 are the basic variables. Then the initial tableau can be obtained as Tableau 1. First tableau for the problem cj 60 30 0 0 0 0 x3 x4 x5 x6 x7 CB XB b x1 0 0 0 0 x4 x5 x6 x7 48 20 8 5 8 6 4 2 [2] 3/2 0 1 1 3/2 1/2 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 60 20 0 0 0 0 cj-zj x2 20 30 θi 6 5 4 - (2) Because all cj-zj≥0, the the initial basic feasible is not the optimal solution, go to the next step; n (3) max(σ 1 , σ 2 , σ 3 ) = max(60,30, 20) = 60 , so x1 is the entering variable, and n bi θ = min( | ai1 > 0) = min(48 / 8, 20 / 4,8 / 2, −) = 4 i ai1 x6 is the leaving Basic Variable and is replaced by x1. In the tableau, the [2] is called pivot element. n (4) Performing a pivot operation on the pivot element, converting P1 to (0 0 1 0)T , x6 is replaced by x1 in XB, and obtain Tableau 2. cj 60 30 20 0 x2 x3 x4 x5 x6 x7 θi 1 0 0 0 -4 -2 1/2 0 8 16 - CB XB b x1 0 0 60 0 x4 x5 x1 x7 16 4 4 5 0 0 1 0 0 -1 3/4 1 -1 [1/2] 1/4 0 0 -15 5 cj-zj 0 0 0 1 0 0 0 0 -30 0 0 0 0 1 0 n From the tableau 2, the new basic feasible solution is X (1) = ( 4,0,0,16,4,0,5) the value of objective function z=240. n (5)Checking all the cj-zj of the Tableau 2, we get c3-z3=5, it means x3 should be entering variable. Doing step(2)~(4), and we can get Tableau 3. Tableau 3 (Optimal Tableau for the problem) cj 60 30 20 0 0 0 0 x6 x7 CB XB b x1 x2 x3 x4 x5 0 20 60 0 x4 x3 x1 x7 24 8 2 5 0 0 1 0 -2 -2 5/4 1 0 1 0 0 1 0 0 0 2 -8 2 -4 1/2 3/2 0 0 0 -5 0 0 -5 cj-zj 0 0 0 1 θi -10 0 (6)In tableau 3, all cj-zj are negative. we can conclude that the larger value of objective function do not exist X * = ( 2,0,8,24,0,0,5) n the optimal solution is n z * = 280 1.2.3 Using the Simplex Algorithm to solve Minimization Problems n n There are two different ways the simplex method can be used to solve minimization problems. Method 1 - Consider this LP: min z = 2x1 – 3x2 s.t. x1 + x2 ≤ 4 x1 – x2 ≤ 6 x1, x2 ≥ 0 The optimal solution is the point (x1,x2) that makes z = 2x1 – 3x2 the smallest. n Equivalently, this point makes max z’=-z = - 2x1 + 3x2 the largest. n n Method 2 - A simple modification of the simplex algorithm can be used to solve min problems directly. n Modify step 3 of the simplex algorithm. n n n If cj-zj≥0 for all nonbasic variables (NBV), the current bfs is optimal. If any nonbasic variable has cj-zj≤0 , choose the variable with the “most negative” cj-zj as the entering variable. This modification of the simplex algorithm works because increasing a nonbasic variable (NBV) with cjzj≤0 will decrease z. 1.2.4 Alternative Optimal Solutions n If there is a nonbasic variable (NBV) with cj-zj=0 of the optimal tableau, the LP has alternative optimal solutions. max z = 40 x1 + 45 x2 + 25 x3 s.t. 2 x1 + 3x2 + x3 ≤ 100 3 x1 + 3x2 + 2 x3 ≤ 120 x j ≥ 0, j = 1,2,3 Optimal Tableau for the problem c j→ 40 45 25 0 0 x4 x5 CB XB b x1 x2 x3 45 40 x2 x1 20 20 0 1 1 0 40 45 25 0 0 0 -5 -10 zj cj-zj -1/3 1 1 -1 5 0 1 10 θi Another Optimal Tableau for the problem c j→ 40 45 25 0 0 x4 x5 CB XB b x1 45 x2 26.67 1/3 1 0 2/3 -1/3 25 x3 20 1 0 1 -1 1 5 10 -5 -10 zj 40 cj-zj 0 x2 x3 45 25 0 0 θi Convex combinations n n If we have two (or more) optimal solutions called two bfs X1 and X2,Then use α X1 + (1- α)X2 to represent the set of optimal solutions. N.B. You must state that 0≤α≤1. 1.2.5 Unbounded LPs n an unbounded LP for a max problem occurs when a nonbasic variable cj with cj-zj≥0 has a non positive coefficient in each constraint. c j→ 1 1 0 0 0 CB XB b x1 x2 x3 x4 x5 0 1 x3 x1 8 2 0 1 -1 -1 1 0 2 1 0 0 0 x5 9 0 -2 0 3 1 zj 1 -1 0 1 0 cj-zj 0 2 0 -1 0 θi 1.2.6 The Big M Method n n If an LP have ≥ or = constraints, however, a starting bfs may not be readily apparent. In such a case, the Big M method may be used to solve the problem. Example 6 min z = −3 x1 + x2 + x3 x1 − 2 x2 + x3 ≤ 11 −4 x + x + 2 x ≥ 3 1 2 3 2 x1 − x3 = −1 x1 , x2 , x3 ≥ 0 n First converting it to the standard form as follows: max z = 3 x1 − x2 − x3 x1 − 2 x2 + x3 + x4 = 11 −4 x + x + 2 x − x = 3 1 2 3 5 −2 x1 + x3 = 1 x1 , x2 , x3 , x4 , x5 ≥ 0 n (6.1) (6.2) (6.3) we add artificial variables x6 and x7 to (6.2) and (6.3) −4 x1 + x2 + 2 x3 − x5 + x6 = 3 −2 x1 + x3 + x7 = 1 x1 , x2 , x3 , x4 , x5 , x6 , x7 ≥ 0 x7 can be written by follows: x6 function the objective max z = 3x1 − x2 − x3 − Mx6 − Mx7 where M is a very large positive number Now, we used simplex method in tableau form to solve it. The initial simplex tableau is the Tableau 6-1. Tableau 6-1 cj 3 -1 -1 0 0 -M -M x5 x6 x7 0 -1 0 0 1 0 0 0 1 -M 0 0 CB XB b x1 x2 x3 x4 0 -M -M x4 x6 x7 11 3 1 1 -4 -2 -2 1 0 1 2 1 1 0 0 cj-zj 3-6M M-1 3M-1 0 θi 11 3/2 1 Tableau 6-2 cj 3 -1 -1 0 0 -M -M x5 x6 x7 -1 -2 1 CB XB b x1 x2 x3 x4 0 -M -1 x4 x6 x3 10 1 1 3 0 -2 -2 1 0 0 0 1 1 0 0 0 -1 0 0 1 0 1 M-1 0 0 -M 0 1-3M cj-zj n Finally, we get Tableau 6-3 which is optimal θi 1 - Tableau 6-3 cj 3 -1 -1 0 0 -M -M x4 x5 x6 CB XB b x1 x2 x3 3 -1 -1 x1 x2 x3 4 1 9 1 0 0 0 1 0 0 0 1 0 0 0 -1/3 -2/3 -1/3 2/3-M cj-zj n n θi x7 1/3 -2/3 2/3 -5/3 0 -1 1 -2 2/3 -4/3 4/3 -7/3 1 - 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. 1.2.7 The two-Phase Method n n This is another approach to handle the artificial variables whenever they are added. Phase1. the objective function is to minimize the sum of all artificial variables.. If the minimum value of the artificial problem is zero, we have a basic feasible solution to the original problem. We then go to Phase2. If at least one of the artificial variables is positive, it means that the original problem without the artificial variables is infeasible, and we terminate. n Phase2. the basic feasible solution found at the end of Phase1 is optimized with respect to the original objective function. Then the simplex method is once again applied to determine the optimal solution. Let us consider Example 6-1 again. n Example 7-1 min w = x6 + x7 x1 − 2 x2 + x3 + x4 = 11 − 4 x + x + 2 x − x + x = 3 1 2 3 5 6 − 2 x1 + x3 + x7 = 1 x1 ,..., x7 ≥ 0 The initial basic feasible solution for the Phase 1 problem is given below: Tableau 7-1 (PHASE 1) cj 0 0 0 0 0 1 1 x5 x6 x7 CB XB b x1 x2 x3 x4 0 1 1 x4 x6 x7 11 3 1 1 -4 -2 -2 1 0 1 2 1 1 0 0 0 -1 0 0 1 0 0 0 1 6 -1 -3 0 1 0 0 cj-zj θi 11 3/2 1 The simplex method is used until we get the final Tableau 7-2. Tableau 7-2 (PHASE 1) cj 0 0 0 0 0 1 1 CB XB b x1 x2 x3 x4 x5 x6 x7 0 0 0 x4 x2 x3 4 1 9 3 0 -2 0 1 0 0 0 1 1 0 0 -2 -1 0 2 1 0 -5 -2 1 0 0 0 0 0 1 1 cj-zj θi We now have an optimal solution to the Phase1 LP, and the artificial variables x6 = 0, x7 = 0 and W=0. We now begin Phase 2 of the simplex method. The initial tableau for Phase 2 is constructed by deleting the column corresponding to the artificial variable, and computing the new last row coefficient with respect to the original objective function, max z = 3x1 − x2 − x3 , as shown below; Tableau 7-3 (PHASE 2) cj 3 -1 -1 0 0 CB XB b x1 x2 x3 x4 x5 0 -1 -1 x4 x2 x3 4 1 9 3 0 -2 0 1 0 0 0 1 1 0 0 -2 -1 0 cj-zj 1 0 0 0 -1 θi 4 - Tableau 7-3 is not optimal, the nonbasic variable x1 replaces the basic variable x4 to increase the value of Z further. Tableau 7-4 (PHASE 2) CB cj XB 3 -1 -1 x1 x2 x3 cj-zj b 4 1 9 3 x1 -1 x2 -1 x3 0 x4 0 x5 1 0 0 0 1 0 0 0 1 1/3 -2/3 0 -1 2/3 -4/3 0 0 0 -1/3 -1/3 θi Z=2 An optimal solution has been reached, and it is given by x1 = 4, x2 = 1, x3 = 9, x4 = 0, x5 = 0, and maximum Z=2. 1.2.8 Degeneracy of the Simplex Algorithm n n n n n An LP is degenerate if it has at least one bfs in which a basic variable is equal to zero. Any bfs that has at least one basic variable equal to zero is a degenerate bfs. unique optimal solution alternative or multiple optimal solution cycling