Chapter 9 If one would take statistics about which mathematical problem is using most of the computer time in the world (not including data base handling problems like sorting and searching) the answer would probably be linear programming.—Laslo Lavasz 1 Linear Programming Applications and Computer Solutions Product-Mix Selection 2 Let XE, XL, XR, XS, and XM denote the number of extra-large, large, regular, small, and miniature modules to assemble. Maximize P = 58XE + 43XL + 25XR + 17XS + 28XM Subject to: 58XE + 43XL + 25XR + 17XS + 28XM < 50,000 (PC bd) 25XE + 15XL + 10XR + 5XS + 1XM < 10,000 (res. A) 52XE + 48XL + 40XR + 60XS + 75XM < 25,000 (res. B) 1.50XE +1.25XL + 1.00XR +.75XS + 1.50XM < 2,000 (assem.) XR ≥ 200 (reg. qty) XS ≥ 100 (sm. qty) 2XE < XL (mix 1) XM < .50(XE + XL + XR + XS) (mix 2) where XE, XL, XR, XS, and XM ≥ 0 The resource constraints all take the form: amt. used < amt. avail. The quantity constraints take form: number made ≥ minimum quantity. The mix 1 constraint translates: at least 2 extra-large modules made for every large one. The mix 2 constraint translates: miniatures cannot exceed half the total of the other sizes combined. Product-Mix Selection The above problem must be solved with the simplex method. That is nearly always done with computer assistance. The constraint expressions must first be modified so that all Xs appear on the left: 2XE – XL < 0 for mix 1 –.50XE –.50XL –.50XR –.50XS + XM < 0 for mix 2 The Xs should all align vertically. 3 Entering Data with QuickQuant From the QuickQuant menu, select linear programming. That brings to screen the following. 4 Entering Data with QuickQuant After supplying basic information, the variables are named. 5 Entering Data with QuickQuant Then the objective coefficients are entered. That is followed by entering the constraints. 6 Solving the Problem with QuickQuant After entering the data, Run is pulled down in the menu bar and Quick Solve is selected. 7 Product-Mix Selection Solution QuickQuant provides the following solution. 8 Slack and Surplus Variables QuickQuant automatically assigns slack and surplus variables to the constraints. S1 is the unused quantity (slack) of chips A. S5 is the surplus regular modules beyond the minimum. 9 Portfolio Selection 10 A portfolio manager wants to determine how much to invest in company bonds A, B, C, D, E, or F with respective yields 8.5, 9, 10, 9.5, 8.5 and 9%. Letting Xi = the dollar amount invested in company i bonds, she wants to maximize interest income. Her objective is to Maximize P = .085XA + .090XB + .100XC + .095XD + .085XE + .090XF Total available funds are $100,000, and that constraint is: XA + XB + XC + XD + XE + XF = 100,000 (funds) No bond investment can exceed $25,000. For bond A that constraint is: XA < 25,000 (limitation A) Similar but separate constraints apply to the other five bonds. At least half the funds must be placed in longer maturities (B, E, and F): XE + XL + XR ≥ 50,000 (long maturity) No more than 30% of all funds can be place in junk (C and D): XC + XD < 30,000 (junk) Non-negativity conditions apply. The optimal solution is: XA = 20,000 XB = 25,000 XC = 25,000 XD = 5,000 XE = 0 XA = 25,000 P = 9,175 Transportation Problem: Shipment Scheduling The following capacity, demand, and unit costs apply for plants and warehouses. To Warehouse From Plant Frankfurt 11 New York Phoenix Yokohama Capacity Juarez $19 $7 $3 $21 100 Seoul 15 21 18 6 300 Tel Aviv 11 14 15 22 200 Demand 150 100 200 150 600 The linear program involves one variable for each cell in the above: Xij = quantity shipped from plant i to warehouse j i = J, S, T and j = F, N, P, Y Transportation Problem: Shipment Scheduling The following objective applies. Minimize C =19XJF + 7XJN + 3XJP +21XJY +15XSF +21XSN +18XSP + 6XSY +11XTF +14XTN +15XTP +22XTY Subject to: XJF + XJN + XJP + XJY = 100 (Juarez Capacity) XSF +XSN + XSP + XSY = 300 (Seoul Capacity) XTF +XTN + XTP + XTY = 200 (Tel Aviv Capacity) XJF + XSF + XTF = 150 (Frankfurt Demand) XJN + XSN + XTN = 100 (New York Demand) XJP + XSP + XTP = 200 (Phoenix Demand) XJY + XSY + XTY = 150 (Yokohama Demand) where all Xij’s > 0 12 Solution to Transportation Problem The linear program was solved on the computer. The following shipment quantities apply. C = 6,250 To Warehouse From Plant Frankfurt 13 New York Phoenix Yokohama Juarez 0 0 100 0 Seoul 50 0 100 150 Tel Aviv 100 100 0 0 Budgeting Advertising Expenditures Real Reels is deciding how many ads to place in Playboy (P), True (T), and Esquire (E). Respective costs are $10,000, $5,000, and $6,000. The respective variables are XP, XT, and XE. The objective is to Maximize P = 1XP + .9XT + .28XE with the coefficients are the number of exposures (millions of gear users) per ad. 14 Budgeting Advertising Expenditures There is a budget maximum of $100,000. A maximum of 5 ads may be placed in True and minimum of 2 for each other magazine. The following constraints apply: 10XP + 5XT + 6XE < 100 (budget) 1XT < 5 (True max.) 1XP > 2 (Playboy min.) 1XE > 2 (Esquire min.) all Xs > 0 15 Solution: X = 6.3, X = 5, X = 2, P = 11.36 P T E Assignment Problem The following data apply for persons and jobs. Time to Complete One Job Individual Drilling Grinding Lathe Ann 5 min. 10 min. 10 min. Bud 10 5 15 Chuck 15 15 10 The linear program involves one variable for each cell in the above: Xij = Fraction of time person i is assigned to job j i = A, B, C and j = D, G, L 16 Assignment Problem 17 The following objective applies. Minimize C = 5XAD + 10XAG + 10XAL +10XBD + 5XBG + 15XBL + 11XCD + 14XCG + 15XCL Subject to: XAD + XAG + XAL = 1 (Ann’s Availability) XBD + XBG + XBL = 1 (Bud’s Availability) XCD + XCG + XCL = 1 (Chuck’s Availability) XAD + XBD + XCD = 1 (drill-press requirement) XAG + XBG + XCG = 1 (grinder requirement) XAL + XBL + XCL = 1 (lathe requirement) where all Xij’s > 0 Solution: XAD = 1 (Ann to Drilling) XBG = 1 (Bud to Grinding) XCL = 1 (Chuck to Lathe) C = 20 Liquid Blending Chanel 2000 makes aftershave and cologne. The following data apply. Agents (%) Selling Order Product Emulsion Evaporatives Price Quantity Aftershave -- 20 $10 1,500 Cologne 30 -- 20 500 The following data apply to the raw materials. Agents (%) Ingredient Oil Rinse Emulsion 50 Evaporatives 0 Cost $ 2 100 25 30 Available 2,000 500 Stabilizer 10 50 4 1,000 Let Xij = Volume (liters) of ingredient i used in blending product j with i = O, R, S and j = A, C 18 Liquid Blending 19 Revenue = 10(XOA + XRA + XSA) + 20(XOC + XRC + XSC) Cost = 2(XOA + XOC) + 30(XRA + XRC) + 4(XSA + XSC) Using Profit = Revenue – Cost, collecting terms, the objective is to Maximize P = 8XOA - 20XRA + 6XSA + 18XOC - 10XRC + 16XSC There are three constraints for resource availabilities: XOA + XOC < 2,000 (available oil) XRA + XRC < 500 (available rinse) XSA + XSC < 1,000 (available stabilizer) There are two constraints for product quantity requirements: XOA + XRA + XSA > 1,500 (aftershave volume) XOC + XRC + XSC > 500 (cologne volume) There are two proportional ingredient requirements: .50XOC + 1.00XRC + .10XSC > .30(XOC + XRC + XSC) (emulsions in cologne) .25XRA + .50XSA > .20(XOA + XRA + XSA) (evaps. in aftershave) These simplify to: .20XOC + .70XRC - .20XSC > 0 (emulsions in cologne) -.20XOA + .05XRA + .30XSA > 0 (evaporatives in aftershave) Solution: XOA = 500 XRA = 0 XSA = 1,000 XOC = 1,500 XRC = 0 XSC = 0 P = 37,000 Solving Linear Programs with a Spreadsheet Step 1: Write out the formulation table. Step 2: Put the formulation table into a spreadsheet. Step 3: Use Excel’s Solver to obtain a solution. 20 Step 1: The Formulation Table (Figure 9-1) The formulation table arranges the problem in a tabular format, as shown below for the Microcircuit Production Plan. Variables XE XL XR XS XM Sign RHS Objective 58 43 25 17 28 = P(max) PC Board 25 15 10 5 1 < 50,000 A Availability 28 24 18 12 5 < 10,000 B Availability 52 48 40 60 75 < 25,000 Assembly Time 1.50 1.25 1.00 0.75 1.50 < 2,000 Regular Quantity 1 > 200 Small Quantity 1 > 100 Oversized Mixture 2 -1 < 0 Miniature Mixture -0.50 -0.50 -0.50 -0.50 1.00 < 0 21 Step 2: The Excel Spreadsheet (Figure 9-2) The numbers in the Excel spreadsheet come from the formulation table. A 1 2 3 4 5 6 7 8 9 10 11 12 22 B C D E F G H Sign = < < < < > > < < RHS P(max) 50000 10000 25000 2000 200 100 0 0 Microcircuit Production Plan Variables Objective PC Board A Availability B Availability Assembly Time Regular Quantity Small Quantity Oversized Mixture Miniature Mixture XE 58 25 28 52 1.50 XL 43 15 24 48 1.25 XR 25 10 18 40 1.00 1 XS 17 5 12 60 0.75 XM 28 1 5 75 1.50 1 2 -0.50 -1 -0.50 -0.50 -0.50 1.00 Step 3: Expanded Spreadsheet (Figure 9-3) The expanded spreadsheet contains the formulas necessary to use Solver. Put =SUMPRODUCT(B4:F4,$B$15:$F$15) in cell J4 and copy it down to cell J12. Cell J4 gives the value of the objective function. A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 B C D E F G H I J Microcircuit Production Plan Variables Objective PC Board A Availability B Availability Assembly Time Regular Quantity Small Quantity Oversized Mixture Miniature Mixture 23 XE 58 25 28 52 1.50 XL 43 15 24 48 1.25 2 -0.50 -1 -0.50 XE 10.00 XL 20.00 XR 25 10 18 40 1.00 1 XS 17 5 12 60 0.75 XM 28 1 5 75 1.50 1 -0.50 Solution XR 200.00 -0.50 1.00 XS 100.00 XM 10.00 The solution is found here (the values of the decision variables). Sign = < < < < > > < < 4 5 6 7 8 9 10 11 12 RHS P(max) 50000 10000 25000 2000 200 100 0 0 Profit PC Board A Availability B Availability Assembly Time Regular Quantity Small Quantity Oversized Mixture Miniature Mixture J =SUMPRODUCT(B4:F4,$B$15:$F$15) =SUMPRODUCT(B5:F5,$B$15:$F$15) =SUMPRODUCT(B6:F6,$B$15:$F$15) =SUMPRODUCT(B7:F7,$B$15:$F$15) =SUMPRODUCT(B8:F8,$B$15:$F$15) =SUMPRODUCT(B9:F9,$B$15:$F$15) =SUMPRODUCT(B10:F10,$B$15:$F$15) =SUMPRODUCT(B11:F11,$B$15:$F$15) =SUMPRODUCT(B12:F12,$B$15:$F$15) 8420 3060 5610 16230 330 200 100 0 -155 Using Excel’s Solver to Solve Linear Programs Click on Tools on the menu bar, select the Solver option, and the Solver Parameters dialog box shown next appears. 24 1. Enter the value of the objective function, J4, in the Target Cell line, either with or without the $ sign. Solver Parameters Dialog Box (Figure 9-5) NOTE: Normally all these entries appear in the Solver Parameter dialog box so you only need to click on the Solve button. However, you should always check to make sure the entries are correct for the problem you are solving. 2. The Target Cell is to be maximized so click on Max in the Equal To line. 3. Enter the decision variables in the By Changing Cells line, B15:F15. 4. The constraints are entered in the Subject to Constraints box by using the Add Constraints dialog box shown next (obtained by clicking on the Add button). If a constraint needs to be changed, click on the Change button. The 25 Change and Add Constraint dialog box function in the same manner. The Add Constraint Dialog Box (Figure 9-6) To represent the constraints in rows 5 - 8: 1. Enter J5:J8 (or $J$5:$J$8) in the Cell Reference line. This is the total amount of these resources used. Normally, all these entries already appear. You will need to use this dialog box only if you need to add a constraint. 3. Enter the amounts of the resources available H5:H8 in the Constraint line (or =$H$5:$H$8). 4. Click Add and repeat Steps 1 - 3 if another constraint is to be added. If this is the last constraint, click OK. 2. Enter <= as the sign because the resources used must be equal to or less than the amounts available, given next in Step 3. If another sign is needed, see the next slide. 26 If you need to change a constraint, the Change Constraint dialog box functions just like this one. Dialog Box for Constraint Signs (Figure 9-7) To enter different signs, click on the down arrow and three possibilities are displayed: <=, =, >=, 27 The Solver Options Dialog Box (Figure 9-8) Click on the Options button in the Solver Parameters dialog box to check the Solver Options dialog box to ensure that the Assume Linear Model and Assume Non-Negative boxes are checked. 28 Solver Results Dialog Box (Figure 9-9) Be sure to check the message in the Solver Results dialog box. In this case it indicates that a solution has been found. What happens when Solver does not find a solution will be discussed latter. Click OK and the spreadsheet with the solution, shown next, is obtained. 29 1. To solve other problems: Spreadsheet with Optimal Solution (Figure 9-10) 2. Enter the data: the coefficients of the objective function in cells B4:F4, the right-hand sides in cells H5:H12, and the exchange coefficients in cells B5:F12. A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 B C D E F G H I J Microcircuit Production Plan Variables Objective PC Board A Availability B Availability Assembly Time Regular Quantity Small Quantity Oversized Mixture Miniature Mixture 30 XE 58 25 28 52 1.50 XL 43 15 24 48 1.25 2 -0.50 -1 -0.50 XE 67.54 XL 135.08 XR 25 10 18 40 1.00 1 XS 17 5 12 60 0.75 XM 28 1 5 75 1.50 1 3. To find the solution, click on Tools and Solver to obtain the Solver Parameters dialog box and then click the Solve button. -0.50 Solution XR 200.00 -0.50 1.00 XS 100.00 XM 13.39 Sign = < < < < > > < < RHS P(max) 50000 10000 25000 2000 200 100 0 0 Profit 16800.65 PC Board 6228.10 A Availability 10000.00 B Availability 25000.00 Assembly Time 565.24 Regular Quantity 200.00 Small Quantity 100.00 Oversized Mixture 0.00 Miniature Mixture -237.92 4. For bigger problems insert additional rows or columns. Insert them in the middle of the table and not at the beginning or the end. Copy the formulas in column J to any new cells created by inserting rows. Check to make sure the ranges of the formulas and signs in the Solver Parameters dialog box are correct. Solver’s Answer Report Solver’s Answer Report gives the values of the: • objective function • decision variables • slack variables 31 Solver’s Answer Report To get Solver’s Answer Report, highlight Answer Report in the Report box of the Solver Results dialog box before clicking the OK button. 32 Answer Report for Microcircuit Production Plan (Figure 9-11) Target Cell (Max) Cell Name $J$4 Profit Adjustable Cells Cell Name $B$15 XE $C$15 XL $D$15 XR $E$15 XS $F$15 XM Original Value 0.00 Original Value 0.00 0.00 0.00 0.00 0.00 Final Value 16800.65 Final Value 67.54 135.08 200.00 100.00 13.39 Objective function Decision variables Slack variables Note: Not binding means the slack variable is positive, binding means it is zero. 33 Constraints Cell Name $J$5 PC Board $J$6 A Availability $J$7 B Availability $J$8 Assembly Time $J$9 Regular Quantity $J$10 Small Quantity $J$11 Oversized Mixture $J$12 Miniature Mixture Cell Value 6228.10 10000.00 25000.00 565.24 200.00 100.00 0.00 -237.92 Formula $J$5<=$H$5 $J$6<=$H$6 $J$7<=$H$7 $J$8<=$H$8 $J$9>=$H$9 $J$10>=$H$10 $J$11<=$H$11 $J$12<=$H$12 Status Not Binding Binding Binding Not Binding Binding Binding Binding Not Binding Slack 43771.90 0.00 0.00 1434.76 0.00 0.00 0.00 237.92 Bond Portfolio Selection (page 319) A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 34 B C D E F G H I J K RHS P(max) 100,000 25,000 25,000 25,000 25,000 25,000 25,000 50,000 30,000 Profit Funds Diversification - A B C D E F Maturity Quality 9,175 100,000 20,000 25,000 25,000 5,000 0 25,000 70,000 30,000 Bond Portfolio Selection Variables Objective Funds Diversification - A B C D E F Maturity Quality XA 0.085 1 1 XB 0.09 1 XC 0.1 1 XD XE 0.095 0.085 1 1 XF 0.09 1 1 1 1 1 1 XA 20,000 1 XB 25,000 1 1 Solution XC XD 25,000 5,000 1 1 1 XE 0 XF 25,000 Sign = = < < < < < < > < Real Reels (page 323) A 1 2 3 4 5 6 7 8 9 10 11 35 B C D E F G H RHS P(max) 100,000 5 2 2 Profit Budget Maximum True ads Minimum Playboy ads Minimum Esquire ads 11.36 100000.00 5.00 6.30 2.00 Real Reels Variables Objective Budget Maximum True ads Minimum Playboy ads Minimum Esquire ads XP 1 10000 XT 0.9 5000 1 XE 0.28 6000 1 1 Solution XA XB 6.30 5.00 XC 2.00 Sign = < < > > Scent Mixing (page 328) A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 36 B C D E F G H I J Sign = < < < > > > > RHS P(max) 2000 500 1000 1500 500 0 0 Profit Available oil Available rinse Available stabilizer Aftershave volume Cologne volume Emulsions in cologne Evaporatives in aftershave K Scent Mixing Variables Objective Available oil Available rinse Available stabilizer Aftershave volume Cologne volume Emulsions in cologne Evaporatives in aftershave XOA 8 1 XRA -20 XSA 6 XOC 18 1 1 1 1 0.05 XOA 500 XRA 0 XSC 16 1 1 1 1 1 0.2 -0.2 XRC -10 1 0.7 1 -0.2 0.3 Solution XSA XOC XRC 1000 1500 0 XSC 0 37000 2000 0 1000 1500 1500 300 200 Yosemite Ann A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 37 B C D E F G H I J Yosemite Ann Variables Objective Total weight Calories Protein Iron Vitamin A Thiamin Riboflavin Niacin Calcium Ascorbic acid XC 1.50 1.00 540 20 10 230 0.5 0.5 3 600 2000 XP 2.50 1.00 5720 270 30 0 2.5 2.6 170 720 10 XW XK XM Sign RHS 4.00 1.00 1.50 = C(min) Cost 1.00 1.00 1.00 = 1 Total weight 6540 5530 4990 > 3000 Calories 150 290 260 > 56 Protein 20 110 10 > 10 Iron 300 700 9200 > 1000 Vitamin A 4.8 2.4 2.9 > 1.4 Thiamin 1.3 1.9 12.1 > 1.6 Riboflavin 12 24 7 > 18 Niacin 830 510 9120 > 800 Calcium 30 0 90 > 60 Ascorbic acid Solution XC XP XW XK XM 0.0283 0.0000 0.0000 0.9348 0.0369 1.0326 1 5369 281 103 1000 2 2 23 830 60