Example: Mary’s radiation therapy (Ch. 3.4) Mary has a tumor in her bladder that must be treated with radiation therapy. From two different directions her body is treated with ionizing radiation. The effects on healthy and malignant tissue are known. Which doses must be administered to reach a certain level in the tumor, while the surrounding tissue and organs are spared as much as possible? LP model: Min s.t. and Z = 0.4x1 + 0.5x2 0.3x1 + 0.1x2 2.7, 0.5x1 + 0.5x2 = 6, 0.6x1 + 0.4x2 6, x1, x2 0. Solution with simplex method (Ch. 4.6) Rewrite the model with equalities by introducing slack (x3), surplus (x5) and auxiliary variables (x4, x6): Min s.t. and Z = 0.4x1 + 0.5x2 + Mx4 + Mx6 0.3x1 + 0.1x2 + x3 = 2.7, 0.5x1 + 0.5x2 + x4 = 6, 0.6x1 + 0.4x2 - x5 + x6 = 6, x1, x2, x3, x4, x5, x6 0. Note: the coefficients of x4 and x6 in the objective function are +M, because we are minimizing! In maximization form: - Z + 0.4x1 + 0.5x2 + Mx4 + Mx6 0.3x1 + 0.1x2 + x3 0.5x1 + 0.5x2 + x4 0.6x1 + 0.4x2 - x5 + x6 =0 = 2.7 =6 =6 Note: -Z, because it is a minimization problem. The basic variables are (x3, x4, x6) and must not occur in the objective function. Gaussian elimination yields: - Z + (0.4-1.1M)x1 + (0.5-0.9M)x2 + Mx5 0.3x1 + 0.1x2 + x3 0.5x1 + 0.5x2 + x4 0.6x1 + 0.4x2 - x5 + x6 = -12M = 2.7 =6 =6 - Z + (0.4-1.1M)x1 + (0.5-0.9M)x2 + Mx5 0.3x1 + 0.1x2 + x3 0.5x1 + 0.5x2 + x4 0.6x1 + 0.4x2 - x5 + x6 = -12M = 2.7 =6 =6 The simplex tableaus are: From the last tableau the solution can be read: Basic variables are x1 = 7.5, x5 = 0.3, x2 = 4.5 (left-most and right-most column), so the non-basic variables in this corner point are x3 = x4 = 0. The objective value is (first row): -Z = -5.25, so: x1 = 7.5, x2 = 4.5 and Z = 5.25. The feasible region of the original problem (black line segment), and of the artificial problem (grey), this is a projection of a 5 dimensional region. The simplex method finds the points 0, 1, 2, 3. From point 3 the solution is feasible for the original problem. The solution happens to be optimal (by coincidence). Two-phase method (Ch. 4.6) The big-M method will not be implemented, in general, with an explicit, large value of M, because that value is problem dependent and because it may lead to numerical problems (cancellation). Other approach: The objective function of the big-M method is: Min Z = 0.4x1 + 0.5x2 + Mx4 + Mx6 The simplex method will first try to reduce the contribution of M for find a feasible point for the original problem. Two-phase method: Phase 1: Min Z = x4 + x6 The result of this phase will be that x4 = x6 = 0 (if there is a feasible solution). Start with this feasible solution and change the objective function: Phase 2: Min Z = 0.4x1 + 0.5x2 to find the optimal solution. Example: Mary’s radiation therapy Phase 1: -Z + x4 + x6 0.3x1 + 0.1x2 + x3 0.5x1 + 0.5x2 + x4 0.6x1 + 0.4x2 - x5 + x6 =0 = 2.7 =6 =6 The basic variables are (x3, x4, x6) and must not occur in the objective function: - Z -1.1x1 - 0.9x2 + x5 0.3x1 + 0.1x2 + x3 0.5x1 + 0.5x2 + x4 0.6x1 + 0.4x2 - x5 + x6 = -12 = 2.7 =6 =6 In the last tableau the objective value 0 has been found so x4 = x6 = 0. The solution (6, 6, 0.3, 0, 0, 0) is feasible for the original problem (but may not be optimal). In phase 2 the objective Z = 0.4x1 + 0.5x2 is minimized. In the final tableau of phase 1, replace the objective function and continue with the simplex method: The optimal solution is (7.5, 4.5, 0, 0, 0.3), Z = 5.25. Note: The path followed by the two-phase method in this case differs from the one in the big-M method! This may occur in the first phase if two equally best ascent directions where the choice of ascent direction may be influenced. What happens if there is no feasible solution? Min s.t. and Z = 0.4x1 + 0.5x2 0.3x1 + 0.1x2 2.7, 0.5x1 + 0.5x2 = 6, 0.6x1 + 0.4x2 6, x1, x2 0. Replace 0.3x1 + 0.1x2 2.7 with 0.3x1 + 0.1x2 1.8. This yields the following tableaus for the big-M method: The optimal objective value still contains M. This means that there is no feasible solution. The two-phase method will not reach a zero objective value in its first phase. Tie breaking in the simplex method (Ch. 4.5) During the simplex method it may be unclear what to do at certain moments: 1. Variable entering the basis: Find the largest coefficient in the objective function. What if two or more largest coefficients occur? Example: 3x1 + 3x2. Answer: Choose one (e.g. the first). 2. Variable leaving the basis: See how large is can become (minimum ratio test). What if there are coefficients 0? For example: 2a. 2x1 + x3 = 4, then x1 = 4/2 – x3/2 2 (because x3 0) Normal situation. 2b. –2x1 + x3 = 4, then x1 = –4/2 + x3/2 –2. This is always true, so nothing needs to be checked. 2c. 2x1 + x3 = –4, then x1 = –4/2 – x3/2 –2. Not feasible. Impossible! Calculation error. 2d. –2x1 + x3 = –4, then x1 = 4/2 + x3/2 2. Impossible, because x1 = 0 was feasible. Calculation error! Conclusion: Only apply the minimum ratio test when the pivot element > 0 and the right-hand side 0. 2e. What if no quotient can be computed because all coefficients in the pivot column are 0? No leaving variable. The problem is then unbounded. (Usually an error in the modeling). 3. Two quotients are equal. You run into two constraints at the same time. This may lead to an infinite loop (cycling). Solutions for this problem are known. 4. There may be more optimal solutions for the same objective value. The simplex method will find the first one and stops. The simplex algorithm can be restarted in a direction in which the objective function remains constant (coefficient = 0 for some non-basic variables). In this way it is possible to find other optima. Example of cycling in the simplex method Max 10x1 – 57x2 – 9x3 – 24x4 s.t. 0.5x1 – 5.5x2 – 2.5x3 + 9x4 0 0.5x1 – 1.5x2 – 0.5x3 + x4 0 x1 1 x1, x2, x3, x4 0 > A:=matrix([[0.5,-5.5,-2.5,9,1,0,0],[0.5,-1.5,-0.5,1,0,1,0], [1,0,0,0,0,0,1]]); b:=vector([0,0,1]); c:=vector([10 ,-57,-9,-24,0,0,0]); > T1:=initableau(A,b,c); > T2:=spil(T1,5,1); > T3:=spil(T2,6,2); > T4:=spil(T3,1,3); > T5:=spil(T4,2,4); > T6:=spil(T5,3,5); > T7:=spil(T6,4,6); This tableau is equal to the first tableau. There was no improvement in Z. All minimum ratios were = 0, so no steps were actually taken. This cycling will go on forever. This behavior can be disturbed by choosing another leaving basic variable: > T1:=initableau(A,b,c); > T2:=spil(T1,6,1); (instead of T2:=spil(T1,5,1)) > T3:=spil(T2,7,3); This solution is now optimal. Changing the search direction may help! Complexity of the simplex method Max s.t. 100x1 + 10x2 + x3 x1 1 20x1 + x2 100 200x1 + 20x2 + x3 10000 x1, x2, x3 0 > A:=matrix([[1,0,0,1,0,0],[20,1,0,0,1,0], [200,20,1,0,0,1]]); b:=vector([1,100,10000]); c:=vector([100,10,1,0,0,0]); > T1:=initableau(A,b,c); > T2:=spil(T1,4,1); > T3:=spil(T2,5,2); > T4:=spil(T3,1,4); > T5:=spil(T4,6,3); > T6:=spil(T5,4,1); > T7:=spil(T6,2,5); > T8:=spil(T7,1,4); The optimal solution is found after 8 iterations, so the simplex method travels through all corner points of the feasible region. This example can be generalized to n dimensions. This gives an example with 2n constraints and 2n iterations. This means exponential behaviour (the number of iterations can grow exponentially in the size of the problem). Example by Klee and Minty. The simplex method is not finite (cycling) but in practice it is The simplex method is not polynomiaal (Klee, Minty) but in practice it is: ca. 1.5m iterations, maximal 3m (m = #constraints) Computation time m3. Interior Point Methods are provably polynomial. In practice the number of iterations is constant, ca. 20 – 80.