CO50 Linear Programming Chapter 6: The Simplex Method rd June 2005
Chapter 6: The Simplex Method 1 Recap Suppose A is an m-by-n matrix with rank m. max. c T x (P ) s.t. Ax = b x 0 On Wednesday, we learned if (P ) has an optimal solution, then it has an optimal solution that is basic. the motivation for simplex method: we search for an optimal solution one bfs at a time. how to obtain the basic solution determined by a given basis, while preserving the data of the LP.
Chapter 6: The Simplex Method 2 Bases and Tableaux Suppose A is m-by-n with rank m. max. (z =) c T x (P ) s.t. Ax = b x 0 (Defn) Tableau A tableau for (P ) corresponding to a basis B is the system of equations of the form z-row z c j x j j N = v x i -row x i + X j N ā ij x j = b i (i B) derived by applying elementary row operations to z c T x = 0 Ax = b Example (B = {1, 2, }) z + 8/ x 4 1/ x 5 = 2 x 5/ x 4 + 4/ x 5 = 4 x 1 + 1/ x 4 + 1/ x 5 = 4 x 2 + 1/ x 4 2/ x 5 = 1 (z-row) (x -row) (x 1 -row) (x 2 -row) c 4 = 8/ c 5 = 1/ v = 2 ā 4 = 5/ ā 25 = 2/ b2 = 1
Chapter 6: The Simplex Method A tableau has a wealth of information (Pg 71) Tableau corresponding to B = {1, 2, }: z + 8/ x 4 1/ x 5 = 2 x 5/ x 4 + 4/ x 5 = 4 x 1 + 1/ x 4 + 1/ x 5 = 4 x 2 + 1/ x 4 2/ x 5 = 1 1. The basic solution determined by B = {1, 2, } is x = [4, 1, 4, 0, 0] T In general, the basic solution determined by B is x i = b i for i B x j = 0 for j N The solution is a bfs if and only if b i 0 for all i B. In this case, we say that the tableau is feasible, and B is a feasible basis. E.g., B = {1, 2, } is feasible but B = {2,, 5} is not feasible. 2. The objective value of the basic solution determined by B = {1, 2, } is z = v = 2 In general, the objective value is given by v.
Chapter 6: The Simplex Method 4 A tableau has a wealth of information (cont d) Tableau corresponding to B = {1, 2, }: z + 8/ x 4 1/ x 5 = 2 x 5/ x 4 + 4/ x 5 = 4 x 1 + 1/ x 4 + 1/ x 5 = 4 x 2 + 1/ x 4 2/ x 5 = 1. When we increase x 5 from 0 while keeping the other nonbasic variable x 4 at 0, we see that the term 1/ x 5 in the z-row decreases. So z have to increase to counter this. Note: c 5 = 1/ > 0. When we increase x 4 from 0 while keeping the other nonbasic variable x 5 at 0, we see that the term 8/ x 4 in the z-row increase. So z have to decreases to counter this. Note: c 4 = 8/ < 0. c k > 0 = increasing x k increases z. c k < 0 = increasing x k decreases z. c k = 0 = increasing x k does not change z. c k is called the reduced cost of the nonbasic x k.
Chapter 6: The Simplex Method 5 The Idea of the Simplex Method Illustration with an example (This illustrates the idea of the method, and not how the simplex method should be applied.) Recall the example LP. max. z = 5x 1 + x 2 s.t. 2x 1 + x 2 + x = 15 2x 1 + x 2 + x 4 = 9 x 1 x 2 + x 5 = x 1, x 2, x, x 4, x 5 0 The tableau corresponding to the basis B = {, 4, 5} is z 5x 1 x 2 = 0 2x 1 + x 2 + x = 15 2x 1 + x 2 + x 4 = 9 x 1 x 2 + x 5 = and it determines the bfs x = [0, 0, 15, 9, ] T. We saw that for a nonbasic variable x k that has reduced cost c k > 0, increasing x k from 0 while keeping the other nonbasic variables (in this case there is only one other, but in general there could be many more) at 0 will increase the value of z (i.e., the objective value).
Chapter 6: The Simplex Method 6 In the tableau, the nonbasic variable x 1 has reduced cost c 1 = 5 > 0 (we can use x 2 instead since c 2 = > 0). Increasing x 1 to t 0 while keeping x 2 at 0 gives z(t) = 0 + 5t x 1 (t) = t x 2 (t) = 0 x (t) = 15 2t x 4 (t) = 9 2t x 5 (t) = t From the expression for z(t) we know that the larger t is, the better our solution is. BUT we need to make sure our solution is feasible. Maintaining feasibility means 15 2t 0 which implies t 7.5 9 2t 0 which implies t 4.5 t 0 which implies t 9>= >; = t. So we use t =, which gives the new feasible solution x = [, 0, 9,, 0] T with objective value 15. Note that this is again a bfs! This is NOT a coincidence. This bfs is determined by the basis B = {1,, 4}.
Chapter 6: The Simplex Method 7 Here is a diagram of the problem in SIF (treating x, x 4, x 5 as slacks). x 2 2x 1 + x 2 15 2x 1 + x 2 9 (0,5) (,) x1 x 2 Feasible region New x (4,1) x1 (0,0) (,0) x 2 0 Old x x 1 0 The solution x(t) = [x 1 (t), x 2 (t),..., x 5 (t)] T x 1 (t) = t x 2 (t) = 0 x (t) = 15 2t x 4 (t) = 9 2t x 5 (t) = t 9>= >; = x(t) = 2 64 0 0 is given by 15 75 + t 9 i.e., in the space of all 5 variables, we move from [0, 0, 15, 9, ] T in the direction of [1, 0, 2, 2, 1] T. 2 64 1 0 2 2 1 75 In the space of [x 1, x 2 ] T, we move from [0, 0] T in the direction of [1, 0] T.
Chapter 6: The Simplex Method 8 We shall get the tableau corresponding to B = {1,, 4} from z 5x 1 x 2 = 0 2x 1 + x 2 + x = 15 2x 1 + x 2 + x 4 = 9 x 1 x 2 + x 5 = Note that the columns for x and x 4 (previous basic variables that remain basic) already form part of the identity matrix (so does the column for z, but it always does). So we only need to make the column for x 1 (a new member of the basic variables) the remaining column of the identity matrix. In a way, we are transferring the column for x 5 to x 1. Good news: This can be done with at most four elementary row operations at most one on each row. (z-row) + 5 (x 5 -row): z 8x 2 + 5x 5 = 15 (x -row) 2 (x 5 -row): 5x 2 + x 2x 5 = 9 (x 4 -row) 2 (x 5 -row): x 2 + x 4 2x 5 = (x 5 -row): x 1 x 2 + x 5 = By changing only one member of B, we need at most m+1 row operations to get the new tableau.
Chapter 6: The Simplex Method 9 In the new tableau, the nonbasic variable x 2 has reduced cost c 2 = 8 > 0 (we cannot use x 5 since c = 5 0). Increasing x 2 to t 0 while keeping x 5 at 0 gives z(t) = 15 + 8t x 1 (t) = + t x 2 (t) = t x (t) = 9 5t x 4 (t) = t x 5 (t) = 0 Once again the larger t is, the better our solution is. To maintain feasibility, we need + t 0 which implies no upper bound on t 9 5t 0 which implies t 1.8 t 0 which implies t 1 9>= >; = t 1. So we use t = 1, which gives the new feasible solution x = [4, 1, 4, 0, 0] T with objective value 2. Once again, this is a bfs, and it is determined by the basis B = {1, 2, }.
Chapter 6: The Simplex Method 10 The following diagram shows this step. 2x 1 + x 2 15 x 2 2x 1 + x 2 9 (0,5) (,) x1 x 2 Feasible region New x (4,1) Old x x1 (0,0) (,0) x 2 0 x 1 0 The solution x(t) = [x 1 (t), x 2 (t),..., x 5 (t)] T x 1 (t) = + t x 2 (t) = t x (t) = 9 5t x 4 (t) = t x 5 (t) = 0 9>= >; = x(t) = 2 64 0 is given by 9 75 + t i.e., in the space of all 5 variables, we move from [, 0, 9,, 0] T in the direction of [1, 1, 5,, 0] T. 0 2 64 1 1 5 0 75 In the space of [x 1, x 2 ] T, we move from [, 0] T in the direction of [1, 1] T.
Chapter 6: The Simplex Method 11 To get the tableau corresponding to B = {1, 2, } from z 8x 2 + 5x 5 = 15 5x 2 + x 2x 5 = 9 x 2 + x 4 2x 5 = x 1 x 2 + x 5 = we transfer the column for x 4 to x 2. Once again we do this with at most four elementary row operations. (z-row) + 8 (x 4-row): z + 8 x 4 1 x 5 = 2 (x -row) 5 (x 4-row): x 5 x 4 + 4 x 5 = 4 1 (x 4-row): x 2 + 1 x 4 2 x 5 = 1 (x 1 -row) + 1 (x 4-row): x 1 + 1 x 4 + 1 x 5 = 4 We can still increase the objective value since c 5 = 1 > 0. Increasing x 5 to t 0 while keeping x 4 at 0 gives z(t) = 2 + 1 t x 1 (t) = 4 1 t x 2 (t) = 1 + 2 t x (t) = 4 4 t x 4 (t) = 0 x 5 (t) = t
Chapter 6: The Simplex Method 12 To maintain feasibility, we need 4 1 t 0 which implies t 12 1 + 2 t 0 which implies no upper bound on t 4 4 t 0 which implies t 9>= >; = t. So we use t =, which gives the new feasible solution x = [,, 0, 0, ] T with objective value 24. This bfs is determined by the basis B = {1, 2, 5}. To get the tableau corresponding to B = {1, 2, 5} from z + 8 x 4 1 x 5 = 2 x 5 x 4 + 4 x 5 = 4 x 2 + 1 x 4 2 x 5 = 1 x 1 + 1 x 4 + 1 x 5 = 4 we transfer the column for x to x 5, giving z + 1 4 x + 9 4 x 4 = 24 4 x 5 4 x 4 + x 5 = x 2 + 1 2 x 1 2 x 4 = x 1 1 4 x + 4 x 4 =
Chapter 6: The Simplex Method 1 Now we can no longer proceed since both reduced costs c = 1/4 and c 4 = 9/4 are not positive. The diagram below shows that x is optimal. x 2 x (,) Feasible region 5x1 + x 2 = 24 x1 We can actually prove it algebraically. From the z-row: z + 1 4 x + 9 4 x 4 = 24, we get z = 24 1 4 x 9 4 x 4 Since x 4, x 5 0 for any feasible solution, we have z = 24 1 4 x 9 4 x 4 24 for any feasible solution. The solution x = [,, 0, 0, ] T has objective value 24, so it must an optimal solution. We can also prove optimality using the C.S. Theorem. (More on this later.)