Table of Contents Chapter 8 (Nonlinear Programming) The Challenges of Nonlinear Programming (Section 8.1) NLP with Decreasing Marginal Returns: Wyndor (Section 8.2) NLP with Decreasing Marginal Returns: Portfolio Selection (Section 8.2) Separable Programming (Section 8.3) Difficult Nonlinear Programming Problems (Section 8.4) Evolutionary Solver and Genetic Algorithms (Section 8.5) 8.2–8.15 8.16–8.20 8.21–8.25 8.26–8.38 8.39–8.40 8.41–8.54 Nonlinear and Separable Programming (UW Lecture) 8.55–8.70 These slides are based upon a lecture from the MBA elective course “Modeling with Spreadsheets” at the University of Washington (as taught by one of the authors). Evolutionary Solver (UW Lecture) 8.71–8.82 These slides are based upon a lecture from the MBA elective course “Modeling with Spreadsheets” at the University of Washington (as taught by one of the authors). McGraw-Hill/Irwin 8.1 © The McGraw-Hill Companies, Inc., 2008 Examples of Linear and Nonlinear Formulas Linear Formulas Nonlinear Formulas SUMPRODUCT(D4:D6, C4:C6) [(D1 + D2) / D3] * C4 IF(D2 >= 2, 2*C3, 3*C4) SUMIF(D1:D6, 4, C1:C6) SUM(D4:D6) 2*C1 + 3*C4 + C6 C1 + C2 + C3 SUMPRODUCT(C4:C6, C1:C3) [(C1 + C2) / C3] * D4 IF(C2 >= 2, 2*C3, 3*C4) SUMIF(C1:C6, 4, D1:D6) ROUND(C1) MAX(C1, 0) MIN(C1, C2) ABS(C1) SQRT(C1) C1 * C2 C1 / C2 C1 ^2 Data cells are located in D1:D6 and changing cells are in C1:C6. McGraw-Hill/Irwin 8.2 © The McGraw-Hill Companies, Inc., 2008 The Challenges of Nonlinear Programming • Nonlinear programming is used to model nonproportional relationships between activity levels and the overall measure of performance, whereas linear programming assumes a proportional relationship. • Constructing the nonlinear formula(s) needed for a nonlinear programming model is considerably more difficult than developing the linear formulas used in linear programming. • Solving a nonlinear programming model is often much more difficult (if it is possible at all) than solving a linear programming model. McGraw-Hill/Irwin 8.3 © The McGraw-Hill Companies, Inc., 2008 The Challenge of Nonproportional Relationships • Proportionality Assumption of Linear Programming: The contribution of each activity to the value of the objective function is proportional to the level of the activity. In other words, the term in the objective function involving this activity consists of a coefficient times the decision variable. • Nonlinear programming problems arise when any activity has a nonproportional relationship where the contribution of the activity to the measure of performance is not proportional to the level of the activity. McGraw-Hill/Irwin 8.4 © The McGraw-Hill Companies, Inc., 2008 Profit Graphs for Wyndor Glass Co. (Proportional Relationship) Weekly Profit ($) Weekly Profit ($) 1200 3000 2500 900 2000 600 1500 1000 300 500 0 2 Production rate for doors McGraw-Hill/Irwin 4 0 D 8.5 4 2 Production rate for windows 6 W © The McGraw-Hill Companies, Inc., 2008 Profit Graphs with Nonproportional Relationships Piecewise Linear with Decreasing Marginal Returns Decreasing Marginal Returns Profit Profit Level of an activity (a) Profit McGraw-Hill/Irwin Level of an activity (b) 8.6 Profit © The McGraw-Hill Companies, Inc., 2008 Profit Graphs with Nonproportional Relationships Level of an activity (a) Level of an activity (b) Decreasing Marginal Returns Except for Discontinuities Increasing Marginal Returns Profit Profit Level of an activity Level of an activity (c) McGraw-Hill/Irwin (d) 8.7 © The McGraw-Hill Companies, Inc., 2008 Constructing a Nonlinear Formula A 1 B C Constructing a Nonlinear Formula 2 3 4 5 6 7 8 Level of Activity 2 4 5 7 10 Profit $16 $24 $28 $30 $33 Profit vs. Level of Activity Profit $35 $30 $25 $20 $15 $10 $5 $0 0 2 4 6 8 10 Level of Activity (x) McGraw-Hill/Irwin 8.8 © The McGraw-Hill Companies, Inc., 2008 Format Trendline Dialogue Box McGraw-Hill/Irwin 8.9 © The McGraw-Hill Companies, Inc., 2008 The Trendline (Quadratic Equation) A 1 B C Constructing a Nonlinear Formula 2 3 4 5 6 7 8 Level of Activity 2 4 5 7 10 Profit $16 $24 $28 $30 $33 Profit vs. Level of Activity Profit $35 $30 $25 $20 $15 $10 y = -0.3002x2 + 5.661x + 6.1477 $5 $0 0 2 4 6 8 10 Level of Activity (x) McGraw-Hill/Irwin 8.10 © The McGraw-Hill Companies, Inc., 2008 Solving Nonlinear Programming Models Consider the following model in algebraic form: Maximize Profit = 0.5x5 – 6x4 + 24.5x3 – 39x2 + 20x subject to x≤5 x≥0 McGraw-Hill/Irwin 8.11 © The McGraw-Hill Companies, Inc., 2008 Solver Solution Starting with x = 0 A 1 B C D E A Simple NLP 2 3 4 x= 0.371 <= Maximum 5 5 6 7 McGraw-Hill/Irwin Profit = 0.5x = 5 4 -6x +24.5x 3 2 -39x +20x $3.19 8.12 © The McGraw-Hill Companies, Inc., 2008 Solver Solution Starting with x = 3 A 1 B C D E A Simple NLP 2 3 4 x= 3.126 <= Maximum 5 5 6 7 McGraw-Hill/Irwin Profit = 0.5x = 5 4 -6x +24.5x 3 2 -39x +20x $6.13 8.13 © The McGraw-Hill Companies, Inc., 2008 Solver Solution Starting with x = 4.7 A 1 B C D E A Simple NLP 2 3 4 x= 5.000 <= Maximum 5 5 6 7 McGraw-Hill/Irwin Profit = 0.5x = 5 4 -6x +24.5x 3 2 -39x +20x $0.00 8.14 © The McGraw-Hill Companies, Inc., 2008 The Profit Graph P ro fit ($) x McGraw-Hill/Irwin 8.15 © The McGraw-Hill Companies, Inc., 2008 Original Wyndor Glass Co. Spreadsheet A 1 B C D E F G Wyndor Glass Co. Product-Mix Problem 2 3 4 Unit Profit Doors Windows $300 $500 5 6 Hours Used Per Unit Produced 1 0 7 Plant 1 8 Plant 2 0 9 Plant 3 3 Hours Hours Used Available 2 <= 4 2 12 <= 12 2 18 <= 18 10 11 12 Doors Units Produced McGraw-Hill/Irwin Windows 2 6 8.16 Total Profit $3,600 © The McGraw-Hill Companies, Inc., 2008 Quadratic (non-linear) programs • A quadratic program is an example of a non-linear program in which each constraint is linear, but the objective function has the form: f(x1, x2, …, xn) = i→nj→ncijx1xj + i→ndixi Where cij and di are known constants. Example: Quadratic program with linear constraints, quadratic objective function, n = 2 variables, c11 = 1, c12 = c21 = 0, c22 = 1, and d1 = d2 = 0. Introducti minimize: z = x12 + x22 subject to: x1 – x2 = 3 x2 ≥ 3 McGraw-Hill/Irwin Issue 8. Non-linear programming on to Wyndor Glass with Marketing Costs • Market research indicates that Wyndor could sell small numbers of doors and windows with no advertising. However, extensive advertising would be required to sell all that could be produced. • A curve-fitting procedure was used to estimate the weekly marketing costs required to sustain a production rate of D doors and W windows: – Marketing cost for doors = $25D2 – Marketing costs for windows = ($662/3)W2 • The gross profit per door sold is about $375, and the gross profit per window is about $700. Therefore, the net profits are as follows: – Net profit for doors = $375D – $25D2 Net profit for windows = $700W – ($662/3)W2 • Thus, the revised objective function is Maximize Profit = $375D – 25D2 + $700W –($662/3)W2 Question: Considering the nonlinear marketing costs, how many doors and windows should Wyndor produce? McGraw-Hill/Irwin 8.18 © The McGraw-Hill Companies, Inc., 2008 Profit Graphs for Doors and Windows Weekly profit ($) 1,800 1,600 Weekly profit ($) 1,400 1,200 1,200 1,000 1,000 800 800 600 600 400 400 200 200 0 2 4 D 0 Production rate for doors McGraw-Hill/Irwin 2 4 6 W Production rate for windows 8.19 © The McGraw-Hill Companies, Inc., 2008 Spreadsheet Formulation A 1 B C D E F G H Wyndor Problem With Nonlinear Marketing Costs 2 3 4 Unit Profit (Gross) Doors Windows $375 $700 5 Hours Hours 6 Used Available Hours Used Per Unit Produced 1 0 7 Plant 1 8 Plant 2 0 9 Plant 3 3 3.214 <= 4 2 8.357 <= 12 2 18 <= 18 10 11 12 Doors Windows Units Produced 3.214 4.179 Gross Profit from Sales $4,130 Marketing Cost $258 $1,164 Total Marketing Cost $1,422 13 14 15 16 McGraw-Hill/Irwin Total Profit 8.20 $2,708 © The McGraw-Hill Companies, Inc., 2008 Graphical Display of Nonlinear Formulation W Production rate for windows 6 5 (3 3 ,4 14 5 ) = optimal solution 28 4 Profit = $2,800 3 Feasible region Profit = $2,708 Profit = $2,600 Profit = $2,500 2 1 0 McGraw-Hill/Irwin 1 2 3 Production rate for doors 8.21 4 5 D © The McGraw-Hill Companies, Inc., 2008 Portfolio Selection • It is now common practice for professional managers of large stock portfolios to use computer models based on nonlinear programming to guide them. • Investors are concerned about both the expected return and the risk. • One way of formulating their approach is as a nonlinear version of a costbenefit trade-off problem: – Minimize Risk subject to Expected return ≥ Minimum acceptable level • Consider a portfolio with 3 stocks. Question: What is the portfolio that will minimize the risk subject to achieving at least an 18% expected return? McGraw-Hill/Irwin 8.22 © The McGraw-Hill Companies, Inc., 2008 Data for Stocks Stock Expected Return Risk (Standard Deviation) Pair of Stocks Joint Risk per Stock (Covariance) 1 21% 25% 1 and 2 0.040 2 30 45 1 and 3 –0.005 3 8 5 2 and 3 –0.010 McGraw-Hill/Irwin 8.23 © The McGraw-Hill Companies, Inc., 2008 Algebraic Formulation Minimize Risk = (0.25S1)2+(0.45S2)2+(0.05S3)2+2(0.04)S1S2+2(–0.005)S1S3+2(–0.01)S2S3 subject to (21%)S1 + (30%)S2 + (8%)S3 ≥ 18% S1 + S2 + S3 = 100% and S1 ≥ 0, S2 ≥ 0, S3 ≥ 0. McGraw-Hill/Irwin 8.24 © The McGraw-Hill Companies, Inc., 2008 Spreadsheet Model A 1 B C D E F G H = 100% Portfolio Selection Problem (Nonlinear Programming) 2 3 4 Stock 1 Stock 2 Stock 3 Expected Return 21% 30% 8% Risk (Stand. Dev.) 25% 45% 5% Joint Risk (Covar.) Stock 1 Stock 2 Stock 3 0.040 -0.005 5 6 7 8 9 Stock 1 10 Stock 2 11 Stock 3 -0.010 12 13 14 Portfolio Stock 1 Stock 2 Stock 3 Total 40.2% 21.7% 38.1% 100% 15 16 Minimum 17 Expected 18 19 Portfolio Expected Return 18.0% Risk (Variance) 0.0238 Risk (Stand. Dev.) 15.4% Return >= 18.0% 20 21 22 23 McGraw-Hill/Irwin 8.25 © The McGraw-Hill Companies, Inc., 2008 Portfolio selection spreadsheet model McGraw-Hill/Irwin Introducti on to Issue 8. Non-linear programming Using Solver Table to Examine Trade-Offs Between Expected Return and Risk B C D E 25 26 F Risk Min Return 27 G Expected Stock 1 Stock 2 Stock 3 (St. Dev.) Return 40.2% 21.7% 38.1% 15.4% 18.0% 28 8% 7.1% 3.7% 89.1% 3.9% 9.7% 29 10% 8.1% 4.3% 87.6% 3.9% 10.0% 30 12% 16.2% 8.6% 75.2% 5.6% 12.0% 31 14% 24.2% 13.0% 62.8% 8.6% 14.0% 32 16% 32.2% 17.3% 50.5% 12.0% 16.0% 33 18% 40.2% 21.7% 38.1% 15.4% 18.0% 34 20% 48.2% 26.1% 25.7% 18.9% 20.0% 35 22% 56.2% 30.4% 13.4% 22.5% 22.0% 36 24% 64.2% 34.8% 1.0% 26.1% 24.0% 37 26% 44.4% 55.6% 0.0% 30.8% 26.0% 38 28% 22.2% 77.8% 0.0% 37.3% 28.0% 39 30% 0.0% 100.0% 0.0% 45.0% 30.0% 8.27 © The McGraw-Hill Companies, Inc., 2008 McGraw-Hill/Irwin Wyndor Glass When Overtime is Needed • Wyndor Glass has accepted a special order for hand-crafted goods to be made in plants 1 and 2 throughout the next four months. • Filling this order will require borrowing certain employees from the work crews of regular products. • The remaining workers will need to work overtime to utilize the full production capacity of each plant’s machinery for the regular products. • The original constraints of Hours Used ≤ Hours Available are still valid. However, the objective function will need to be modified because of the additional cost of using overtime work. • In particular, because of the additional cost, the profit per unit will be reduced for those units that require overtime. Question: Considering overtime costs, how many doors and windows should Wyndor produce? McGraw-Hill/Irwin 8.28 © The McGraw-Hill Companies, Inc., 2008 Data for Wyndor When Overtime is Needed Maximum Weekly Production Product Regular Time Overtime Doors 3 Windows 3 Profit per Unit Produced Total Regular Time Overtime 1 4 $300 $200 3 6 500 100 (and 3D + 2W ≤ 18) McGraw-Hill/Irwin 8.29 © The McGraw-Hill Companies, Inc., 2008 Profit Graphs for Doors and Windows Weekly profit ($) 1,800 1,500 Weekly profit ($) 1,100 900 0 3 Production rate for doors McGraw-Hill/Irwin 4 D 0 8.30 3 Production rate for windows 6 W © The McGraw-Hill Companies, Inc., 2008 The Separable Programming Technique • For each activity that violates the proportionality assumption, separate its profit graph into parts, with a line segment in each part. • Then, instead of using a single decision variable to represent the level of each such activity, introduce a separate new decision variable for each line segment on that activity’s profit graph. • Since the proportionality assumption holds for these new decision variables, formulate a linear programming model in terms of these variables. • For the Wyndor problem, these new decision variables are – DR = Number of doors produced per week on regular time – DO = Number of doors produced per week on overtime – WR = Number of windows produced per week on regular time WO = Number of windows produced per week on overtime McGraw-Hill/Irwin 8.31 © The McGraw-Hill Companies, Inc., 2008 Separable Programming Spreadsheet Model A 1 B C D E F G Wyndor Problem with Overtime (Separable Programming) 2 3 Unit Profit Doors Windows 4 Regular $300 $500 5 Overtime $200 $100 6 7 Hours Used Per Unit Produced 1 0 8 Plant 1 9 Plant 2 0 10 Plant 3 3 Hours Hours Used Available 4 <= 4 2 6 <= 12 2 18 <= 18 11 12 Units Produced 13 Doors Maximum Doors Windows Windows 14 Regular 3 3 <= 3 3 15 Overtime 1 0 <= 1 3 16 Total Produced 4 3 17 18 McGraw-Hill/Irwin Total Profit $2,600 8.32 © The McGraw-Hill Companies, Inc., 2008 Separable programming spreadsheet model McGraw-Hill/Irwin Introducti on to Issue 8. Non-linear programming Separable Programming with Smooth Profit Graphs Profit Profit graph Approximation Level of activity McGraw-Hill/Irwin 8.34 © The McGraw-Hill Companies, Inc., 2008 Advantages of Separable Programming • The Excel Solver can readily solve nonlinear problems that have decreasing marginal returns, with the advantage that no approximation is needed. • However, the separable programming approach also has certain advantages: – Converting the problem into a linear programming problem tends to make it quicker to solve, which can be very helpful for large problems. – A linear programming formulation makes available Solver’s Sensitivity Report. – Separable programming only requires estimating the profit from each activity at a few points. Therefore, it is not necessary to use a curve fitting method to estimate the formula for the profit graph. McGraw-Hill/Irwin 8.35 © The McGraw-Hill Companies, Inc., 2008 Wyndor Problem with Both Overtime Costs and Nonlinear Marketing Costs • The previous spreadsheet model does not include nonlinear marketing costs. • Recall that the curve-fitting procedure was used to estimate the weekly marketing costs required to sustain a production rate of D doors and W windows: – Marketing cost for doors = $25D2 – Marketing costs for windows = ($662/3)W2 Question: Considering both overtime costs and nonlinear marketing costs, how many doors and windows should Wyndor produce? McGraw-Hill/Irwin 8.36 © The McGraw-Hill Companies, Inc., 2008 Data for Wyndor with Overtime Costs and Nonlinear Marketing Costs Maximum Weekly Production Regular Time Overtime Doors 3 Windows 3 Product McGraw-Hill/Irwin Gross Unit Profit Total Regular Time Overtime Marketing Costs 1 4 $375 $275 $25D2 3 6 700 300 662/3W2 8.37 © The McGraw-Hill Companies, Inc., 2008 Weekly Profit from Producing Doors D Gross Profit Marketing Costs Profit Incremental Profit 0 $0 $0 $0 — 1 375 25 350 350 2 750 100 650 300 3 1,125 225 900 250 4 1,400 400 1,000 100 McGraw-Hill/Irwin 8.38 © The McGraw-Hill Companies, Inc., 2008 Weekly Profit from Producing Windows W Gross Profit Marketing Costs Profit Incremental Profit 0 $0 $0 $0 — 1 700 662/3 6331/3 6331/3 2 1,400 2662/3 1,1331/3 500 3 2,100 600 1,500 3662/3 4 2,400 1,0662/3 1,3331/3 –1662/3 5 2,700 1,6662/3 1,0331/3 –300 6 3,000 2,400 600 –4331/3 McGraw-Hill/Irwin 8.39 © The McGraw-Hill Companies, Inc., 2008 Separable Programming Spreadsheet Model A 1 B C D E F G Wyndor with Overtime and Marketing Costs (Separable) 2 3 Unit Profit Doors Windows 4 Regular (0-1) $350.00 $633.33 5 Regular (1-2) $300.00 $500.00 6 Regular (2-3) $250.00 $367.67 7 Overtime $100.00 -$300.00 8 9 10 Hours Used Per Unit Produced Hours Hours Used Available 11 Plant 1 1 0 4 <= 4 12 Plant 2 0 2 6 <= 12 13 Plant 3 3 2 18 <= 18 14 15 Units Produced 16 Doors Windows Doors Maximum Windows 17 Regular (0-1) 1 1 <= 1 1 18 Regular (1-2) 1 1 <= 1 1 19 Regular (2-3) 1 1 <= 1 1 20 Overtime 1 0 <= 1 3 21 Total Produced 4 3 22 23 McGraw-Hill/Irwin Total Profit $2,501 8.40 © The McGraw-Hill Companies, Inc., 2008 Separable Programming Spreadsheet Model McGraw-Hill/Irwin Introducti on to Issue 8. Non-linear programming Nonlinear Programming Spreadsheet Model A 1 B C D E F G H Wyndor With Overtime and Marketing Costs (Nonlinear Programming) 2 3 Unit Profit (Gross) Doors Windows 4 Regular $375 $700 5 Overtime $275 $300 6 7 8 Hours Used Per Unit Produced 1 0 Hours Hours Used Available 9 Plant 1 4 <= 4 10 Plant 2 0 2 6 <= 12 11 Plant 3 3 2 18 <= 18 12 13 14 Units Produced Doors Maximum Doors Windows Windows 15 Regular 3 3 <= 3 3 16 Overtime 1 0 <= 1 3 17 Total Produced 4 3 18 19 Marketing Cost $400 $600 20 McGraw-Hill/Irwin Gross Profit from Sales $3,500 Total Marketing Cost $1,000 Total Profit 8.42 $2,500 © The McGraw-Hill Companies, Inc., 2008 Nonlinear Programming Spreadsheet Model McGraw-Hill/Irwin Introducti on to Issue 8. Non-linear programming Difficult Nonlinear Programming Problems • Even if a model has a nonlinear objective function, so long as the model has certain properties (e.g., linear constraints, decreasing marginal returns), the Solver can easily find an optimal solution. • In some cases separable programming can be used to model a nonlinear problem in such a way that linear programming can be used. • However, if a problem has increasing marginal returns, or nonlinear functions in the constraints, or disconnected profit graphs, finding a solution is often much more difficult. – such problems may have many local optima – Solver can get stuck at local optima, rather than finding the global optimum • One approach with such problems is to solve the problem many times, each time starting with a different initial solution. – Solver Table can be used to do this process more systematically when there are only one or two variables. McGraw-Hill/Irwin 8.44 © The McGraw-Hill Companies, Inc., 2008 Using Solver Table to Try Different Starting Points A 1 B C D E F G H I Using Solver Table to Try Different Starting Points 2 3 4 Maximum x= 0.371 <= Starting 5 Point Solution x * Profit 0.371 $3.19 0 0.371 $3.19 8 1 0.371 $3.19 9 2 3.126 $6.13 10 3 3.126 $6.13 11 4 3.126 $6.13 12 5 5.000 $0.00 5 6 7 x Profit = 0.5x = McGraw-Hill/Irwin 5 4 -6x +24.5x 3 2 -39x +20x $3.19 8.45 © The McGraw-Hill Companies, Inc., 2008 Evolutionary Solver and Genetic Algorithms • Evolutionary Solver uses an entirely different approach than the standard Solver to search for an optimal solution for a model. • The philosophy of Evolutionary Solver is based on genetics, evolution and the survival of the fittest. Hence, this type of algorithm is sometimes called a genetic algorithm. • The standard Solver starts with a single solution, and then moves in directions that will improve this solution. Evolutionary Solver begins by randomly generating a whole population of solutions. • After generating the population, Evolutionary Solver creates a new generation by pairing off solutions in the population to create “offspring”, combining some elements from each parent. McGraw-Hill/Irwin 8.46 © The McGraw-Hill Companies, Inc., 2008 Evolutionary Solver and Genetic Algorithms • Among solutions in the population, some will be good (or “fit”) and some will be bad (or “unfit”), as measured by evaluating the objective function. Borrowing from the principles of evolution and survival of the fittest, the “fit” members are allowed to reproduce more frequently than the unfit members. • Another key feature is mutation. Like gene mutation in biology, Evolutionary Solver will occasionally make a random change in a member of the population. This helps the algorithm get unstuck if it is getting trapped near a local optimum. • Evolutionary Solver keeps creating new generations of solutions until there have been no improvements for several consecutive generations. McGraw-Hill/Irwin 8.47 © The McGraw-Hill Companies, Inc., 2008 Selecting a Portfolio to Beat the Market • A common goal of portfolio managers is to beat the market. • If we assume that past performance is somewhat of an indicator of the future, then picking a portfolio that beat the market most often in the past might yield a portfolio that will more than likely beat the market in the future. • Consider a portfolio of five large stocks traded on the New York Stock Exchange (NYSE): – – – – – Disney (DIS) Boeing (BA) General Electric (GE) Procter & Gamble (PG) McDonald’s (MCD) Question: What mix of these five stocks will yield a portfolio that is likely to beat the market in the future? McGraw-Hill/Irwin 8.48 © The McGraw-Hill Companies, Inc., 2008 Spreadsheet Model A 1 B C D E F G H I J K Beating the Market (Evolutionary Solver) 2 Beat M arket 3 Quarter Year DIS BA GE PG M CD Return M arket? (NYSE) 4 5 6 7 8 9 10 11 12 13 Q4 Q3 Q2 Q1 Q4 Q3 Q2 Q1 Q4 Q3 2005 2005 2005 2005 2004 2004 2004 2004 2003 2003 0.38% -4.17% -12.35% 3.34% 24.37% -11.52% 2.00% 7.12% 16.79% 2.08% 3.77% 3.34% 13.36% 13.45% 0.67% 1.45% 24.99% -2.17% 23.28% 0.55% 4.85% -2.21% -3.31% -0.57% 9.32% 4.26% 6.80% -0.89% 4.61% 4.60% -2.15% 13.29% 0.04% -3.33% 2.26% -0.13% 4.31% 5.49% 8.12% 4.64% 2.74% 20.71% -10.88% -2.90% 16.50% 7.84% -9.02% 15.07% 7.13% 6.70% 1.92% 6.19% -2.63% 2.00% 10.62% 0.38% 5.81% 4.93% 11.99% 3.71% Yes Yes No Yes Yes Yes Yes Yes No Yes 1.59% 5.75% 0.70% -1.14% 10.35% -0.50% 0.06% 2.09% 14.53% 2.52% 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 Q2 Q1 Q4 Q3 Q2 Q1 Q4 Q3 Q2 Q1 Q4 Q3 Q2 Q1 2003 2003 2002 2002 2002 2002 2001 2001 2001 2001 2000 2000 2000 2000 16.09% 4.36% 9.02% -19.86% -18.15% 11.42% 12.44% -35.55% 1.03% -1.20% -23.81% -1.45% -5.91% 41.04% 37.76% -23.61% -2.84% -23.80% -6.39% 24.95% 16.34% -39.57% 0.08% -15.34% 2.55% 54.71% 11.00% -8.47% 13.17% 5.59% -0.49% -14.56% -21.84% -6.24% 8.23% -23.50% 17.06% -12.37% -16.81% 9.62% 2.16% 0.87% 0.60% 4.11% -3.42% 0.61% 0.32% 14.39% 9.29% 14.73% 2.54% -19.82% 17.65% 18.77% 0.48% -48.07% 52.55% -10.05% -7.70% -37.92% 2.51% 4.85% -1.51% 0.28% 1.91% -21.90% 13.37% -8.36% -11.87% -7.29% 24.03% -3.92% -1.09% -19.11% -8.71% 9.87% 8.96% -16.72% 4.52% -14.13% -1.41% 14.66% -0.83% -4.38% Yes Yes No No Yes Yes Yes No Yes No No Yes No No 16.38% -5.40% 6.16% -16.44% -11.22% 1.80% 8.45% -12.53% 4.38% -9.32% -0.93% 3.13% -0.74% -0.40% 0% <= 20.0% <= 100% 0% <= 20.0% <= 100% 0% <= 20.0% <= 100% 0% <= 20.0% <= 100% 0% <= 20.0% <= 100% Sum 100% = 100% Portfolio Num ber of Quarters Beating the M arket 36 McGraw-Hill/Irwin 15 8.49 © The McGraw-Hill Companies, Inc., 2008 Premium Solver Dialogue Box McGraw-Hill/Irwin 8.50 © The McGraw-Hill Companies, Inc., 2008 Solver Options Dialogue Box McGraw-Hill/Irwin 8.51 © The McGraw-Hill Companies, Inc., 2008 Limit Options Dialogue Box McGraw-Hill/Irwin 8.52 © The McGraw-Hill Companies, Inc., 2008 Evolutionary Solver Spreadsheet Solution A 1 B C D E F G H I J K Beat M arket Beating the Market (Evolutionary Solver) 2 3 Quarter Year DIS BA GE PG M CD Return M arket? (NYSE) 4 5 6 7 8 9 10 11 12 13 Q4 Q3 Q2 Q1 Q4 Q3 Q2 Q1 Q4 Q3 2005 2005 2005 2005 2004 2004 2004 2004 2003 2003 0.38% -4.17% -12.35% 3.34% 24.37% -11.52% 2.00% 7.12% 16.79% 2.08% 3.77% 3.34% 13.36% 13.45% 0.67% 1.45% 24.99% -2.17% 23.28% 0.55% 4.85% -2.21% -3.31% -0.57% 9.32% 4.26% 6.80% -0.89% 4.61% 4.60% -2.15% 13.29% 0.04% -3.33% 2.26% -0.13% 4.31% 5.49% 8.12% 4.64% 2.74% 20.71% -10.88% -2.90% 16.50% 7.84% -9.02% 15.07% 7.13% 6.70% 1.78% 7.26% 0.88% 1.80% 5.96% 2.05% 8.46% 3.13% 11.11% 3.79% Yes Yes Yes Yes No Yes Yes Yes No Yes 1.59% 5.75% 0.70% -1.14% 10.35% -0.50% 0.06% 2.09% 14.53% 2.52% 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 Q2 Q1 Q4 Q3 Q2 Q1 Q4 Q3 Q2 Q1 Q4 Q3 Q2 Q1 2003 2003 2002 2002 2002 2002 2001 2001 2001 2001 2000 2000 2000 2000 16.09% 4.36% 9.02% -19.86% -18.15% 11.42% 12.44% -35.55% 1.03% -1.20% -23.81% -1.45% -5.91% 41.04% 37.76% -23.61% -2.84% -23.80% -6.39% 24.95% 16.34% -39.57% 0.08% -15.34% 2.55% 54.71% 11.00% -8.47% 13.17% 5.59% -0.49% -14.56% -21.84% -6.24% 8.23% -23.50% 17.06% -12.37% -16.81% 9.62% 2.16% 0.87% 0.60% 4.11% -3.42% 0.61% 0.32% 14.39% 9.29% 14.73% 2.54% -19.82% 17.65% 18.77% 0.48% -48.07% 52.55% -10.05% -7.70% -37.92% 2.51% 4.85% -1.51% 0.28% 1.91% -21.90% 13.37% -8.36% -11.87% -7.29% 19.73% -4.12% -2.71% -14.53% -7.27% 10.51% 9.57% -11.69% 5.54% -16.55% 3.44% 21.62% 1.89% -18.41% Yes Yes No Yes Yes Yes Yes Yes Yes No Yes Yes Yes No 16.38% -5.40% 6.16% -16.44% -11.22% 1.80% 8.45% -12.53% 4.38% -9.32% -0.93% 3.13% -0.74% -0.40% 0% <= 2.6% <= 100% 0% <= 25.0% <= 100% 0% <= 25.7% <= 100% 0% <= 34.8% <= 100% 0% <= 12.0% <= 100% Sum 100% = 100% Portfolio Num ber of Quarters Beating the M arket 36 19 McGraw-Hill/Irwin 8.53 © The McGraw-Hill Companies, Inc., 2008 Advantages and Disadvantages of Evolutionary Solver • Evolutionary Solver has two significant advantages over the standard Solver for solving difficult nonlinear programming problems: – The complexity of the objective function does not matter. As long as the function can be evaluated for a given candidate solution (to determine the level of fitness), it does not matter if the function has kinks, discontinuities, or many local optima. – By evaluating whole populations of candidate solutions, Evolutionary Solver keeps from getting trapped at a local optimum. Even if the whole population evolves toward a locally optimal solution, mutation allows the possibility of getting unstuck. • However, Evolutionary Solver is not a panacea. – It can take much longer that standard Solver to find a final solution. – Evolutionary Solver does not perform well on models that have many constraints. – Evolutionary Solver is a random process. Running it again on the same model usually will yield a different solution. – The best solution found is typically not optimal (although it may be very close). McGraw-Hill/Irwin 8.54 © The McGraw-Hill Companies, Inc., 2008 Problems That Solver will Solver Correctly • A maximization problem with linear constraints and a concave objective function. Line joining any two points is on or below the curve A Concave Function McGraw-Hill/Irwin 8.55 © The McGraw-Hill Companies, Inc., 2008 Problems That Solver will Solver Correctly • A minimization problem with linear constraints and a convex objective function. Line joining any two points is on or above the curve A Convex Function McGraw-Hill/Irwin 8.56 © The McGraw-Hill Companies, Inc., 2008 Quality Furniture Corporation • The Quality Furniture Corporation manufactures two products: benches and tables. • They employ three carpenters. During the next week, 120 hours of labor are available at regular wages ($8 per hour). • Up to 30 hours of overtime can be used at a wage rate of $12 per hour. • Up to 30 hours of weekend time can be utilized at a wage rate of $16 per hour. • 540 pounds of wood is available at a cost of $2 per pound. • Each bench requires 3 labor hours and 12 pounds of wood. Each table requires 6 labor hours and 38 pounds of wood. • Completed benches sell for $80 each, and tables sell for $200 each. Question: How many benches and how many tables should be produced? McGraw-Hill/Irwin 8.57 © The McGraw-Hill Companies, Inc., 2008 Outdoor Furniture Labor Costs Labor Cost $1600 $16/ hr Weekend $1320 $12/ hr Overtime $960 $8/ hr Regular 30 60 90 120 150 180 Labor Hours McGraw-Hill/Irwin 8.58 © The McGraw-Hill Companies, Inc., 2008 Nonlinear Programming Spreadsheet A 1 B C D E F G Quality Furniture Corporation (Nonlinear) 2 3 4 Revenue/Unit Benches $85 Tables $200 5 6 7 8 Labor Wood Usage per Unit Produced 3 6 12 38 Total Used 135 540 <= <= Available 180 540 9 Wood Cost/lb. $2 Regular Overtime Sunday Labor Cost (per hour) $8 $12 $16 Hours Available 120 30 30 Production Benches 45 Tables 0 23 Revenue Wood Cost Labor Cost $3,825.00 $1,080.00 $1,140.00 24 Profit $1,605.00 10 11 12 13 14 15 16 17 18 19 20 21 22 McGraw-Hill/Irwin 8.59 © The McGraw-Hill Companies, Inc., 2008 Outdoor Furniture Labor Costs Labor Cost $1600 $16/ hr Weekend $1320 $12/ hr Overtime $960 $8/ hr Regular 30 60 90 120 150 180 Labor Hours McGraw-Hill/Irwin 8.60 © The McGraw-Hill Companies, Inc., 2008 Separable Programming Spreadsheet A 1 B C F E D G Quality Furniture Corporation (Separable) 2 3 4 Revenue/Unit Benches $85 Tables $200 5 6 7 8 Labor Wood Usage per Unit Produced 6 3 38 12 Total Used 135 540 <= <= Available 135 540 9 10 Wood Cost/lb. $2 11 Regular Overtime Sunday Labor Cost (per hour) $8 $12 $16 Hours Available 120 30 30 Production Benches 45 Tables 0 Regular Hours Overtime Hours Weekend Hours Labor Used 120 15 0 <= <= <= 28 Revenue Wood Cost Labor Cost $3,825.00 $1,080.00 $1,140.00 29 Profit $1,605.00 12 13 14 15 16 17 18 19 20 21 22 23 24 120 30 30 25 26 27 McGraw-Hill/Irwin 8.61 © The McGraw-Hill Companies, Inc., 2008 Advertising Example A 1 B C Advertising Example (Nonlinear) 2 3 4 5 6 7 8 Parameters: Unit Variable Cost Unit Price Salesforce Salary Fixed Overhead Seasonality $48 $65 $9,000 $23,000 1.2 9 10 11 Decision Variable: Advertising $122,949 12 Quarter 13 14 Q1 14994 Units Sold 15 16 17 18 Sales Revenue Cost of Sales Gross Margin $974,610 $719,712 $254,898 Total Fixed Costs $154,949 19 20 21 22 Profit Sales (35) (Seasonality Factor) McGraw-Hill/Irwin $99,949 8.62 Advertising + Sales Force 2 © The McGraw-Hill Companies, Inc., 2008 The Sales Function Sales (35) (Seasonality Factor) Advertising + Sales Force 2 20000 18000 16000 Sales Level 14000 12000 10000 8000 6000 4000 2000 0 0 50000 100000 150000 200000 Advertising McGraw-Hill/Irwin 8.63 © The McGraw-Hill Companies, Inc., 2008 Approximating a Nonlinear Function A 1 B C D Approximating the Nonlinear Sales Function 2 3 4 Seasonality = Sales Force = 1.2 9000 5 6 7 8 9 10 11 McGraw-Hill/Irwin Advertising Level $0 $50,000 $100,000 $150,000 $200,000 Sales Level 2,817 9,805 13,577 16,509 18,993 8.64 Slope 0.1398 0.0754 0.0586 0.0497 © The McGraw-Hill Companies, Inc., 2008 Advertising Example Using Separable Programming A 1 B C D E F G Advertising Example (Separable) 2 3 4 5 6 7 8 Parameters: Unit Variable Cost Unit Price Salesforce Salary Fixed Overhead Seasonality $48 $65 $9,000 $23,000 1.2 9 Units Sold per Advertising Dollar 0.1398 0.0754 0.0586 0.0497 10 11 12 13 14 15 Advertising ($0-$50,000) Advertising ($50,000-$100,000) Advertising ($100,000-$150,000) Advertising ($150,000-) 16 Quarter 17 18 Units Sold $50,000 $50,000 $0 $0 $100,000 <= <= <= $50,000 $50,000 $50,000 Total Advertising Q1 13577 19 20 21 22 Sales Revenue Cost of Sales Gross Margin $882,505 $651,696 $230,809 Total Fixed Costs $132,000 23 24 25 26 Profit McGraw-Hill/Irwin $98,809 8.65 © The McGraw-Hill Companies, Inc., 2008 Evolutionary Solver • The standard Solver has difficulty with problems that are – – – – • highly nonlinear are not smooth (have “kinks” in the objective) have discontinuities (the objective jumps in value) have many local optima (many hills and valleys) Excel functions like IF, MAX, ABS, ROUND, etc., tend to cause one or more of these problems. McGraw-Hill/Irwin 8.66 © The McGraw-Hill Companies, Inc., 2008 Premium Solver • Included on the textbook CD is the “Premium Solver”. After installing, a new button (“Premium”) is added to Solver. McGraw-Hill/Irwin 8.67 © The McGraw-Hill Companies, Inc., 2008 Premium Solver • Clicking on the “Premium” button switches to Premium Solver, which gives the option of three different solvers. – Standard GRG Nonlinear is equivalent to the regular Solver without choosing “Assume Linear Model”. – Standard Simplex LP is equivalent to the regular Solver with choosing “Assume Linear Model”. – Standard Evolutionary uses a genetic evolutionary algorithm that is only available with Premium Solver. McGraw-Hill/Irwin 8.68 © The McGraw-Hill Companies, Inc., 2008 How Genetic Algorithms (Evolutionary Solver) Work Genetic algorithms (such as Evolutionary Solver) use principles from the theory of evolution. • The Population: a large set of random solutions is generated. • Level of fitness: each member of the population (solution) is evaluated to determine its level of “fitness” (value of objective). • Evolution: a new generation (set of solutions) is created as follows: – Reproduction: pairs reproduce and create new solutions that share some properties of each. – Survival of the Fittest: more “fit” solutions reproduce more frequently, less “fit” solutions are allowed to die out. – Mutation: occasionaly random “mutations” are introduced. McGraw-Hill/Irwin 8.69 © The McGraw-Hill Companies, Inc., 2008 Inventory Ordering Policy with Quantity Discounts • Consider a manufacturer that orders a given part from a supplier. • They require 10,000 parts per year. • There is a cost associated with each order (due to processing, receiving costs, fixed shipping costs, etc.) of $20. • The cost of holding a part in inventory is estimated at $4 per year. • The supplier of this part offers quantity discounts on the purchasing cost of this part according to the following schedule. McGraw-Hill/Irwin Order Quantity Purchase Price (per unit) 1–99 $10.00 100–499 9.80 500–999 9.70 1,000–9,999 9.60 10,000+ 9.50 8.70 © The McGraw-Hill Companies, Inc., 2008 Total Annual Cost • Recall from Operations Management class that the total annual cost (including puchasing, ordering, and holding costs) is Total Annual Cost = Dp + (Q / 2)H + (D / Q)S where D = Annual demand p = purchase cost Q = order size H = annual holding cost per unit S = ordering cost McGraw-Hill/Irwin 8.71 © The McGraw-Hill Companies, Inc., 2008 Spreadsheet Model A 1 B C D E F G H I Ordering Policy with Quantity Discounts 2 Min Order Quantity 1 Price $10.00 8 100 500 1,000 $9.80 $9.70 $9.60 9 10,000 $9.50 3 4 5 6 7 1 Order Quantity <= 1000 <= 20,000 Annual Cost Purchasing Ordering Holding Total $192,000 $400 $2,000 $194,400 10 11 12 13 Annual Demand Ordering Cost Annual Holding Cost McGraw-Hill/Irwin 20,000 $20 $4 Price 8.72 $9.60 © The McGraw-Hill Companies, Inc., 2008 Attempts with Standard Solver Various “solutions” provided by the standard Solver, depending on the starting point: Starting Point (Q) Solution (Q*) Cost 1 1,000 $194,400 200 500 195,800 400 447 197,789 600 500 195,800 1,200 1,000 194,400 11,000 10,000 210,040 12,000 1,000 194,400 McGraw-Hill/Irwin 8.73 © The McGraw-Hill Companies, Inc., 2008 Cost Function with Quantity Discounts Cos t $230,000 $225,000 $220,000 $215,000 $210,000 $205,000 $200,000 $195,000 $190,000 10 100 447 500 1000 10,000 Order Quantity (logarithmic scale) McGraw-Hill/Irwin 8.74 © The McGraw-Hill Companies, Inc., 2008 Solving with the Evolutionary Solver A 1 B C D E F G H I Ordering Policy with Quantity Discounts 2 Min Order Quantity 1 Price $10.00 1 8 100 500 1,000 $9.80 $9.70 $9.60 <= 1000 <= 9 10,000 $9.50 3 4 5 6 7 Order Quantity 20,000 Annual Cost Purchasing Ordering Holding Total $192,000 $400 $2,000 $194,400 10 11 12 13 Annual Demand Ordering Cost Annual Holding Cost McGraw-Hill/Irwin 20,000 $20 $4 Price 8.75 $9.60 © The McGraw-Hill Companies, Inc., 2008 Tips on Using Evolutionary Solver • Bounding all of the variables greatly aids the Evolutionary Solver by decreasing the search space. • The limit options should be increased (Max Time, Max Subproblems, and Max Feasible Sols) for challenging problems. Setting Tolerance to 0.0005 and Max Time Without Improvements to 30 will ensure the algorithm will stop if the Target Cell value has improved less than 0.05% in the last 30 seconds. • Experiment with different populations sizes and mutation rates to see what works well. I have found that higher than default mutation rates can be helpful in problems with lots of local optima. • The Evolutionary Solver can take a very long time, but it will usually find a good solution. McGraw-Hill/Irwin 8.76 © The McGraw-Hill Companies, Inc., 2008 Tips on Using Evolutionary Solver • There is no guarantee that Evolutionary Solver will find the best solution. • The Evolutionary Solver performs well even with nasty objective functions, but is not very efficient at handling constraints. • Much of the solution process is driven by random numbers that direct the search. Thus, two people running Evolutionary Solver on the same model may get different results. • Once Evolutionary Solver has found a good solution, you can use GRG Nonlinear Solver (the nonlinear algorithm that is included with the Premium Solver software) to try to find a slightly better solution. McGraw-Hill/Irwin 8.77 © The McGraw-Hill Companies, Inc., 2008