Chapter 3 Introduction to Optimization Modeling Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Introduction to Optimization Common elements of all optimization problems – Decision Variables - the variables whose values the decision maker is allowed to choose. (Changing cells in Excel) – Objective Function - value that is to be optimized – maximized or minimized (Target cell in Excel) – Constraints that must be satisfied – Constraints impose restrictions on the values in the changing cells. (Subject to constraints in Excel) – Non-negativity – Decision variables cannot have negative values (Options, check non-negative in Excel) Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Solutions A feasible solution is any set of values of the decision variables that satisfies all of the constraints. The set of all feasible solutions is called the feasible region. An infeasible solution is a solution where at least one constraint is not satisfied. The optimal solution is the feasible solution that optimizes the objective. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Steps – Model development – decide what the decision variables are, what the objective is, which constraints are required and how everything fits together – Optimize – systematically choose the values of the decision variables that make the objective as large or small as possible and cause all of the constraints to be satisfied. – Sensitivity analysis – How changes to parameters of the problem will affect the optimal solution Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Example 3.1 – Two Variable Model Maggie will allow herself no more then 450 calories and 25 grams of fat in her daily desserts. She requires at least 120 grams of desserts a day. Each dessert also has a “taste index”. What should her daily dessert plan be to stay within her constraints and maximizes the total taste index of her dessert? Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Summary of given data Serving of snack bar Serving of ice cream Limits Calories 120 160 450 per day Fat 5 grams 10 grams 25 grams per day Weight 37 grams 65 grams At least 120 grams/day Taste per gram 85 95 Taste per serving 37 x 85 = 3145 65 x 95 = 6175 Maximize total taste Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Formulation Decision variables Daily servings of snack bar = Snack Bars Daily servings of ice cream = Ice Cream Objective function – Maximize total taste index Max Z = 3145 X Snack Bars + 6175 X Ice Cream Constraints – Calories consumed per day ≤ 450 – Fat consumed per day ≤ 25 grams – Total dessert consumed ≥ 120 grams Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Constraints Calories consumed per day ≤ 450 120 X Snack Bars + 160 X Ice Cream ≤ 450 Fat consumed per day ≤ 25 grams 5 X Snack Bars + 10 X Ice Cream ≤ 25 Total dessert consumed ≥ 120 grams 37 X Snack Bars + 65 X Ice Cream ≥ 120 Non-negativity constraints X1, X2 ≥ 0 Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Complete model Maximize Z = 3145 X Snack Bars + 6175 X Ice Cream Subject to: 120 X Snack Bars + 160 X Ice Cream ≤ 450 Calories 5 X Snack Bars + 10 X Ice Cream ≤ 25 Fat 37 X Snack Bars + 65 X Ice Cream ≥ 120 Total wt. x1,x2 ≥ 0 Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.1(cont’d) - Spreadsheet Model Common elements in all LP spreadsheet models are: – Inputs – all numeric data given in the statement of the problem (Blue border) – Changing cells – the values in these cells can be changed to optimize the objective (Red border) – Target(objective) cell – contains the value of the objective (Double line black boarder) – Constraints – specified in the Solver dialog box – Nonnegativity – check an option in a Solver dialog box to indicate nonnegative changing cells Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.1(cont’d) - Spreadsheet Model Three stages of the complete solution: – Model development stage – enter all inputs, trial values for the changing cells, and formulas relating these in spreadsheet – Invoke Solver – designate the objective cell, changing cells, the constraints and selected options, and tell Solver to find the optimal solution. – Sensitivity analysis – see how the optimal solution changes as the selected inputs vary Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.1(cont’d) - Spreadsheet Model Solver dialog box for this model. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.1(cont’d) - Spreadsheet Model Optimal Solution for the Dessert Model Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.1(cont’d) - Spreadsheet Model In this solution the calorie and fat constraints have been met exactly, thus they are binding. The constraint on grams in nonbinding, the positive difference in grams is called slack. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc The SolverTable Add-in allows us to ask sensitivity questions about any of the input variables. SolverTable’s can be used in two ways: – One-way table – single input cell and any number of output cells – Two-way table – two input cells and one or more outputs The results are easily interpreted. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc For the dessert model, check how sensitive the optimal dessert plan and total taste index are to (1) changes in the number of calories (2) the number of daily dessert calories allowed. The solution to question (1) can be solved by selecting the Data/SolverTable menu item and select a one-way table in the first dialog box. The second dialog box should be completed as shown on the next slide. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc The second question asks us to vary two inputs simultaneously. This requires a two-way SolverTable. Select the two-way option in the first SolverTable dialog box to get the two-way table dialog box. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc 3.5 Properties of Linear Models Linear programming is an important subset of a larger class of models called mathematical programming models. Three important properties that LP models possess – Proportionality • If a level of any activity is multiplied by a constant factor, the contribution of this activity to the objective, or to any of the constraints in which the activity is involved, is multiplied by the same factor. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc – Additivity • This property implies that the sum of the contributions from the various activities to a particular constraint equals the total contribution to that constraint. – Divisibility • This property means that both integer and noninteger levels of the activities are allowed. How can you recognize whether a model satisfies proportionality and additivity? Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Not easy to recognize in a spreadsheet model because the logic of the model can be embedded in a series of cell formulas. Often it is easier to recognize when a model is not linear. Two situations that lead to nonlinear models are when 1. there are products or quotients of expressions involving changing cells, and 2. there are nonlinear functions, such as squares, square roots, or logarithms, of changing cells. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Real-life problems are almost never exactly linear. However, a linear approximation often yields very useful results. In terms of Solver, if the model is linear the Assume Linear Model box must be checked in the Solver Options dialog box. Check the Assume Linear Model box even if the divisibility property is violated. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc If the Solver returns a message that “the condition for Assume Linear Model are not satisfied” it – can indicate a logical error in your formulation. – can also indicate that Solver erroneously thinks the linearity conditions are not satisfied. Try not checking the Assume Linear model box and see if that works. In any case it always helps to have a well-scaled model. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc 3.6 Infeasibility and Unboundedness It is possible that there are no feasible solutions to a model. There are generally two possible reasons for this: 1. There is a mistake in the model (an input entered incorrectly) or 2. the problem has been so constrained that there are no solutions left. In general, there is no foolproof way to find the problem when a “no feasible solution” message appears. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc A second type of problem is unboundedness. Unboundedness is that the model can be made as large as possible. If this occurs it is likely that a wrong input has been entered or forgotten some constraints. Infeasibility and unboundedness are quite different. It is possible for a model to have no feasible solution but no realistic model can have an unbounded solution. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Example 3.2 – Product Mix Model The product mix problem is basically to select the optimal mix of products to produce to maximize profit. The Monet company produces four types of picture frames. The four types differ with respect to size, shape and materials used. Each frame requires a certain amount of skilled labor, metal and glass. They also all have different selling prices. Monet can produce in the coming week but they do not want any inventory at the end of the week. What should the company do to maximize its profit for this week? Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.2(cont’d) - Algebraic Model Maximize Subject to 6x1 + 2x2 + 4x3 + 3x4 (profit objective) 2x1 + x2 + 3x3 + 2x4 4000 (labor constraint) 4x1 + 2x2 + x3 + 2x4 10,000 (glass constraint) x1 1000 (frame 1 sales constraints) x2 2000 (frame 2 sales constraints) x3 500 (frame 3 sales constraints) x4 1000 (frame 4 sales constraints) x1, x2, x3, x4 0 (nonnegativity constraint) Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.2(cont’d) - Spreadsheet Model To develop the spreadsheet model follow these steps: – Inputs - Enter the various inputs in the shaded ranges. Enter only numbers, not formulas in the input cells. – Range names – Name the ranges as indicated. – Changing cells - Enter any four values in the range named Produced. – Resources used - Enter the formula =SUMPRODUCT (B9:E9,Produced) in cell B21 and copy it to the rest of the Used range. – Revenues, costs, and profits – Enter the formulas to calculate these values. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc The optimal solution for the product mix model is shown on the next slide. The sensitivity analysis allows us to experiment with different inputs to this problem. Simply change the inputs and then rerun Solver. Use SolverTable to perform a more systematic sensitivity analysis on one or more input variables. Additional insight can be gained from Solver’s sensitivity report. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Example 3.3 – Another Product Mix Model Pigskin company must decide how many footballs to produce each month. It has decided to us a 6-month planning horizon. Pigskin wants to determine the production schedule that minimizes the total production and holding costs. By modeling this type of problem, one needs to be very specific about the timing events. By modifying the timing assumptions in this type of model, one can get alternative – and equally realistic – models with very different solutions. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.3(cont’d) - Spreadsheet Model The difference between this model from the product mix model is that some of the constraints are built into the spreadsheet itself by means of the formulas. The only changing cells are production quantities. To develop the spreadsheet model: – Inputs - Enter the inputs in the shaded ranges. – Name ranges – Name ranges indicated. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.3(cont’d) - Spreadsheet Model – Production quantities - Enter any values in the range Produced as the production quantities. As always, you can enter values that you believe are good, maybe even optimal. – On-hand inventory - Enter the formula =B4 + B12 in cell B16. This calculates the first month on-hand inventory after production. Then enter the “typical” formula =B20 + C12 for on-hand inventory after production in month 2 in cell C16 and copy it across row 16. – Ending inventories - Enter the formula =B16 – B18 for ending inventory in cell B20 and copy it across row 20. – Production and holding costs - Enter the formula calculate the monthly holding costs. Finally, calculate the cost totals in column H by summing with the SUM function. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.3(cont’d) - Spreadsheet Model The optimal solution from Solver. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc Ex. 3.3(cont’d) - Spreadsheet Model SolverTable can be used to perform a number of interesting sensitivity analyses. In multiperiod models, the company has to make forecasts about the future, such as the level of demand. The length of the planning horizon is usually the length of time for which the company can make reasonably accurate forecasts. Copyright © 2005 Brooks/Cole, a division of Thomson Learning, Inc