5. Finding the Dual of an LP and Dual Theorem Associated with any LP is another LP, called the dual. Knowing the relation between the two is vital to understanding advanced topics in LP and NLP. The relationship gives us interesting economic insights and provide additional insights into sensitivity analysis. The LP is referred to as the primal. If primal is a max. problem, the dual is a min. problem and vice versa. LP is considered in normal form as: Max Z = c1X1 + c2X2 + s.t. a11X1 + a12X2 + a21X1 + a22X2 + ... ... am1X1 + am2X2 + cnXn + a1nXn ≤ b1 + a2nXn ≤ b2 + amnXn ≤ bm Xj ≥ 0 ( j = 1, 2, .......n) The dual of a normal max. problem is defined to be: s.t. Min W = b1y1 + b2y2 + a11y1 + a21y2 + a12y1 + a22y2 + ...... ...... a1ny1 + a2ny2 + bmym + am1ym ≥ c1 + am2ym ≥ c2 + amnym ≥ cn yi ≥ 0 (i = 1, 2, ......m) A min. problem such as above is called a normal min problem. Considering the Dakota problem: Z= 60X1 + 30X2 + 20X3 8X1 + 6X2 + X3 ≤ 48 4X1 + 2X2 + 1.5X3 ≤ 20 2X1 + 1.5X2 + 0.5X3 ≤ 8 X1, X2, X3 ≥ 0 where X1 : desks X2 : tables X3: chairs The Dakota dual is: s.t. Min W = 48y1 + 20y2 + 8y3 8y1 + 4y2 + 2y3 ≥ 60 6y1 + 2y2 + 1.5y3 ≥ 30 y1 + 1.5y2 + 0.5y3 ≥ 20 y1, y2, y3 ≥ 0 1 ( lumber constraint) ( finishing constraint) (carpentry constraint) It can also be read from the following tableau: Max Z Min W X1 ≥ 0 X2 ≥ 0 X3 ≥ 0 y1 ≥ 0 y1 X1 8 X2 6 X3 1 ≤ 48 y2 ≥ 0 y2 4 2 1.5 ≤ 20 y3 ≥ 0 y3 2 1.5 0.5 ≤8 ≥ 60 ≥ 30 ≥ 20 It is clear that the ith dual constraint corresponds to the ith primal variable Xi. Finding Dual of Non Normal LP (Max Problem) For example, consider the following problem, s.t. Max Z = 2X1 + X2 X1 + X2 = 2 2X1 – X2 ≥ 3 X1 – X2 ≤ 1 X1 ≥ 0, X2 urs (A) We can convert this problem into standard form: Replace X1 + X2 = 2 by X1 + X2 ≤ 2 and X1 + X2 ≥ 2 Replace X1 + X2 ≥ 2 by –X1 – X2 ≤ -2 (Multiply both sides by -1) Replace 2X1 – X2 ≥ 3 by For X2 urs, replace X2 -2X1 + X2 ≤ -3 by X2’ – X2’’ Then, we have, Max Z = 2X1 + X2’ – X2’’ s.t. X1 + X2’ – X2’’ ≤ 2 -X1 – X2’ + X2’’ ≤ -2 -2X1 + X2’ – X2’’ ≤ -3 X1 – X2’ + X2’’ ≤ 1 X1, X2’, X2’’ ≥ 0 This is now a normal max problem for which we can write the dual: Min W = 2y1’ – 2y1” – 3y2’ + y3 s.t. y1’ – y1” – 2y2’ + y3 ≥ 2 y1’ – y1” + y2’ – y3 ≥ 1 - y1’ + y1” – y2’ + y3 ≥ - 1 y1’, y1”- y2’, y3 ≥ 0 We may now substitute y1 = y1’ – y1” where now y1 has urs. 2 Also, y1 + y2’ – y3 ≥ 1 and - y1 – y2’ + y3 ≥ -1 is same as y1 + y2’ – y3 = 1 We may also substitute y2 = - y2’ where now y2 ≤ 0 Then, the dual becomes: s.t. Min W = 2y1 + 3y2 + y3 y1 + 2y2 + y3 ≥ 2 y1 – y2 – y3 = 1 y1 urs, y2 ≤ 0, y3 ≥ 0. We can summarize the rules as: - if the ith primary constraint is a ≥ constraint, then the corresponding dual variable yi must satisfy yi ≤ 0. - if the ith primal constraint is an equality constraint, then the dual variable yi is now unrestricted in sign. - if the ith primal variable is urs, then the ith dual constraint will be an equality constraint. Dual of a Non normal Min Problem Consider, Min W = 2y1 + 4y2 + 6y3 s.t. y1 + 2y2 + y3 ≥ 2 y1 - y3 ≥ 1 y2 + y3 = 1 2y1 + y2 ≤3 y1 urs, y2, y3 ≥ 0. The rules are symmetrical. Then, Dual will be Max Z = 2X1 + X2 + X3 + 3X4 s.t. X1 + X2 + 2X4 = 2 2X1 + X3 + X4 ≤ 4 X1 – X2 + X3 ≤6 X1, X2 ≥ 0, X3 urs, X4 ≤ 0. Economic Interpretation of the Dual Problem Suppose we are interested in purchasing all of Dakota’s resources. Then, we must determine the price we are willing to pay for a unit of each of Dakota’s resources. With this in mind, we define, y1 = price paid for 1 board ft of lumber y2 = price paid for 1 finishing hour y3 = price paid for 1 carpentry hour y1, y2, y3 represent the resource prices and are determined by solving the dual. 3 Because cost of purchasing the resources is to be minimized, objective function of the dual becomes, Min W = 48y1 + 20y2 + 8y3 If we are interested in taking over the Dakota Co. resources, we must offer attractive prices. For desks, for example, resources used to produce a desk is, (8y1 + 4y2 + 2y3); since Dakota can sell desks for $60, to make it attractive, 8y1 + 4y2 + 2y3 ≥ 60. Similarly, for tables, 6y1 + 2y2 + 1.5y3 ≥ 30, and, for chairs, y1 + 1.5y2 + 0.5y3 ≥ 20 Weak Duality and Dual Theorem (a) Let X = X1 X2 ... Xn be any feasible solution to the primal and y = [y1 y2 ............. ym] be any feasible solution to the dual. Then, from weak duality, (Z value for X) ≤ (W value for y) i.e. A feasible solution to one puts a bound on the other. e.g. For Dakota, X1 = X2 = X3 = 1 is a feasible solution. Then, Z = 60 + 30 + 20 = 110 Then, W = 48y1 + 20y2 + 8y3 ≥ 110 Similarly for dual. (b) Let X= and y = [ y1 X1 X2 ... Xn i.e. optimal W value for the dual ≥ 110. be a feasible solution to the primal y2 ............. ym] be a feasible solution to the dual. If cX = yb, then X is optimal for the primal and y is optimal for the dual. Weak duality can also be used to prove the following results: - If the primal is unbounded, then the dual problem is infeasible. - If the dual is unbounded, then the primal is infeasible. 4 Dual Theorem Suppose BV is an optimal basis for the primal. Then, cBVB-1 is an optimal solution to the dual. Also, Z = W (or, A basis BV that is feasible for the primal is optimal if and only if cBVB-1 is dual feasible) Based on this, we can say that when we find the optimal solution to the primal by using simplex algorithm, we have also found the optimal solution to the dual. To see why this is true, Dual theorem tells us that cBVB-1 = [y1 y2 ......ym] is the optimal solution to the dual. Recall also that coefficient of the slack variable Si in row 0 = ith element of cBVB-1 in a normal max problem. Thus, if the primal is a normal max problem, then the optimal value of the ith dual variable is the coefficient of Si in row 0 of the optimal primal tableau. Considering the Dakota optimum tableau: Z + 5X2 - 2X2 - 2X2 + X1 + 1.25X2 + 10S2 + 10S3 + S1 + 2S2 - 8S3 X3 + 2S2 - 4S3 - 0.5S2 + 1.5S3 = 280 = 24 =8 =2 Then, the optimal dual solution is, y1 = 0, y2 = 10, y3 = 10 (i.e. coefficients of Si in row 0) and W = 48(0) + 20(10) + 8(10) = 280 indicated by the dual theorem. which agrees with primal Z value, as also If we wish to determine dual variables directly, [y1 y2 y3] = cBVB-1 = [0 20 60] 1 0 0 2 2 -0.5 -8 = [0 -4 1.5 10 10] How to Read the Optimal Dual Solution from Row 0 of Optimal Tableau if the Primal is a Max. Problem Optimal value of dual variable yi: if constraint is a ≤ constraint yi = coefficient of Si in optimal row 0 if constraint is a ≥ constraint yi = - (coefficient of ei in optimal row 0) if constraint is an equality constraint yi = (coefficient of ai in optimal row 0) – M Example: Max Z = 3X1 + 2X2 + 5X3 s.t. X1 + 3X2 + 2X3 ≤ 15 2X2 – X3 ≥ 5 2X1 + X2 – 5X3 = 10 X1, X2, X3 ≥ 0 5 Optimal tableau for the above example is as given below: Z X1 X2 X3 S1 e2 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 51/23 4/23 2/23 9/23 58/23 5/23 -9/23 17/23 The dual is: a2 M-58/23 -5/23 9/23 -17/23 a3 RHS M+9/23 -2/23 -1/23 7/23 565/23 15/23 65/23 120/23 Min W = 15y1 + 5y2 + 10y3 y1 + 2y3 ≥ 3 3y1 + 2y2 + y3 ≥ 2 2y1 – y2 – 5y3 ≥ 5 y1 ≥ 0, y2 ≤ 0, y3 urs s.t. Then, First constraint ≤ , y1 = 51/23 (coeff.of S1) 2nd constraint ≥ , y2 = -58/23 - (coeff. of e2) 3rd constraint = , y3 = (M + 9/23) – M = 9/23 (coeff. of a3) By dual theorem, W = 565/23 Another way of computing the optimal values of the dual variables is by using the following relationship: Optimal primal Z coefficient (reduced cost) of any variable Xj = Left-hand side of the jth dual constraint Right-hand side of the jth dual constraint For the above example, we can then write: For X1, 0 = y1 + 2y3 – 3 For X2, 0 = 3y1 + 2y2 + y3 – 2 For X3 0 = 2y1 –y2 – 5y3 – 5 Solution of these equations yield, same as above. y1 = 51/23, y2 = -58/23, y3 = 9/23 which are the Similarly, for the Dakota problem we can write, For X2, 5 = 6y1 + 2y2 + 1.5y3 – 30 For X1, 0 = 8y1 + 4y2 + 2y3 – 60 For X3, 0 = y1 + 1.5y2 + 0.5y3 – 20 Solution of these equations yield, the results obtained above. y1 = 0, y2 = 10, and 6 y3 = 10 which agrees with If Primal is a Min Problem Optimal value of dual variable Xi: if constraint is a ≤ constraint if constraint is a ≥ constraint if constraint is an equality constraint Xi = coefficient of Si in optimal row 0 Xi = - (coefficient of ei in optimal row 0) Xi = (coefficient of ai in optimal row 0) + M Shadow Prices The shadow price of the ith constraint is the amount by which the optimal Z-value is improved (increased in a max problem and decreased in a min problem) if we increase bi by 1 (from bi to bi + 1). It can be shown that (p. 314) the shadow price of the ith constraint of a max problem is the optimal value of the ith dual variable. Note: For a ≤ constraint shadow price ≥ 0 ≥ “ “ “ ≤0 = “ “ “ urs Then, assuming the current basis remains optimal, new Z–value for an increase of Δbi, For max., New optimal Z-value = Old optimal value + Δbi(constraint i shadow price) For min., New optimal Z-value = Old optimal value - Δbi(constraint i shadow price) Example. Steelco has received an order for 100 tons of steel. The order must contain at least 3.5 tons of nickel, at most 3 tons of carbon, and exactly 4 tons of manganese. Steelco receives $20/ton for the order. To fill the order, Steelco can combine four alloys, whose chemical composition is given below. Steelco wants to maximize the profits obtained from filling the order. Formulate the appropriate LP. Also, find and interpret the shadow prices for each constraint. Alloy (%) 1 2 3 4 Nickel Carbon Manganese Cost / ton ($) 6 3 8 12 3 2 3 10 2 5 2 8 1 6 1 6 Let Xi = number of tons of alloy i used to fill order. Then, Max. Z = (20 – 12)X1 + (20 – 10)X2 + (20 – 8)X3 + (20 – 6)X4 s.t. 0.06X1 + 0.03X2 + 0.02X3 + 0.01X4 0.03X1 + 0.02X2 + 0.05X3 + 0.06X4 0.08X1 + 0.03X2 + 0.02X3 + 0.01X4 X1 + X2 + X3 + X4 X1, X2, X3, X4 ≥ 0 7 ≥ 3.5 ≤ 3 = 4 = 100 Nickel constraint Carbon constraint Mn constraint Order size Subtracting excess variable e1 and adding artificial variable a1, adding slack variable S2, adding artificial variable a3, adding artificial variable a4, we obtain the optimal solution: Z = 1000, and row 0 is, S2 = 0.25, X1 = 25, X2 = 62.5, X4 = 12.5, e1 = 0, X3 = 0 Z + 400e1 + (M – 400)a1 + (M + 200)a3 + (M + 16)a4 = 1000 Shadow price of nickel const. = -(coeff. of e1) = - 400 “ “ “ carbon “ = ( coeff. of S2) = 0 “ “ “ Mn “ = (coeff. of a3) – M = 200 “ “ “ Size “ = (coeff. of a4) – M = 16 For nickel, sensitivity analysis on b1 (= 3.5) will show that solution is optimal if 3.46 ≤ b1 ≤ 3.6. Increase of Δb1 by, for example, (3.55 – 3.5) = 0.05 increase profits (Z) by, - 400(0.05) = - $20 (actually decreases since increasing nickel forces us to use more expensive alloy 1). For carbon, 2.75 ≤ b2 ≤ ∞ still optimal. Change in b2 will not change Z as shadow price for carbon = 0. For Mn, 3.83 ≤ b3 ≤ 4.07 still optimal. Suppose Δb3 = 0.05, increase in Z-value = 200(0.05) = $10 For order size, 91.67 ≤ b4 ≤ 103.12 still optimal. If order is 103 tons, i.e. Δb4 = 3, Then Z-value will increase by (16)3 = $48 8 Other Examples for Shadow Prices (From Winston) 6.8.5. A company manufactures two products (1 and 2). Each unit of product 1 can be sold for $15, and each unit of product 2 for $25. Each product requires raw material and two types of labor (skilled and unskilled) (see Table 29). Currently, the company has available 100 hours of skilled labor, 70 hours of unskilled labor, and 30 units of raw material. Because of marketing considerations, at least 3 units of product 2 must be produced. a) Explain why the company’s goal is to maximize revenue. b) The relevant LP is max z = 15x1 + 25x2 s.t. 3x1 + 4x2 ≤ 100 s.t. 2x1 + 3x2 ≤ 70 s.t. x1 + 2x2 ≤ 30 s.t. 2x1 _ 2 x2 ≥ 3 x1, x2 ≥ 0 (Skilled labor constraint) (Unskilled labor constraint) (Raw material constraint) (Product 2 constraint) The optimal tableau for this problem has the following row 0: z + 15s3 + 5e4 + (M - 5)a4 = 435 The optimal solution to the LP is z = 435, x1 = 24, x2 = 3. Find and interpret the shadow price of each constraint. How much would the company be willing to pay for an additional unit of each type of labor? How much would it be willing to pay for an extra unit of raw material? c) Assuming the current basis remains optimal (it does), what would the company’s revenue be if 35 units of raw material were available? d) With the current basis optimal, what would the company’s revenue be if 80 hours of skilled labor were available? e) With the current basis optimal, what would the company’s new revenue be if at least 5 units of product 2 were required? How about if at least 2 units of product 2 were required? 6.8.6. Suppose that the company in Problem 5 owns no labor and raw material but can purchase them at the following prices: as many as 100 hours of skilled labor at $3/hour, 70 hours of unskilled labor at $2/hour, and 30 units of raw material at $1 per unit of raw material. If the company’s goal is to maximize profit, show that the appropriate LP is max z = x1 + 5x2 s.t. s.t. s.t. s.t. 2x21 _ s.t. 2 _ 3x1, x2 ≥ 0 3x1 + 4x2 ≤ 100 2x1 + 3x2 ≤ 70 x1 + 2x2 ≤ 30 2x2 ≥ 3 The optimal row 0 for this LP is z + 1.5x1 + 2.5s3 + Ma4 = 75 and the optimal solution is z = 75, x1 = 0, x2 = 15. In answering parts (a) and (b), assume that the current basis remains optimal. a) How much should the company pay for an extra unit of raw material? b) How much should the company pay for an extra hour of skilled labor? Unskilled labor? (Be careful here!) 9 10 Duality and Sensitivity Analysis Considering again the Dakota problem. The optimal solution was, Z = 280, S1 = 24, X3 = 8, X1 = 2, X2 = S2 = S3 = 0 The solution to the dual, and hence, the constraints’ shadow prices were, y1 = 0, y2 = 10 y3 = 10 Changing Objective Function Coefficient of Nonbasic Variable Let us consider X2 (tables) where c2 is the price a table is sold for. For what values of c2 will the current basis remain optimal? If y1 = 0, y2 = 10, y3 = 10 remains dual feasible, then the current basis, and the values of all variables, are unchanged. If c2 is changed, first and 3rd constraints remain unchanged. For the second, dual constraint is, 6y1 + 2y2 + 1.5y3 ≥ c2 If values of y1, y2, and y3 satisfy this inequality, then dual feasibility (primal optimality) is maintained. 6(0) + 2(10) + 1.5(10) ≥ c2 or c2 ≤ 35 For this value, current basis remain optimal. 11 Note: $35 is the cost of resources used for making a table as derived from, 0(6) + 10(2) + 10(1.5) = 35. Revenue increases if table sells for > $35 and hence, we do not have optimality. Entering X2 into basis (manufacturing tables) will improve revenue. Note also that the same results were obtained in the earlier method of sensitivity analysis. Changing the Column of a Nonbasic Variable We want to change the column for a nonbasic variable. Suppose a table sells for $43 and uses 5 board ft of lumber, 2 finishing hours, and 2 carpentry hours. Does the current basis remain optimal? The changes leave the first and third dual constraints unchanged. The second dual constraint changes to, 5y1 + 2y2 + 2y3 ≥ 43 y1 = 0, y2 = 10, y3 = 10 does not satisfy this and hence, current basis is no longer optimal. Analysis show that each table uses 0(5) + 10(2) + 10(2) = $40 of resources. Therefore, selling it for $43 increases revenue by (43 – 40) = $3 per table (X2). X2 will be basic in the new optimal solution. Adding a New Activity Introducing foot stools (X4) which sells for $15 and uses 1 board ft of lumber, 1 finishing hour, and 1 carpentry hour; do we still have optimality? Dual constraints one to three remain same but a fourth one is added. y1 + y2 + y3 ≥ 15 For y1 = 0, y2 = 10, y3 = 10 satisfies the new dual constraint. Hence, the current basis remains optimal. It costs 1(0) + 1(10) + 1(10) = $20 to make a foot stool. Selling it for $15 is not worthwhile. Therefore, solution is still optimal. 12 Complementary Slackness We have a normal max problem with variables Xi (i = 1, 2......n) and slack variables Sj (j=1,2,......m). Then, dual is normal with variables y1, y2,.......ym and e1, e2,.....en as excess variables. Let X = X1 be a feasible primal solution X2 ... Xn and y = [y1 y2 .........ym] be a feasible dual solution. Then, X is primal optimal and y is dual optimal if and only if, Siyi = 0 (i = 1, 2, ..... m) ejXj = 0 (j = 1, 2, .......n) What does it mean? ith primal slack > 0 implies ith dual variable = 0 ith dual variable > 0 implies ith primal slack = 0 jth dual excess > 0 implies jth primal variable = 0 jth primal variable > 0 implies jth dual excess = 0 13