Chapter 4 The Simplex Algorithm PART 2 Prof. Dr. M. Arslan ÖRNEK 1 2 ISE203/IE251 3 ISE203/IE251 4 ISE203/IE251 5 ISE203/IE251 6 ISE203/IE251 7 ISE203/IE251 8 ISE203/IE251 9 ISE203/IE251 10 ISE203/IE251 11 ISE203/IE251 12 ISE203/IE251 13 ISE203/IE251 14 ISE203/IE251 15 ISE203/IE251 16 ISE203/IE251 17 ISE203/IE251 18 4.6 – The Simplex Algorithm (min LPs) Two different ways the simplex method can be used to solve minimization problems. Method 1 min z = 2x1 – 3x2 max -z = -2x1 + 3x2 s.t. s.t. x1 + x 2 ≤ 4 x1 + x 2 ≤ 4 x1 – x2 ≤ 6 x1 – x2 ≤ 6 x1, x2 ≥ 0 x1, x2 ≥ 0 19 4.6 – The Simplex Algorithm (min LPs) Use –z as the basic variable in row 0. Initial Tableau Row -z 0 1 1 0 2 0 ero1 0 1 2 ero 2 0 1 2 -z 1 0 0 -z 1 0 0 x1 2 1 1 x2 -3 1 -1 s1 0 1 0 s2 0 0 1 rhs 0 4 6 BVs -z=0 s1 =4 s2 = 6 x1 2 1 2 x1 5 1 2 x2 -3 1 0 x2 0 1 0 s1 0 1 1 s1 3 1 1 s2 0 0 1 s2 0 0 1 rhs 0 4 10 rhs 12 4 10 BVs - z = 12 x2 = 4 s2 = 10 20 4.6 – The Simplex Algorithm (min LPs) The optimal solution (to the max problem) is -z = 12, x2 = 4, s2 = 10, x1 = s1 = 0. Then the optimal solution to the min problem is z = -12, x2=4, s2 = 10, x1 = s2 = 0. z = 2x1-3x2 =2(0) – 3 (4) = -12. In summary, multiply the objective function for the min problem by -1 and solve the problem as a maximization problem with the objective function –z. (optimal z-value for the min problem) = - (optimal z-value for the max problem). 21 4.6 – The Simplex Algorithm (min LPs) Method 2 A simple modification of the simplex algorithm can be used to solve min problems directly. Modify Step 3 of the simplex algorithm as follows: If all nonbasic variables (NBV) in row 0 have nonpositive coefficients, the current bfs is optimal. If any nonbasic variable has a positive coefficient, choose the variable with the “most positive” coefficient in row 0 as the entering variable. 22 4.7 – Alternative Optimal solutions If an LP has more than one optimal solution, it has multiple optimal solutions. If all nonbasic variables (NBV) have nonzero coefficients in row 0 of the optimal tableau, the LP has a unique optimal solution. Otherwise, the LP may have alternative optimal solutions. 23 ISE203/IE251 24 25 4.8 – Unbounded LPs An unbounded LP occurs in a max problem if There is a nonbasic variable with a negative coefficient in row 0 and There is no constraint that limits how large we can make this NBV. An unbounded LP for a max problem occurs when a variable with a negative coefficient in row 0 has a nonpositive coefficient in each constraint. 26 ISE203/IE251 27 Example 3: Breadco Bakeries-An Unbounded LP 28 Solution: 29 30 31 4.11 Degeneracy and the Convergence of the Simplex Algorithm Theoretically, the simplex algorithm can fail to find an optimal solution to an LP. The following are facts (for Max LP): – If (value of entering variable in new bfs) > 0, then (z-value for new bfs) > (z-value for current bfs). – If (value of entering variable in new bfs) = 0, then (z-value for new bfs) = (z-value for current bfs). Up to now, we have seen that in each of the LP’s BFS, all basic variables are positive. 32 An LP with this property is a nondegenerate LP. 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. When the same bfs is encountered twice it is called cycling (looping). – If cycling occurs, then we will loop, or cycle, forever among a set of basic feasible solutions and never get to an optimal solution. 33 ISE203/IE251 34 4.12 The Big M Method The simplex algorithm requires a starting (initial) bfs. Previous problems have found starting bfs by using the slack variables as our basic variables. – If an LP have ≥ or = constraints, however, a starting bfs cannot be found easily. In such a case, the Big M method is used to obtain a starting bfs and solve the problem. 35 Example 4: Bevco (A Blending Problem) Bevco manufactures an orange-flavored soft drink called Oranj by combining orange soda and orange juice. – Each oz of orange soda contains 0.5 oz of sugar and 1 mg of vitamin C. – Each oz 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 can meet the marketing department’s requirements at minimum cost. 36 Example 4: Bevco Letting x1 = number of ounces of orange soda in a bottle of Oranj x2 = number of ounces of orange juice in a bottle of Oranj The LP is: min z = 2x1 + 3x2 st 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 37 4.10 – The Big M Method Row 0: z - 2x1 What will be the BV in row 2? Row 3? Row 1: Row 2 would violate sign restrictions Row 3 no readily apparent basic variable. 3x2 =0 0.5x1 + 0.25x2 + s1 = 4 Row 2: x1 + 3x2 - e2 = 20 Row 3: x1 + x2 = 10 To find a bfs, we create artificial variables. The variables will be labeled according to the row in which they are used. Row 1: z - 2x1 Row 2: 3x2 =0 0.5x1 + 0.25x2 + s1 Row 3: x1 + 3x2 Row 4: x1 + x2 - e2 + a2 = 4 = 20 + a3 = 10 38 4.10 – The Big M Method In the optimal solution, all artificial variables must be equal to zero. To accomplish this, in a min LP, a term +Mai is added to the objective function for each 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: Row 0: z - 2x1 - Row 1: 3x2 -Ma2 - Ma3 0.5x1 + 0.25x2 + s1 Row 2: x1 + 3x2 Row 3: x1 + x2 - e2 =0 = 4 + a2 + = 20 a3 = 10 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. 39 4.10 – The Big M Method Description of the Big M Method: 1. Modify the constraints so that the rhs of each constraint is nonnegative. 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 function. 5. Since each artificial variable will be in the starting basis, all artificial variables must be eliminated from row 0 before beginning the simplex. 40 4.10 – 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. The Bevco example continued: Initial Tableau Row 0 1 2 3 z 1.00 x1 -2.00 0.50 1.00 1.00 x2 -3.00 0.25 3.00 1.00 s1 e2 a2 -M -1.00 1.00 a3 -M 1.00 1.00 rhs 0.00 4.00 20.00 10.00 41 4.10 – The Big M Method Pivot 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,00 0,25 1 1,00 x2 1,00 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 s1 s1 a3 s1 -1,00 1,00 e2 -M a2 -0,33 0,33 e2 a2 (M-3)/3 (3-4M)/3 -0,33 s1 s1 rhs ratio 30M 1,00 a3 1,00 1,00 1 a2 -M 1,00 1 1,00 x2 e2 1,00 a3 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 ero Row 2 divided by 3 ero Row 0 - (4M-3)*(Row 2) ero Row 1 - 0.25*(Row 2) ero Row 3 - Row 2 42 4.10 – The Big M Method Pivot 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 1.00 z 1.00 z 1.00 z 1.00 x1 (2M-3)/3 0.42 0.33 0.67 x1 (2M-3)/3 0.42 0.33 1.00 x1 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 Optimal Solution Row 2 -(1/3)*Row 3 43 Wyndor Problem - modified ISE203/IE251 44 Nonzero coefficient of x5 in the objective function row. We should make it zero. ISE203/IE251 45 ISE203/IE251 46 ISE203/IE251 47 ISE203/IE251 48 ISE203/IE251 49 ISE203/IE251 50 ISE203/IE251 51 ISE203/IE251 52 ISE203/IE251 53 4.14 Unrestricted-in-Sign Variables If some variables are allowed to be unrestricted in sign (urs), the ratio test and therefore the simplex algorithm are no longer valid. An LP with an unrestricted-in-sign variable can be transformed into an LP in which all variables are nonnegative. – For each urs variable xi, define two new variables x+i and x-i. – Then substitute ( x +i - x - i ) for xi in each constraint and in the objective function. – Also add the sign restrictions. 54 So we express xi as the difference of the two nonnegative variables x+i and x-i. No basic feasible solution can have both x+i ≥ 0 and x-i ≥ 0. x+i and x-i will never be both basic variables. – The column of one is equal to the negative column of the other For any basic feasible solution, each urs variable xi must fall into one of the following three cases. 1. x+i > 0 and x-i = 0 2. x+i = 0 and x- i > 0 3. x+i = x-i = 0 55 Example 8 (Using urs Variables): 56 Solution: 57 58 59