Tutorial Simplex
Tutorial Simplex
The simplex method is a general-purpose linear-programming algorithm widely used to solve large-scale problems. Although it lacks the intuitive appeal of the graphical approach, its ability to handle problems with more than two decision variables makes it extremely valuable for solving problems often encountered in operations management. The simplex technique involves a series of iterations; successive improvements are made until an optimal solution is achieved. The technique requires simple mathematical operations (addition, subtraction, multiplication, and division), but the computations are lengthy and tedious, and the slightest error can lead to a good deal of frustration. For these reasons, most users of the technique rely on computers to handle the computations while they concentrate on the solutions. Still, some familiarity with manual computations is helpful in understanding the simplex process. You will discover that it is better not to use your calculator in working through these problems because rounding can easily distort the results. Instead, it is better to work with numbers in fractional form. Even though simplex can readily handle three or more decision variables, you will gain considerable insight on the technique if we use a two-variable problem to illustrate it because you can compare what is happening in the simplex calculations with a graphical solution to the problem. Lets consider the simplex solution to the following problem: Maximize Subject to + 5x2 + 3 x2 + 3 x2 x1, x2 The solution is shown graphically obtain the solution. Figure 1. Graphical Solution X2 10 8 6 4 4X1 + 5X2 = 20 2 0 2 4 6 8 10 12 4X1 + 3X2 = 24 Objective function Optimum X1 + 3X2 = 12 X1 Z= 4x1 x1 4x1
12 24 0 in Figure 1. Now lets see how the simplex technique can be used to
Tutorial: Simplex Method (continued) The simplex technique involves generating a series of solutions in tabular form, called tableaus. By inspecting the bottom row of each tableau, one can immediately tell if it represents the optimal solution. Each tableau corresponds to a corner point of the feasible solution space. Their first tableau corresponds to the origin. Subsequent tableaus are developed by shifting to an adjacent corner point in the direction that yields the highest rate of profit. This process continues as long as a positive rate of profit exists. Thus, the process involves the following steps: 1. 2. 3. 4. Set up the initial tableau. Develop a revised tableau using the information contained in the first tableau. Inspect to see if it is optimum. Repeat steps 2 and 3 until no further improvement is possible. Setting Up the Initial Tableau Obtaining the initial tableau is a two-step process. First, we must rewrite the constraints to make them equalities and modify the objective function slightly. Then we put this information into a table and supply a few computations that are needed to complete the table. Rewriting the objective function and constrains involves the addition of slack variables, one for each constraint. Slack variables represent the amount of each resource that will not be used if the solution is implemented. In the initial solution, with each of the real variables equal to zero, the solution consists solely of slack. The constraints with slack added become equalities: (1) (2) x1 + 3x2 4x1 + 3x2 + 1s1 + 1s2 = 12 = 24
It is useful in setting up the table to represent each slack variable in every equation. Hence, we can write these equations in an equivalent form: (1) (2) x1 + 3x2 4x1 + 3x2 + 1s1 + 0s1 + 0s2 + 1s2 = 12 = 24
The objective function can be written in similar form: Z = 4x1 + 5x2 + 0s1 + 0s2 The slack variables are given coefficients of zero in the objective function because they do not produce any contributions to profits. Thus, the information above can be summarized as: Maximize Subject to Z = 4x1 + 5x2 + 0s1 + 0s2 (1) (2) x1 + 3x2 4x1 + 3x2 + 1s1 + 0s1 + 0s2 + 1s2 = 12 = 24
This forms the basis of our initial tableau, which is shown in Table 5S-1. To complete the first tableau, we will need two additional rows, a Z row and a C - Z row. The Z row values indicate the reduction in profit that would occur if one unit of the variable in that column were added to the solution. The C - Z row shows the potential for increasing profit if one unit of the variable in that column were added to the solution.
Tutorial: Simplex Method (continued) To compute the Z values, multiply the coefficients in each column by their respective row profit per unit amounts, and sum within columns. To begin with, all values are zero: C 0 0 Z x1 (1)0 4(0) 0 x2 3(0) 3(0) 0 s1 1(0) 0(0) 0 s2 (0)0 (1)0 0 Quantity (12)0 (24)0 0
The last value in the Z row indicates the total profit associated with a given solution (tableau). Since the initial solution always consists of the slack variables, it is not surprising that profit is 0. Values in the C - Z row are computed by subtracting the Z value in each column from the value of the objective row for that column. Thus, Variable row Objective row (C) Z C-Z Table 1 Partial Initial Tableau Profit per unit for variables in solution C Variables in solution s1 s2 4 x1 1 4 Decision Variables 5 x2 3 3 0 s1 1 0 0 s2 0 1 Objective row Solution quantity 12 24 x1 4 0 4 x2 5 0 5 s1 0 0 0 s2 0 0 0
0 0
The completed tableau is shown in Table 2. The Test for Optimality If all the values in the C - Z row of any tableau are zero or negative, the optimal solution has been obtained. In this case, the C - Z row contains two positive values, 4 and 5, indicating that improvement is possible. Developing the Second Tableau Values in the C - Z row reflect the profit potential for each unit of the variable in a given column . For instance, the 4 indicates that each unit of variable x 1 added to the solution will increase profits by $4. Similarly, the 5 indicates that each unit of x 2 will contribute $5 to profits. Given a choice between $4 per unit and $5 per unit, we select the larger and focus on that column, which means that x 2 will come into the solution. Now we must determine which variable will leave the solution. (At each tableau, one variable will come into the solution, and one will go out of solution, keeping the number of variables in the solution constant. Note that the number of variables in the solution must always equal the number of constraints. Thus, since this problem has two constraints, all solutions will have two variables.)
Tutorial: Simplex Method (continued) To determine which variable will leave the solution, we use the numbers in the body of the table in the column of the entering variable (i.e., 3 and 3). These are called row pivot values. Divide each one into the corresponding solution quantity amount, as shown in Table 3. The smaller of these two ratios indicates the variable that will leave the solution. Thus, variable s 1 will leave and be replaced with x 2. In graphical terms, we have moved up the x 2 axis to the next corner point. By determining the smallest ratio, we have found which constraint is the most limiting. In Figure 1, note that the Table 2 completed initial tableau. C 0 0 4 Variables in solution s1 s2 Z C-Z Variables in solution s1 s2 Z C-Z x1 1 4 0 4 4 x1 1 4 0 4 5 x2 3 3 0 5 5 x2 3 3 0 5 Largest positive 0 s1 1 0 0 0 0 s1 1 0 0 0 0 s2 0 1 0 0 0 s2 0 1 0 0 Solution quantity 12/3 = 4 24/3 = 8 0 Solution quantity 12 24 0
0 0
two constraints intersect the x 2 axis at 4 and 8, the two row ratios we have just computed. The second tableau will describe the corner point where x 2 = 4 and x1 = 0; it will indicate the profits and quantities associated with that corner point. It will also reveal if the corner point is an optimum, or if we must develop another tableau. At this point we can begin to develop the second tableau. The row of the leaving variable will be transformed into the new pivot row of the second tableau. This will serve as a foundation on which to develop the other rows. To obtain this new pivot row, we simply divide each element in the s 1 row by the row pivot value (intersection of the entering column and leaving row), which is 3. The resulting numbers are: Solution quantity 4
x2 1
s1 1/3
s2 0
Tutorial: Simplex Method (continued) These numbers become the new x2 row of the second tableau. The pivot-row numbers are used to compute the values for the other constraint rows (in this instance, the only other constrain row is the s2 row). The procedure is: 1. 2. 3. Find the value that is at the intersection of the constrain row (i.e., the s 2 row) and the entering variable column. It is 3. Multiply each value in the new pivot row by this value. Subtract the resulting values, column by column, from the current row values. Current value: -3 x (pivot row) New row value x1 4 -3(1/3) 3 x2 3 -3(1) 0 s1 0 -3(1/3) -1 s2 1 -3(0) 1 Quantity 24 -3(4) 12
The two new rows are shown in Table 4. The new Z row can now be computed. Multiply the row unit profits and the coefficients in each column for each row. Sum the results within each column. Thus, Row x2 s1 New Z row Profit 5 0 x1 5(1/3) 0(3) 5/3 x2 5(1) 0(0) 5 s1 5(1/3) 0(-1) 5/3 s2 5(0) 0(1) 0 Quantity 5(4) 0(12) 20
Table 4 partially completed second tableau C Variables in solution x2 s2 4 x1 1/3 3 5 x2 3 0 0 s1 1/3 -1 0 s2 0 1 Solution quantity 4 12
5 0
Table 5 completed second tableau C Variables in solution X2 s2 Z C-Z 4 x1 1/3 3 5/3 7/3 5 x2 1 0 5 0 0 s1 1/3 -1 5/3 -5/3 0 Solution s2 quantity 0 1 0 0 4 12 20
5 0
Tutorial: Simplex Method (continued) The completed second tableau is shown in Table 5. It tells us that at this point 4 units of variable x 2 are the most we can make (see column Solution quantity, row x 2)and that the profit associated with x2 = 4, x1= 0 is $20 (see row Z, column Solution quantity). The fact that there is a positive value in the C - Z row tells us that this is not the optimal solution. Consequently, we must develop another tableau. Developing the Third Tableau The third tableau will be developed in the same manner as the previous one. 1. 2. Determine the entering variable: Find the column with the largest positive value in the C - Z row (7/3, in the x1column). Determine the leaving variable: Divide the solution quantity in each row by the row pivot. Hence, 4 = 12 12/3 = 4 1/3 The smaller ratio indicates the leaving variable, s2. See Table 5S-6. 3. Divide each value in the row of the leaving variable by the row pivot value (3) to obtain the new pivot-row values: x1 Current value New pivot-row value Table 6 Leaving/Entering Variables C Variables in solution 5 0 x2 s2 Z C-Z 4 x1 1/3 3 5/3 7/3 Entering variable is x1 5 x2 1 0 5 0 0 s1 1/3 -1 5/3 -5/3 0 s2 0 1 0 0 Solution quantity 4 = 12 1/3 12/3 = 4 20 3 1 x2 0 0/3 s1 -1 -1/3 s2 1 1/3 Quantity 12 12/3 = 4
Leaving variable is s2
Tutorial: Simplex Method (continued) 4. Compute values for the x2 row: Multiply each new pivot-row value by the x2 row pivot value (i.e., 1/3) and subtract the product from corresponding current values. Thus, x1 1/3 -1/3(1) 0 x2 1 -1/3(0) 1 s1 1/3 -1/3(-1/3) 4/9 s2 0 -1/3(1/3) -1/9 Quantity 4 -1/3(4) 8/3
At this point, it will be useful to consider the tableaus in relation to a graph of the feasible solution space. This is shown in Figure 2. 5. Compute new Z row values. Note that now variable x1 has been added to the solution mix; that rows unit profit is $4. Row x2 x1 New Z row Profit $5 $4 x1 5(0) 4(1) 4 x2 5(1) 4(0) 5 s1 5(4/9) 4(-1/3) 8/9 s2 5(-1/9) 4(1/3) 7/9 Quantity 5(8/3) 4(4) 88/3
3rd tableau
Tutorial: Simplex Method (continued) Table 7. Optimal Solution C Variables in solution x2 x1 Z CZ 4 x1 0 1 4 0 5 x2 1 0 5 0 0 s1 4/9 -1/3 8/9 -8/9 0 s2 -1/9 1/3 7/9 -7/9 Solution quantity 8/3 4 88/3
5 4
The resulting values of the third tableau are shown in Table 7. Note that each of the C - Z values is either 0 or negative, indicating that this is the final solution. The optimal values of x 1 and x2 are indicated in the quantity column: x2 = 8/3, or 2 2/3, and x1 = 4. (The x2 quantity is in the x2 row and the x1 quantity in the x1 row.) Total profit is 88/3, or 29.33 (quantity column, Z row). Handling and = Constraints Up to this point, we have worked with constraints. Constraints that involve equalities and constraints are handled in a slightly different way. When an equality constraint is present, use of the simplex method requires addition of an artificial variable. The purpose of such variables is merely to permit development of an initial solution. For example, the equalities (1) 7x1 + 4x2 = 65 (2) 5x1 + 3x2 = 40 would be rewritten in the following manner using artificial variables a 1 and a2: (1) 7x1 + 4x2 + 1a1 + 0a2 = 65 (2) 5x1 + 3x2 + 0a1 + 1a2 = 40 Slack variables would not be added. The objective function, say Z = 2x 1 + 3x2, would be rewritten as: Z = 2x1 + 3x2 + Ma1 + Ma2 where M = A large number (e.g., 999) Since the artificial variables are not desired in the final solution, selecting a large value of M (much larger than the other objective coefficients) will insure their deletion during the solution process. For constraints, surplus variables must be subtracted instead of added to each constraint. For example, the constraints (1) 3x1 + 2x2 + 4x3 80 (2) 5x1 + 4x2 + x3 70 (3) 2x1 + 8x2 + 2x3 68
Tutorial: Simplex Method (continued) would be rewritten as equalities: (1) 3x1 + 2x2 + 4x3 - 1s1 - 0s2 - 0s3 = 80 (2) 5x1 + 4x2 + x3 - 0s1 - 1s2 - 0s3 = 70 (3) 2x1 + 8x2 + 2x3 - 0s1 - 0s2 - 1s3 = 68 As equalities, each constraint must then be adjusted by inclusion of an artificial variable. The final result looks like this: (1) 3x1 + 2x2 + 4x3 - 1s1 - 0s2 - 0s3 + 1a1 + 0a2 + 0a3 = 80 (2) 5x1 + 4x2 + x3 - 0s1 - 1s2 - 0s3 + 0a1 + 1a2 + 0a3 = 70 (3) 2x1 + 8x2 + 2x3 - 0s1 - 0s2 - 1s3 + 0a1 + 0a2 + 1a3 = 68 If the objective function happened to be 5x1 + 2x2 + 7x3 it would become 5x1 + 2x2 + 7x3 + 0s1 + 0s2 + 0s3 + Ma1 + Ma2 + Ma3 Summary of Maximization Procedure The main steps in solving a maximization problem with only constraints using the simplex algorithm are these: 1. Set up the initial tableau. a. Rewrite the constraints so that they become equalities; add a slack variable to each constraint. b. Rewrite the objective function to include the slack variables. Give slack variables coefficients of 0. c. Put the objective coefficients and constraint coefficients into tableau form. d. Compute values for the Z row; multiply the values in each constraint row by the rows C value. Add the results within each column. e. Compute values for the C - Z row. 2. Set up subsequent tableaus. a. Determine the entering variable (the largest positive value in the C- Z row). If a tie exists, choose one column arbitrarily. b. Determine the leaving variable: Divide each constraint rows solution quantity by the rows pivot value; the smallest positive ratio indicates the leaving variable. If a tie occurs, divide the values in each row by the row pivot value, beginning with slack columns and then other columns, moving from left to right. The leaving variable is indicated by the lowest ratio in the first column with unequal ratios. c. Form the new pivot row of the next tableau: Divide each number in the leaving row by the rows pivot value. Enter these values in the next tableau in the same row positions. d. Compute new values for remaining constraint rows: For each row, multiply the values in the new pivot row by the constraint rows pivot value, and subtract the resulting values, column by column, from the original row values. Enter these in the new tableau in the same positions as the original row. e. Compute values for Z and C - Z rows.
Tutorial: Simplex Method (continued) f. Check to see if any values in the C - Z row are positive; if they are, repeat 2a-2f. Otherwise, the optimal solution has been obtained. Minimization Problems The simplex method handles minimization problems in essentially the same way it handles maximization problems. However, there are a few differences. One is the need to adjust for constraints, which requires both artificial variables and surplus variables. This tends to make manual solution more involved. A second major difference is the test for the optimum: A solution is optimal if there are no negative values in the C - Z row. Example Solve the following problem for the quantities of x1 and x2 that will minimize cost. Minimize Subject to Z = 12x1 + 10x2 x1 + 4x2 3x1 + 2x2 x1, x2
8 6 0
Solution to example 1. Rewrite the constraints so that they are in the proper form: x1 + 4x2 8 becomes x1 + 4x2 - 1s1 - 0s2 + 1a1 + 0a2 = 8 3x1 + 2x2 6 becomes 3x1 + 2x2 - 0s1 - 1s2 + 0a1 + 1a2 = 6 2. Rewrite the objective function (coefficients of C row): 12x1 + 10x2 + 0s1 + 0s2 + 999a1 + 999a2 3. Compute values for rows Z and C - Z: C 999 999 Z C-Z x1 1(999) 3(999) 3,996 -3,984 x2 4(999) 2(999) 5,994 -5,984 s1 -1(999) 0(999) -999 999 s2 0(999) -1(999) -999 999 a1 1(999) 0(999) 999 0 a2 0(999) 1(999) 999 0 Quantity 8(999) 6(999) 13,986
4. Set up the initial tableau. (Note that the initial solution has all artificial variables). C Variables in solution a1 a2 12 x1 10 x2 0 s1 0 s2 999 a1 999 a2 Solution Quantity
999 999
1 4 -1 0 1 0 8 3 2 0 -1 0 1 6 Z 3,996 5,994 -999 -999 999 999 13,986 CZ -3,984 -5,984 999 999 0 0 5. Find the entering variable (largest negative C - Z value: x 2 column) and leaving variable (smaller of 8/4 = 2 and 6/2 =3; hence, row a1).
10
Tutorial: Simplex Method (continued) 6. Divide each number in the leaving row by the pivot value (4, in this case) to obtain values for the new pivot row of the second tableau: 1/4 4/4 = 1 -1/4 0/4 1/4 0/4 7. Compute values for other rows; a2 is: x1 Current value -2 x (new pivot row) New row x1 10(1/4) 999(10/4) 2,500 3 -2/4 10/4 x2 10(1) 999(0) 10 x2 2 -2 0 s1 0 2/4 +2/4 s2 -1 -0/4 -1 s2 10(0) 999(-1) -999 8/4 = 2 a1 0 -2/4 -2/4 a1 10(1/4) 999(-2/4) -497 a2 1 -0/4 1 a2 10(0) 999(1) 999
Quantity 6 -4 2
8. Compute a new Z row: Row x2 a2 Z Cost 10 999 s1 10(-1/4) 999(2/4) 497 Quantity 10(2) 999(2) 2,018
9. Compute the C - Z row: x1 C Z C-Z 10. C 12 2,500 -2,488 x2 10 10 0 12 s1 0 497 -497 10 x2 1 0 10 0 0 s1 -1/4 2/4 497 -497 s2 0 -999 999 0 s2 a1 999 -497 1,496 999 a1 999 a2 0 1 999 0 Solution Quantity 2 2 2,018 a2 999 999 0
Variables x1 in solution a1 10 1/4 a 999 2 10/4 Z 2,500 CZ -2,488 11. Repeat the process.
a. Check for optimality: It is not optimum because of negatives in C - Z row. b. Determine the entering variable: The largest negative is in column x 1. c. Determine the leaving variable: 2/(1/4) = 8, 2/(10/4) = 0.8. Therefore, it is row a 2. d. Find new pivot-row value using the pivot value of 10/4: 1 0 0.2 -0.4 -0.2 0.4 0.8 e. Determine values for new x2 row: 0 1 -0.3 0.1 0.3 -0.1 1.8
11
Tutorial: Simplex Method (continued) f. Determine new values for row Z: Row x2 x1 Z Cost 10 12 x1 10(0) 12(1) 12 x2 10(1) 12(0) 10 s1 10(-0.3) 12(0.2) -0.6 s1 0 -0.6 0.6 s2 10(0.1) 12(-0.4) -3.8 s2 0 -3.8 3.8 a1 999 0.6 998.4 a1 10(0.3) 12(-0.2) 0.6 a2 999 3.8 995.2 a2 10(-0.1) 12(0.4) 3.8 Quantity 10(1.8) 12(0.8) 27.6
h. Set up the next tableau. Since no C - Z values are negative, the solution is optimal. Hence, x 1 = 0.8, x2 = 1.8, and minimum cost is 27.60. C 12 10 0 0 999 999 Variables x1 x2 s1 s2 a1 a2 in solution Quantity a 10 1 0 1 -0.3 0.1 0.3 -0.1 1.8 a 12 2 1 0 0.2 -0.4 -0.2 0.4 0.8 Z CZ 12 0 10 0 -0.6 0.6 -3.8 3.8 0.6 3.8 998.4 995.2 27.6
12
5x + 12y + 8z 1,400 minutes 7x + 9y + 9z 1,250 minutes 4x + 3y + 6z 720 minutes x, y, z 0 a. Solve for the quantities of products x, y, and z that will maximize revenue. 2. Use the simplex method to solve these problems: a. Minimize Subject to Z = 21x1 + 18x2 (1) 5x1 + 10x2 100 (2) 2x1 + 1x2 10 b. Minimize Subject to x1, x2 0 Z = 2x + 5y + 3z (1) 16x + 10y + 18z 340 (2) 11x + 12y + 13z 300 (3) 2x + 6y + 5z 120 x, y z 0
13
Solutions-Tutorial (SIMPLEX)
1. C Var 0 0 4 S1 S2 S3 Z C-Z 10.5 x 5 7 4 0 10.5 11.75 10.80 y z 12 8 9 9 3 6 0 0 11.75 10.80 0 S1 1 0 0 0 0 0 S2 0 1 0 0 0 0 S3 0 0 1 0 0 bi 1400 1250 720 0 ratio 116.67 138.89 240
C 11.45 0 0
Var y S2 S3 Z C-Z
y 1 0 0 11.75 0
S3 0 0 1 0 0
C 10.5 0
x 0 1 0 10.5 0 x 0 1 0 10.5 0
z 11/39 12/13 19/13 13.01 -2.206 z 11/7 117/9 1 78/91 13.5 -2.7
11.75 y
S1 7/39
S2 -5/39
S3 0 0 1 0 0 S3 0 0 1 0 0
-3/13 4/13 5/13 -11/13 -0.314 1.724 0.314 -1.724 S1 1 0 0 0 0 S2 -5/7 -1/7 -4/7 1.5 -1.5
C 0 10.5 0
14
Solutions (continued) 2. a. Minimize Z = 21x1 + 18x2 S.T. 5x1 + 10x2 + A1 S1 = 100 2x1 + 1x2 + A2 S2 = 10 I. C Var M A1 M A2 Z C-Z x1 A1 5 10 1 2 1 0 7M 11M M [21-7M] [18-11M] -M x2 S1 -1 0 -M M A2 0 1 M -M S2 0 -1 -M M bi 100 10 110M M ratio 10 10
x1 0.5 1.5
x2 1 0
A1 0.1 -0.1
S1 -0.1 0.1
A2 S2 0 0 1 -1
bi 10 0 180
ratio 20 0
[1.5M+9] 18 [21-1.5M] 0
x1 0 1 21 0
x2 1 18 0
bi 10 0 180
0 +0.0667
15
5 y 10 12 6 28M [-28M+5]
M A2 0 1 0 M 0 A2 0 1 0
0 S2 0 -1 0 -M M S2 0 -1 0
M A3 0 0 +1 M 0 A3 0 0 1
0 S3 0 0 -1 -M M S3 0 0 -1
II. C Var x y 3 Z .8889 .5556 M A2 -.5556 4.778 M A3 -2.444 3.222* Z [-3M+2.7] [8M+1.7] C-Z [+3M+.7] [-8M+3.3] 0 III. C Var x y z 3 z 1.31 0 1 M A2 3.069* 0 0 5 Y -0.7586 1 0 Z [3M+.138] C-Z [-3.1M+1.86] IV. C 3 2 5 Var z x y Z C-Z V. C 3 0 5 Var z S1 y Z C-Z x 0 1 0 2 0 x 2.333 9.889 -1.611 -1.06 3.056 y 0 0 1 5 0 z 1 0 0 3 0 y 0 0 1 5 0 5 0
3 [-M+.17] [M-.17] M -M M -M [2M-47] [-M+.17] 0 M 0 M S1 A2 S2 S3 bi 0 0 -.1034 .1724 14.48 .3103 -1 -1 1.483 16.25 0.08621 0 0 -0.3103 7.931 0 -M M
S3 -0.4607 .4831 .05618 -0.1348 0.1348 S3 .6667 4.778 -0.7222 -1.6111 1.6111
16
Solutions (continued) VI. C 3 0 0 S2 S3 Var x y z S1 z .4 1.2 1 0 0 -0.200 S1 -8.8 11.6 0 1 0 -3.6 S2 -5.8 3.6 0 0 1 -2.6 Z 1.2 3.6 3 0 0 -0.6 C-Z .8 1.4 0 0 0 .6 Optimal solution is: x = 0; y = 0; z = 24 and Z = 72.0 bi 24 92 23 72
17