Linear Programming Problems A linear programming problem (LP) is an optimization problem subject to constraints as established by limitations in resources, manpower, etc. We attempt to maximize a linear function of the decision variables, i.e. revenue, profit, etc. This function we call objective function. The values of the decision variables must satisfy a set of constraints (must also be linear equation or linear inequality). Each variable can be non-negative or unrestricted in sign (urs), i.e. +ve or –ve. Example: A Company manufactures two types of wooden toys: soldiers and trains. Selling soldiers make $3 profit each and selling trains makes $2 profit each. The manufacture of wooden soldiers and trains require two types of skilled labour: Carpentry and finishing. A soldier requires 2 hours of finishing labour and 1 hour of carpentry labour. A train requires 1 hour of finishing and 1 hour of carpentry labour. Company can obtain all the needed raw materials but only 100 finishing hours and 80 carpentry hours. Demand for trains is unlimited, and at most 40 soldiers can be sold each week. Company wants to maximize profit. Formulate a mathematical model of the Company’s situation that can be used to maximize weekly profit. Decision variables: X1 = number of soldiers produced each week. X2 = “ trains “ “ “ Profit = 3X1 + 2X2 Hence, Objective Function: Max Z = 3X1 + 2X2 Constraints: Total finishing hours / week = 2.(X1) + 1.(X2) = 2X1 + X2 Then, 2X1 + X2 ≤ 100 Total carpentry hours / week = 1.(X1) + 1.(X2) = X1 + X2 Then, X1 + X2 ≤ 80 Finally, at most 40 soldiers can be sold. Then, X2 ≤ 40 The following is now the LP formulation of the problem. Max Z = 3X1 + 2X2 Subject to (s.t.) 2X1 + X2 ≤ 100 X1 + X2 ≤ 80 X1 ≤ 40 X1 ≥ 0 X2≥ 0 This can now be solved to determine X1 and X2 that will maximize profit. 1 As this is a two dimensional problem, it can easily be solved graphically. 100 2X1 + X2 = 100 X1 = 40 80 A Increasing Z B Z = 120 X1 + X2 = 80 C Z = 60 O Z = 180 D 40 50 80 The feasible region is tha area covered by OABCD. The broken lines Z = 60 is obtained by assuming that Z = 3X1 + 2X2 = 60. As Z increases, the line representing Z moves in the direction indicated. If we move Z in that direction, the last point at which Z will touch the feasible region is at B. Therefore, B is the optimal solution where, X1 = 20, X2 = 60 and Z = 180. We get alternative optimal solutions if isoprofit line (represented by broken lines) is parallel to the constraint line. For example, if the objective function were changed to Z = 2X 1 + X2, the Z or isoprofit line will be parallel to line 2X1 + X2 = 100. Then, the isoprofit line will leave the feasible region along BC, in which case all the values along BC will be optimal. This will yield infinite number of optimal solutions. We may also get infeasible LP if there is no feasible region. Unbounded LP: Graphically, a maximization problem is unbounded if, when we move parallel to our isoprofit line in the direction of increasing Z, we never entirely leave the feasible region. It can be shown that the feasible region for any LP will be a convex set. 2 It can also be shown that the feasible region for any LP has only a finite number of extreme (corner) points. Furtermore, any LP that has an optimal solution has an extreme (corner) point that is optimal. This means that, in the graphical solution above, the optimal solution will be given by one of the corner points, i.e. O, A, B, C, D. (it was shown to be B). Important: The above statements reduces the set of points that yield an optimal solution from the entire feasible region (infinite number of points) to the set of extreme (corner) points (finite set). Example: Dorian makes luxury cars and jeeps for high-income men and women. It wishes to advertise with 1 minute spots in comedy shows and football games. Each comedy spot costs $50K and is seen by 7M high-income women and 2M high-income men. Each football spot costs $100K and is seen by 2M high-income women and 12M high-income men. How can Dorian reach 28M high-income women and 24M high-income men at the least cost. Let X1 = number of 1-minute comedy ads purchased X2 = number of 1-minute football ads purchased Objective function will be to minimize the total advertising cost. Then, total advertising cost = cost of comedy ads + cost of football ads = 50X1 + 100X2 Constraint 1: Commercials must reach at least 28 million high-income women Then, 7X1 + 2X2 ≥ 28 Constraint 2: Commercials must reach at least 24 million high income men. Then, 2X1 + 12X2 ≥ 24 The problem now becomes, Min Z = 50X1 + 100X2 s.t. 7X1 + 2X2 ≥ 28 2X1 + 12X2 ≥ 24 X1, X2 ≥ 0 (Graphical solution in class) 3 Example: The Dakota Furniture Co. manufactures desks, tables and chairs. The manufacture of each type of furniture requires lumber and two types of skilled labour: finishing and carpentry. The amoun of each resource needed to make each type of furniture is given below: Desk 8 4 2 Lumber, ft Finishing hours Carpentry hours Table 6 2 1.5 Chair 1 1.5 0.5 Currently, 48 ft of lumber, 20 finishing hours, and 8 carpentry hours are available. A desk sells for $60, a table for $30, and a chair for $20. Dakota believes that demand for desks and chairs is unlimited, but at most 5 tables can be sold. Because the available resources have already been purchased, Dakota wants to maximize total revenue. Let X1 = number of desks produced X2 = “ tables “ X3 = “ chairs “ If we now formulate the revenue and the constraints, we arrive at the following LP to solve. Max Z= s.t. 60X1 8X1 4X1 2X1 + 30X2 + 20X3 + 6X2 + X3 + 2X2 + 1.5X3 + 1.5X2 + 0.5X3 X2 ≤ 48 ≤ 20 ≤8 ≤5 X1, X2, X3 ≥ 0 To solve LP problems with many variables, we rely on Simplex Algorithm. This is an iterative process. We start by converting LP into standard form. (see Appendix) Then, we obtain a basic feasible solution. (see Appendix) If there are n variables and m constraints, we make (n – m) variables non-basic (NBV) by setting them equal to zero, and solve for the remaining m variables which become the basic variables (BV). We test the optimality of this solution. If optimal, stop. If not optimal, proceed to the next step. One of the non-basic variables is made basic and one of the basic variables becomes non-basic. (This process takes us to the adjacent extreme or corner point). After obtaining the new basic feasible solution optimality is tested. Procedure is repeated until optimal solution is obtained. Conversion of the LP into the standard form is about changing inequalities to equalities as it would be easier to deal with. This is done by introducing slack variables. 4 We then have the standard form ready for starting the solution process. (iteration 0) Z – Row 0 Row 1 Row 2 Row 3 Row 4 60X1 – 30X2 – 20X3 8X1 + 6X2 + X3 + S1 4X1 + 2X2 + 1.5X3 2X1 + 1.5X2 + 0.5X3 X2 =0 = 48 = 20 =8 =5 + S2 + S3 + S4 Where S1, S2, S3, and S4 are the slack variables. We have a basic feasible solution: Z = 0 and Non basic variables, NBV = (X1, X2, X3) with X1= X2 = X3 = 0 Basic variables BV = (S1, S2, S3, S4) with S1 = 48, S2 = 20, S3 = 8, and S4 = 5 The above solution satisfies all the constraints, hence it is a basic feasible solution. This is not an optimal solution since increasing X1 or X2 or X3 will increase value of Z. Therefore, as the next step, we must make one of the non-basic variables basic and one of the basic variables non-basic. Since X1 increases Z faster than X2 or X3 (most negative coefficint in row 0; -60 vs -30 or -20), we choose X1 as the entering variable. In which row should X1 enter? In row 1 we can increase X1 by 6 (=48/8) before S1 becomes –ve In row 2 we can increase X1 by 5 (=20/4) before S2 becomes –ve In row 3 we can increase X1 by 4 (=8/2) before S3 becomes –ve In row 4 no limit. Since slack variables must be non-negative (otherwise no feasible solution), we introduce X1 into row 3 as the basic variable and basic variable in row 3, i.e. S3 becomes non-basic. To make X1 basic in row 3 we use Elementery Row Operations (ERO) to have the X1 coefficient as 1 in row 3 (dividing by 2 in row 3) and zero elsewhere. Row 0’ Row 1’ Row 2’ Row 3’ Row 4’ Z + 15X2 – 5X3 - X3 + S1 - X2 + 0.5X3 X1 + 0.75X2 + 0.25X3 X2 + S2 + 30S3 - 4S3 - 2S3 + 0.5S3 + S4 = 240 = 16 =4 =4 =5 The following elementery row operations (ERO’s) are carried out to have the above equations. 5 Row 0’ = Row 0 + 60.Row 3’ Row 1’ = Row 1 – 8.Row 3’ Row 2’ = Row 2 – 4.Row 3’ Row 4’ = Row 4 as we do not have X1 in row 4. Now, BV: Z = 240, S1 = 16, S2 = 4, X1 = 4, and S4 = 5 NBV: S3, X2, and X3, all = 0 The solution is still not optimal as increasing X3 increases Z. Hence, X3 is to become basic variable. If we perform the ratio test, i.e. RHS/coefficient of entering variable (X3 here), minimum ratio is 8 at row 2’ (= 4/0.5). Then X3 enters in row 2’. After the necessary ERO’s shown below (to make the coefficient of X3 to equal 1 in row 2’ and eliminate X3 from all other equations) Row 2’’ is obtained by dividing row 2’ by 0.5. Row 0’’ = Row 0’ + 5.Row 2’’ Row 1’’ = Row 1’ + Row 2’’ Row 3’’ = Row 3’ – 0.25Row 2’’ Row 4’’ = Row 4’ as we do not have X3 in row 4. We get, Row 0’’ Row 1’’ Row 2’’ Row 3” Row 4” Z + 5X2 - 2X2 - 2X2 + X1 + 1.25X2 X2 + 10S2 + 10S3 + S1 + 2S2 - 8S3 X3 + 2S2 - 4S3 - 0.5S2 + 1.5S3 + S4 = 280 = 24 =8 =2 =5 BV = (Z, S1, X3, X1, S4) with Z = 280, S1 = 24, X3 = 8, X1 = 2, S4 = 5 NBV = (S2, S3, X2) all = 0 We now have an optimal solution to the maximization problem because all coefficients in row 0’’ are non-negative and changing any of the non-basic variables will decrease Z. Here we have a unique solution, i.e. single optimal solution with Z = 280. 6 Alternative Optimal Solutions Supposing now we had the tables selling for $35 instead of $30 in the Dakota Co. problem. Then, Z = 60X1 + 35X2 + 20X3 And same constraints as before. If we follow the procedures and solve this problem, we arrive at the final tableau shown below: Row 0’’ Row 1’’ Row 2’’ Row 3’ Row 4’ Z + - 2X2 - 2X2 + X1 + 1.25X2 X2 + 10S2 + 10S3 + S1 + 2S2 - 8S3 X3 + 2S2 - 4S3 - 0.5S2 + 1.5S3 + S4 = 280 = 24 =8 =2 =5 Here X2 is non-basic but it has zero coefficient in row 0’’. What this means is that we can change the value of X2 without affecting the value of row 0’’, i.e. Z. It also means that we can enter X2 as a basic variable and obtain another feasible solution which will still be optimal. If we enter X2 in row 3’’, the resulting solution is: Row 0’’ Row 1’’ Row 2’’ Row 3’ Row 4’ Z + + 10S2 1.6X1 + S1 + 1.2S2 1.6X1 + X3 + 1.2S2 0.8X1 + X2 - 0.4S2 - 0.8X1 + 0.4S2 + 10S3 - 5.6S3 - 1.6S3 + 1.2S3 - 1.2S3 = 280 = 27.2 = 11.2 = 1.6 + S4 = 3.4 Solution: Z = 280, S1 = 27.2, X3 = 11.2, X2 = 1.6, and S4 = 3.4 As expected, this is also an optimal solution. We have alternative optimal solution(s). Hence, if a non-basic variable has zero coefficient in row 0, then we have alternative optimal solutions. Otherwise, LP has a unique optimal solution. ( Caution: it is sometimes possible that with non-basic variable having zero coefficient in row 0, LP may not have alternative optimal solutions.) 7 Unbounded LP’s Consider the following LP problem: Max Z = 36X1 + 30X2 – 3X3 – 4X4 s.t. X1 + X2 – X3 ≤ 5 6X1 + 5X2 - X4 ≤ 10 X1, X2, X3, X4 ≥ 0 Adding slack variables S1 and S2 to the two constraints, we obtain the following at the second iteration: Z - 9X3 + 12S1 + 4S2 = 100 X2 - 6X3 + X4 + 6S1 - S2 = 20 X4 = 20 X1 + X2 - X3 + S1 =5 X1 = 5 If we try to make X3 basic variable, no positive ratio test. Whatever value we give to X3, we can not change the condition that X4 ≥ 0 and X1 ≥ 0. Hence, by increasing X3 to infinity, we increase Z to infinity. An unbounded LP. An unbounded LP for a max problem occurs when a variable with a negative coefficient in row 0 has a non-positive coefficient in each constraint. Tie Breaking in the Simplex Method Tie for the entering variable: Selection between contenders may be made arbitrarily. Optimal solution will be reached eventually. Tie for Leaving Basic Variable - Degeneracy: This situation causes degeneracy by making one of the basic variables zero and as a result, we may end up in a loop. Fortunately, it rarely occurs in practical problems. (if a loop occurs, one can get out by changing the choice of the leaving basic variable. For applications here, break this kind of tie by arbitrarily choosing one of the variables to be the leaving variable. 8 Simplex Method in Tabular Form The procedure followed is the same, only the presentation is changed along with some additional terms. We use simplex tableau to record only the essential information. The tabular form solution of the Dakota problem is given below. At iteration 0 we have the standard form LP that we obtained after adding the slack variables. From this, we obtain the entering variable as before. The column containing the entering variable is called pivot column (see shaded column containing entering variable X1). We then perform the ratio test as before and determine that X1 should enter into row 3. This row is called pivot row (see shaded area corresponding to the smallest ratio that is in row 3). The coefficient of the entering variable is the pivot number, i.e. 2 shown in bold letter. To carry out iteration 1, we first make the coefficient of the entering variable 1 by dividing both sides of row 3 by the pivot number. The resulting equation is now row 3’. Then, we carry out the following elementary row operations to complete iteration 1 with the objective of eliminating coefficients of X1 in all rows except row 3’ where it is the basic variable: Row 0’ = Row 0 + 60.Row 3’ Row 1’ = Row 1 – 8.Row 3’ Row 2’ = Row 2 – 4.Row 3’ Row 4’ = Row 4 as we do not have X1 in row 4. From the result of iteration 1 we determine the new entering variable, i.e. X3, which should enter into row 2’. (see shaded pivot column and pivot row with the pivot number of 0.5). Again, as in the procedure above, iteration 2 starts by making coefficient of X3 equal 1 in row row 2’’. (divide row 2’ by the pivot number, i.e.0.5 to obtain row 2’’). To complete iteration 2, we carry out the following ERO’s to eliminate coefficients of X3 in all rows except row 2’’: Row 0’’ = Row 0’ + 5.Row 2’’ Row 1’’ = Row 1’ + Row 2’’ Row 3’’ = Row 3’ – 0.25Row 2’’ Row 4’’ = Row 4’ as we do not have X3 in row 4. 9 Solution of Dakota Problem in Tabular Form Iter. Basic Variable Z Equ.n No. 0 S1 0 1 2 Z X1 X2 X3 S1 S2 S3 S4 RHS 1 -60 -30 -20 0 0 0 0 0 1 0 8 6 1 1 0 0 0 48 S2 2 0 4 2 1.5 0 1 0 0 20 S3 3 0 2 1.5 0.5 0 0 1 0 8 S4 4 0 0 1 0 0 0 0 1 5 Z 0’ 1 0 15 -5 0 0 30 0 240 S1 1’ 0 0 0 -1 1 0 -4 0 16 S2 2’ 0 0 -1 0.5 0 1 -2 0 4 X1 3’ 0 1 0.75 0.25 0 0 0.5 0 4 S4 4’ 0 0 1 0 0 0 0 1 5 Z 0’’ 1 0 5 0 0 10 10 0 280 S1 1’’ 0 0 -2 0 1 2 -8 0 24 X3 2’’ 0 0 -2 1 0 2 -4 0 8 X1 3’’ 0 1 1.25 0 0 -0.5 1.5 0 2 S4 4’’ 0 0 1 0 0 0 0 1 5 As we can see, after iteration 2 optimal solution is obtained with: Z = 280 S1 = 24 X3 = 8 X1 = 2 S4 = 5 10 S2 = S3 = X2 = 0 Ratio 48/8 =6 20/4 =5 8/2 = 4 No limit No ratio 4/0.5 =8 4/0.25 = 16 No ratio Solving Minimization Problems Min Z = 2X1 – 3X2 Ex. s.t. X1 + X2 ≤ 4 X1 – X2 ≤ 6 X1, X2 ≥ 0 Method 1: Min Z above is equivalent to Max (– Z) = -2X1 + 3X2 Then, LP problem is: Max - Z = - 2X1 + 3X2 s.t. X1 + X2 ≤ 4 X1 – X2 ≤ 6 X1, X2 ≥ 0 In standard form, -Z + 2X1 – 3X2 =0 X1 + X2 + S1 =4 X1 – X2 + S2 = 6 BV -Z S1 S2 -Z 1 0 0 X1 2 1 1 X2 -3 1 -1 S1 0 1 0 S2 0 0 1 RHS 0 4 6 -Z X2 S2 1 0 0 5 1 2 0 1 0 3 1 1 0 0 1 12 4 10 Solution: -Z = 12 or Z = 12, X2 = 4, and S2 = 10 11 Ratio 4/1=4 enters in this row - Method 2: In max. problem, we looked at the coefficients of the non-basic variables in row 0. If they were all positive, we had optimal solution. For min. problem, we again check the nonbasic variables’ coefficients. Minimum Z is obtained if all non-basic variable coefficients are negative. If there are positive coefficients, we choose the one with the “most positive” coefficient to enter the basis. We then continue as before. In standard form, Z - 2X1 + 3X2 =0 X1 + X2 + S1 =4 X1 – X2 + S2 = 6 BV Z S1 S2 -Z 1 0 0 X1 -2 1 1 X2 3 1 -1 S1 0 1 0 S2 0 0 1 RHS 0 4 6 Z X2 S2 1 0 0 -5 1 2 0 1 0 -3 1 1 0 0 1 -12 4 10 Solution: Ratio 4/1=4 X2 enters in this row - Z = 12, X2 = 4, and S2 = 10 Adapting to Other Model Forms Consider the following example: s.t. Min Z = 2X1 + 3X2 (1/2)X1 + (1/4)X2 ≤ 4 X1 + 3X2 ≥ 20 X1 + X2 = 10 X1, X2 ≥ 0 (A) Putting this into standard form: Min Z – 2X1 -3X2 (1/2)X1 + (1/4)X2 + s1 X1 + 3X2 - e2 X1 + X2 =0 =4 = 20 = 10 (1) (2) (3) All variables are non-negative and s1 is the slack variable and e2 is the excess variable. Searching for basic feasible solution, row (1) is fine with s1 = 4. In row (2), multiplying both sides by (-1), e2 = -20 may be taken as a basic variable. Unfortunately this violates the sign restriction e2 ≥ 0. Finally, in row (3) there is no readily apparent basic variable. To solve this 12 LP we need a basic feasible solution (bfs). This bfs we obtain by introducing artificial variables. Then, Z – 2X1 -3X2 (1/2)X1 + (1/4)X2 + s1 X1 + 3X2 - e2 + a2 X1 + X2 row (0) row (1) row (2) row(3) + a3 =0 =4 = 20 = 10 (B) All variables are non-negative and a2, a3 are artificial variables. We now have a bfs: Z = 0, s1 = 4, a2 = 20, and a3 = 10. To proceed to the solution, we may follow either of the following two methods. Method 1. Big M method The problem here is that by introducing artificial variables, we have also changed the problem. We may obtain an optimal solution to this LP. But, if one or more of the artificial variables are positive, such a solution may not be feasible for the original problem (A). Therefore, we have to make sure that in obtaining the optimal solution we also force the values of the artificial variables to zero. In a minimization problem, we can ensure that all the artificial variables will be zero by adding a term Mai to the objective function for each artificial variable ai. (In a max. problem, add a term – Mai to the objective function). Here “M” represents a “very large” positive number. (The method of solving LP’s by this way is therefore called “Big M method”). Thus, we have, as objective function. Z = 2X1 + 3X2 + Ma2 + Ma3 Then, row (0) row (1) row (2) row(3) Z – 2X1 -3X2 – Ma2 – Ma3 (1/2)X1 + (1/4)X2 + s1 X1 + 3X2 - e2 + a2 X1 + X2 + a3 =0 =4 = 20 = 10 Since we have a2 and a3 as basic variables, we cannot have non-zero coefficients for a2 and a3 in row (0). We must eliminate them from row 0 through elementary row operations (ERO’s): New row 0 = current row 0 + M(row 2) + M(row 3) yields: Z + (2M – 2)X1 + (4M – 3)X2 – Me2 = 30M 13 Then, the initial tableau (iteration 0) becomes: Row BV Z X1 X2 s1 e2 a2 a3 RHS 0 1 2 3 Z s1 a2 a3 1 0 0 0 2M-2 1/2 1 1 4M-3 1/4 3 1 0 1 0 0 -M 0 -1 0 0 0 1 0 0 0 0 1 30M 4 20 10 Largest +ve coefficient = 4M – 3. Therefore, X2 should enter the basis. Min ratio is at row 2. Then, X2 enters in row 2. With the following ERO’s we carry out iteration 1 to determine the new tableau: Row2’ = (1/3).row 2 Row 0’ = row 0 – (4M – 3).row 2 Row 1’ = row 1 – (1/4).row 2’ Row 3’ = row 3 – row 2’ (to eliminate X2 from row 0’) (eliminates X2 from row 1’) (eliminates X2 from row 3’) Row 0’ 1’ 2’ 3’ s1 0 1 0 0 BV Z s1 X2 a3 Z X1 X2 1 (2M-3)/3 0 0 5/12 0 0 1/3 1 0 2/3 0 e2 (M-3)/3 1/12 -1/3 1/3 a2 (3-4M)/3 -1/12 1/3 -1/3 a3 0 0 0 1 RHS (60+10M)/3 7/3 20/3 10/3 Since we have +ve coefficients of non-basic variables in row 0’, we do not have an optimal solution. (2M-3)/3 for X1 is the largest +ve coefficient. Hence, X1 enters the basis and it should be into row 3’ (min. ratio). With the following ERO’s, we perform iteration 2 and obtain the new tableau: Row 3” = row 3’/(2/3) Row 0” = row 0’ – [(2M – 3)/3].row 3” Row 1” = row 1’ – (5/12).row 3”” Row 2” = row 2’ – (1/3).row 3” Row 0” 1” 2” 3” BV Z s1 X2 X1 Z 1 0 0 0 X1 0 0 0 1 X2 0 0 1 0 s1 0 1 0 0 e2 -1/2 -1/8 -1/2 1/2 a2 (1-2M)/2 1/8 1/2 -1/2 a3 RHS (3-2M)/2 25 -5/8 1/4 -1/2 5 3/2 5 This is now an optimal solution since we do not have any +ve coefficients in row 0”. Optimal solution: Z = 25, s1 = 1/4, X2 = 5, and X1 = 5 with the non-basic variables e2=a2=a3=0. Note: Artificial variables are zero. If any artificial variable is positive in the big M tableau, then the original LP has no feasible solution. 14 Method 2. The Two-Phase Method After setting up the equations by adding slack, excess, and artificial variables, we solve the problem in two phases instead of the big M method. Phase I: The objective here is to find a bfs for the real problem. We change the objective function to Min Z = ∑ artificial variables s.t. same constraints as the real problem. Optimal solution obtained for this problem ( if Z = 0) will be a bfs for the real problem. If Z is not zero in this solution, then the real problem does not have a feasible solution. Phase II: Objective here is to find an optimal solution to the real problem. Solution to phase I has artificial variables with zero values. They can now be dropped as they are not part of the real problem. Then, starting with the bfs obtained at the end of phase I, use simplex method to solve the real problem. Ex. s.t. Min Z = 4X1 + X2 3.X1 + X2 = 3 4.X1 + 3.X2 ≥ 6 X1 + 2.X2 ≤ 4 X1, X2 ≥ 0 The constraints, after adding slack, excess (surplus), and artificial variables: 3.X1 + X2 + a1 =3 4.X1 + 3.X2 - e2 + a2 =6 X1 + 2.X2 + s3 = 4 X1, X2, a1, a2, e2, s3 ≥ 0 Phase I: Min W = a1 + a2 3.X1 + X2 + a1 =3 4.X1 + 3.X2 - e2 + a2 =6 X1 + 2.X2 + s3 = 4 Tableau is then, BV W X1 X2 a1 e2 a2 s3 RHS W a1 a2 s3 1 0 0 0 0 3 4 1 0 1 3 2 -1 1 0 0 0 0 -1 0 -1 0 1 0 0 0 0 1 0 3 6 4 15 row 0 row 1 row 2 row 3 As in the Big M method, a1 and a2 are basic variables; they have to be eliminated from row 0 by, New row 0 = current row 0 + 1. Row 1 + 1. Row 2 Then choosing entering variable, leaving variable as in simplex method, solve the problem. After some iterations the following optimal tableau is obtained. BV W X1 X2 a1 e2 a2 s3 RHS W X1 X2 s3 1 0 0 0 0 1 0 0 0 0 1 0 -1 3/5 -4/5 1 0 1/5 -3/5 1 -1 -1/5 3/5 -1 0 0 0 1 0 3/5 6/5 1 Because Min W = 0, phase I produces the bfs with X1 = 3/5, X2 = 6/5, and s3 = 1. We can now eliminate the artificial variable columns and proceed to phase II. Phase II. After deleting artificial variable columns, the original problem becomes, Min Z = 4.X1 + X2 s.t. X1 + e2/5 X2 – 3.e2/5 e2 + s3 = 1 All variables ≥ 0. Resulting tableau is: BV Z X1 X2 e2 s3 = 3/5 = 6/5 RHS Z 1 -4 -1 0 0 0 X1 0 1 0 1/5 0 3/5 X2 0 0 1 -3/5 0 6/5 s3 0 0 0 1 1 1 X1, X2 are BV’s. Need to be eliminated from row 0: New row 0 = current row 0 + 4.row1 + 1.row 2 row 0 row 1 row 2 row 3 Initial tableau is then, BV Z X1 X2 e2 s3 RHS Z X1 X2 s3 1 0 0 0 0 1 0 0 0 0 1 0 1/5 1/5 -3/5 1 0 0 0 1 18/5 3/5 6/5 1 row 0 row 1 row 2 row 3 Since we are minimizing, e2 must enter the basis (e2 has +ve coefficient in row 0). It should be into row 3. 16 After the needed ERO’s to eliminate e2 from rows 0, 1, and 2, we arrive at the next tableau. As seen, it is the optimal solution. BV Z X1 X2 e2 s3 RHS Z X1 X2 e2 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 -1/5 -1/5 3/5 1 17/5 2/5 9/5 1 Z = 17/5, X1 = 2/5, X2 = 9/5, row 0 row 1 row 2 row 3 e2 = 1, and s3 = 0 Unrestricted-in-sign (urs) Variables For each urs variable Xi, we begin by defining two new variables Xi’ and Xi”. Then, substitute (Xi’ – Xi”) for Xi in each constraint and objective function. Also, we add the sign restrictions Xi’ ≥ 0 and Xi” ≥ 0 (we are expressing Xi as the difference of two non-negative variables). After replacing Xi by (Xi’ – Xi”), we proceed with simplex method as all variables are now non-negative. It is to be noted that both Xi’ and Xi” cannot be basic variables at the same time. Ex. Max Z = 30.X1 – 4.X2 s.t. 5.X1 ≤ 30 + X2 X1 ≤ 5 X1 ≥ 0, X2 urs Substituting X2 = X2’ – X2” and putting the problem in standard form: Z – 30.X1 + 4.X2’ – 4.X2” 5.X1 – X2’ + X2” + s1 X1 + X1, X2’, X2”, s1, s2 ≥ 0 Initial Tableau: BV Z X1 X2’ X2” Z 1 -30 4 -4 s1 0 5 -1 1 s2 0 1 0 0 =0 = 30 + s2 = 5 s1 0 1 0 s2 0 0 1 17 RHS 0 30 5 Ratio 30/5=6 5/1 row 0 row 1 row 2 X1 enters and s2 leaves. Eliminating X1 from rows 0 and 1, BV Z s1 X1 Z 1 0 0 X1 0 0 1 X2’ 4 -1 0 X2” -4 1 0 s1 0 1 0 s2 30 -5 1 RHS 150 5 5 row 0 row 1 row 2 0 -1 0 0 1 0 4 1 0 10 -5 1 170 5 5 row 0 row 1 row 2 X2” enters and s1 leaves, Z X2” X1 1 0 0 0 0 1 This is now the optimal solution with Z = 170, X2” = 5, X1 = 5, X2’=s1=s2= 0. Because X2 = X2’ – X2” = 0 – 5 = -5. Note: Notice that the X2’ column is always the negative of X2” column. Then, both cannot have values of 1 at the same time in any row. Therefore, both cannot be BV at the same time. Variable with a Bound on the –ve Value Allowed Suppose constraint is This can be converted to: Xj ≥ Lj where Lj is some –ve constant Xj’ = Xj – Lj, so Xj’ ≥ 0. Then, (Xj’ + Lj) would be substituted for Xj throughout model. 18 APPENDIX How to Convert an LP to Standard Form Ex. Max Z = 4x1 + 3x2 s.t. x1 + x2 ≤ 40 2x1 + x2 ≤ 60 x1, x2 ≥ 0 Add slack variables to make all constraints equalities and all variables ≥ 0. x1 + x2 + s1 = 40 2x1 + x2 + s2 = 60 x1, x2, s1, s2 ≥ 0. where s1 and s2 are called slack variables. Ex. If we have a constraint of the form, 3x1 + 2x2 ≥ 6 Then, 3x1 + 2x2 – e = 6 Again, in addition to x1, x2, e ≥ 0, where e is called ‘excess variable’. Basic and Nonbasic Variables Assuming we are solving a max. problem. LP has m constraints and n variables. (Some of them may be slack, excess, or artificial).( n > m). We label variables X1, X2, ....Xn. Then, LP is, s.t. Max. Z = c1X1 + c2X2 + ......... a11X1 + a12X2 + a21X1 + a22X2 + + cnXn + a1nXn = b1 + a2nXn = b2 am1X1 + am2X2 + Xi ≥ 0 ( i = 1, 2, ... n) In the matrix and vector form, AX = b where A = + amnXn = bm (&) a11 a21 a12 a22 ............ .............. a1n a2n am1 am2 ............. amn X = X1 X2 .... Xn b= b1 b2 .... bm 19 To find a basic solution to AX = b, we choose (n – m) variables (non-basic variables, NBV) and set each to zero. Then we solve for the values of the remaining n – (n – m) = m variables (the basic variables, BV) that satisfy AX = b. Of course, different choices of non-basic variables will lead to different basic solutions. e.g. x1 + x2 = 3 -x2 + x3 = -1 If x3 is NBV, then x3 = 0 and solution is: x1 = 2, x2 = 1. Basic solution is: x1 = 2, x2 = 1, x3 = 0 which is a basic feasible solution. If x1 is NBV, then x1 = 0 and solution is: x2 = 3, x3 = 2. Basic solution is: x1 = 0, x2 = 3, x3 = 2 which is a basic feasible solution. If x2 is NBV, then x2 = 0 and solution is: x1 = 3, x3 = -1. Basic solution is: x1 = 3, x2 = 0, x3 = -1 which is a not a basic feasible solution since x3 is negative. Some set of variables do not yield a basic solution. Any basic solution to (&) in which all variables are non-negative is a basic feasible solution. 20