AGEC 352 Handout February 1, 2012 Simplex Method The simplex method is an algorithm for solving linear programs. It was developed in 1947 by George Dantzig and represented a significant advance over available algorithms that approximated solutions. The simplex method was also relatively simple to code into computer processing language and is still included as an option in modern optimization packages such as GAMS (general algebraic modeling system) and MS Excel’s Solver. Functioning as an algorithm, the simplex method begins from a standard form and proceeds along a series of steps until some terminal condition is met. The purpose of this handout is to give you a complete example of the Simplex method workings so that you can see how the process works. Pay close attention to the repeated steps as these are the key to transforming the tableaus into a solution. We will not discuss the mathematical theory in detail, but want to be able to fully understand the order of operations. The simplex algorithm works as a matrix transformation,, and the steps are similar to those used in matrix inversion. The example: Let: C = corn production (measured in acres) B = soybean production (measured in acres) The decision maker has the following limited resources: 320 acres of land 20,000 dollars in cash 19,200 bushels of storage The decision maker wants to maximize profits and estimates the following per acre net returns: C = $60 per acre B = $90 per acre The two crops the decision maker produces use limited resources at the following per acre rates: Resource Land Cash Storage Corn 1 50 100 Soybeans 1 100 40 Our first task is to write the algebraic form of this problem. Recall that the algebraic form as defined in this class has the following components A) An objective direction (max or min) followed by the objective variable and its defining equation B) A line with the words ‘subject to’ indicating the beginning of the constraint set C) A label for each constraint followed by the linear inequality for that constraint D) A label for non-negativity constraints followed by the full list of variables required to be non-negative The algebraic problem: max 60C 90 B s.t. land : C B 320 cash : 50C 100 B 20,000 storage : 100C 40 B 19,200 non neg : C 0; B 0 The simplex method requires a tableau format for the problem and each iteration of the algorithm will produce a new version of the tableau. Each tableau produced can be easily checked to see if it is the final solution. Below is the initial tableau and its explanation: Initial Tableau C land cash stor obj B 1 50 100 -60 s1 1 100 40 -90 s2 1 0 0 0 s3 0 1 0 0 P 0 0 1 0 RHS 0 0 0 1 320 20000 19200 0 The headings for columns are variables and the rows are equations. C and B are the columns corresponding to the two decision variables. s1 through s3 are called slack variables of the problem. These variables are introduced to eliminate the inequality signs that are part of the algebraic problem so that every constraint is an equation. For example, if the final solution is to produce 140 acres of corn and 130 acres of soybeans that will use only 270 acres of the available land. The slack variable for land (s1) would take on a solution value of 50. The column P is the objective variable’s column. The RHS column stands for ‘right hand side’ and gives the value of the equations in the initial setup. The rows are the equations of the problem, one for each constraint and the objective equation. The objective equation is always written at the bottom of the tableau. The values in each cell of the table correspond to the usage of resources for each variable. In other words if the value of the C variable is set to 1: 1 acre of land, 50 dollars of cash, and 100 bushels of storage will be used. Note that the slack variables all begin with a 1 in the row for which they provide the slack and a zero for the other constraints. To read a solution from a tableau, we identify only the variables that have a 1 in some row and a 0 in all others. If a variable has more than one value underneath it the solution value is zero. In the initial tableau this means that only the s1, s2, and s3 have values. We read the solution value for the variable in the RHS columns so that the initial value for s1 is 320. Since both C and B columns have multiple non-zero values those are initially set to zero. At the bottom of the tableau is the objective equation which keeps track of the optimal payout. The objective equation is written with negative values for the objective coefficients and a zero value on the right hand side. Think of this as rewriting the equation (where P =profits) as P60C – 90B = 0. With the initial setup, we are ready to begin manipulating the tableau to solve the problem. Note that since we need a column with a value of one in a single cell and all the rest to be zeroes that our task is to manipulate the initial tableau in a way that moves some of the non-zero values over the slack variable side of the tableau and converts the C and B columns to a single cell with a 1 and all the rest being 0. The simplex conversion steps are as follows: 1) Identify the pivot column: the column with the most negative element in the objective row. 2) Identify the pivot cell in that column: the cell with the smallest RHS/column value. 3) Convert the pivot cell to a value of 1 by dividing the entire row by the coefficient in the pivot cell. 4) Convert all other elements of the pivot column to 0 by adding a multiple of the pivot row to that row. We proceed with step 1. The value for B in the objective row is the most negative at -90, so this must be the pivot column (i.e. the column that will have the pivot cell). This also means that soybeans will be the first variable to enter the solution (note that this does not guarantee that it will be non-zero in the final solution). In step 2, we need to identify the pivot cell in the B column. To do this, we divide the RHS values by all the coefficients in the B column and choose the smallest ratio. land row: 320/1 = 320 cash row: 20,000/100 = 200 stor row: 19,200/40 = 480. So, the pivot cell is the intersection of the B column and the cash row. In step 3, we need to convert the pivot cell to a value of 1. Remember in mathematics that we can multiply or divide all parts of an equation by a common factor and have no impact on the solution to the equation. We will use this fact to convert the pivot cell by dividing the entire cash row (it’s an equation) by a factor of 100. The new cash row will now look like this: C B s1 s2 s3 P RHS new cash row 0.5 1 0 0.01 0 0 200 Finally, step 4 tells us that we need to get all of the other cells in the pivot column (the B column) to zero by adding a multiple of the pivot row (the new cash row). For the land row, this means multiplying the new cash row by -1 and adding it to the land row. For the storage row, we will need to multiply the new cash row by -40 and add it to the storage row. For the objective row, we multiple the new cash row by +90 and add it to the objective row. The new rows after completing the above operations are given below: C new land row new stor row new obj row B 0.5 80 -15 s1 0 0 0 s2 s3 1 -0.01 0 -0.4 0 0.9 P 0 1 0 RHS 0 0 1 120 11200 18000 Combining all of the new rows, we have the following updated tableau. This becomes the new basis for 1) testing to see if an optimal solution has been reached and 2) further manipulation using the simplex algorithm steps. C land cash stor obj B 0.5 0.5 80 -15 s1 0 1 0 0 1 0 0 0 s2 s3 -0.01 0.01 -0.4 0.9 P 0 0 1 0 RHS 0 0 0 1 120 200 11200 18000 To test if the iteration has produced an optimal solution, we need to check the objective row and see if it has any values that are less than zero. If it does, we need to redo the steps from before. If it does not, we are finished and can read the solution. Note that the above tableau has a value of 15 for the obj. row in the C column so we have more work to do. We can read the intermediate solution from the tableau to be B = 200, s1 = 120, s3 = 11,200, and profits = 18,000. With slack variables that large, it is not surprising that we have more work to do. Also note that 200 is the highest value that B can ever take, since cash is the most limiting factor for B production. We now redo the steps of the simplex algorithm, beginning with step 1 identifying the pivot column. Only C has a negative value in the objective row so that must be the pivot column. In step 2, we need to divide all the RHS values by the pivot column coefficients. This gives: Land: 120/0.5 = 240 Cash: 200/0.5 = 400 Stor: 11,200/80 = 140 This makes storage our new pivot row and the pivot cell is where the C column and storage row intersect. For step 3, we need to make the pivot cell have a value of 1. We divide the entire storage row (equation) by 80 to accomplish this and give the new storage row below. C new stor row B 1 s1 0 s2 s3 P 0 -0.005 0.0125 RHS 0 140 Finally, in step 4 we eliminate the non-zeroes from all other rows in the C column by adding a multiple of the new storage row to those rows. For the land row, this means we will be multiplying the new storage row by -0.5 and then adding it to the land row. For the cash row, we need to multiply the new storage row by -0.5 and add it to the cash row. To create the new objective row, we will multiple the new storage row by +15 and add it to the previous objective row to get the new version. The new rows after completing these operations are given below. C new land row new cash row new obj row B 0 0 0 s1 0 1 0 s2 s3 P 1 -0.008 -0.00625 0 0.013 -0.00625 0 0.825 0.1875 RHS 0 0 1 50 130 20100 At this point we see that the new objective row has no negative values so the final tableau must have the optimal solution. The final tableau is given below. Final Tableau C land cash stor obj B 0 0 1 0 s1 0 1 0 0 1 0 0 0 s2 s3 P -0.008 -0.00625 0.013 -0.00625 -0.005 0.0125 0.825 0.1875 RHS 0 0 0 1 50 130 140 20100 Recall from earlier that for a variable to have a non-zero value in the solution it must have a value of 1 in a single cell of its column and 0’s in all others. Thus, from the tableau above we see that the solution has s2 and s3 set to values of zero (this means that cash and storage are completely used in the solution). The non-zero variable values appear in the RHS column of the row where their 1 is located. Thus the land equation solves for s1 and shows it has an optimal value of 50. The cash equation solves for B and shows that B = 130. The storage equation solves for corn and shows that C = 140. Finally, the objective equation always solves for the objective variable and shows that profits equal $20,100. Other values in the tableau have interpretations as well but we are not ready for those yet.