Spreadsheet-Based Decision Support Systems Chapter 8: Solving Mathematical Programs Prof. Name Position University Name name@email.com (123) 456-7890 Overview Introduction Formulating Mathematical Programs The Risk Solver Platform Applications of the Solver Summary 2 Introduction Formulating a mathematical program by determining its decision variables, constraints, and objective function The difference between linear, integer, and nonlinear programming problems Using the Risk Solver Platform to solve a mathematical program Preparing the spreadsheet with the model parts. Updating the Risk Solver Task Pane Reading the Solver reports Example linear, integer, and nonlinear programming problems 3 Formulating Mathematical Programs Parts of the Mathematical Program Linear, Integer, and Nonlinear Programming 4 Parts of the Mathematical Program Decision Variables = variables assigned to a quantity or response that must be determined in the problem Objective Function = equation which states the goal of the model – Maximize – Minimize Constraints = equations or inequalities which state limitations or requirements of the problem To solve the model, each constraint must be considered simultaneously in conjunction with the objective function 5 Linear Integer and Nonlinear Programming Linear Programming problem = there is a linear relationship among all constraints and the objective function Integer Programming problem = decision variables can only take integer values in a given range (these integer values can also be boolean = 0 or 1 only) Nonlinear Programming problem = do not have a linear objective function and/or constraints. NLP problems must use more challenging methods to solve these complex equations. 6 The Risk Solver Platform The Risk Solver Platform Steps Understanding Solver Reports 7 The Solver Steps Step 1: Read and Interpret the Problem – Step 1.1: Determine the Decision Variables – Step 1.2: State the Objective Function – Step 1.3: Define any Constraints Step 2: Prepare the Spreadsheet – – – – Step 2.1: Place the Input Table Step 2.2: Set the Decision Variables Cells Step 2.3: Enter the Constraint Formulas Step 2.4: Enter the Objective Function Formula Step 3: Solve the model with Risk Solver Platform – – – – – Step 3.1: Set Objective. Step 3.2: Select Variables Step 3.3: Add Constraints Step 3.4: Set Solver Options Step 3.5: Solve the model and review Results 8 Product Mix Problem A company produces six different types of products. They want to schedule their production to determine how much of each product type should be produced in order to maximize the profits. This is known as the Product Mix problem. Production of each product type requires labor and raw materials; but the company is limited by the amount of resources available. There is also a limited demand for each product, and no more than this demand per product type can be produced. Input tables for the necessary resources and the demand are given. 9 Step 1 Decision Variables: The amount produced of each product type – x1, x2, x3, x4, x5, x6 Objective Function: Maximize Profit – z = p1*x1 + p2*x2 + p3*x3 + p4*x4 + p5*x5 + p6*x6 Constraints: – Labor Constraint: l1*x1 + l2*x2 + l3*x3 + l4*x4 + l5*x5 + l6*x6 <= available labor = 4500 – Raw Material Constraint r1*x1 + r2*x2 + r3*x3 + r4*x4 + r5*x5 + r6*x6 <= available raw material = 1600 – Demand Constraint: xi <= Di for i = 1 to 6 10 Step 2 The spreadsheet should have each part of the model clearly defined. 11 Figure 8.2 The Labor and Raw Material constraint formulas use the SUMPRODUCT function. 12 Figures 8.3 and 8.4 For the demand constraint, ensure that the values in our decision variable range are less than each of the corresponding values in the “Demand” range. The objective function formula is also written with the SUMPRODUCT function. 13 Step 3 The Solver receives the decision variables, constraint equations, and objective function equation as input into a hidden programming code that applies the algorithm to the data. To use the Solver: – We activate the Solver Task Pane: Click on: Risk Solver Platform > Model > Model command. – Use the Optimization tools listed in the Task Pane to update problem’s Objective, Variables, and Constraints – Alternatively, use the commands listed in Risk Solver Platform tab on the Ribbon. 14 Figure 8.6 Set the objective function: Select cell where the objective function formula is typed. Click on: Risk Solver Platform > Optimization Model > Objective command. From the drop-down list that appears, select Max, and click on the Normal option from the fly-out menu. 15 Figure 8.7 The selected Objective cell will appear in the task pane. Use the Objective window located in the bottom of the task pane to change the address, sense or value of the objective cell. 16 Figure 8.8 Select decision variables: Highlight the decision variable cells Click on: Risk Solver Platform > Optimization Model > Decisions command. From the drop-down list that appears, select Normal option. 17 Figure 8.9 Select the objective cell; and click on: Risk Solver Platform > Optimization Problem > Decisions command. Select Plot from the Decisions dropdown menu. The graph confirms that the objective function of the Product Mix problem is linear. 18 Figure 8.10 Add constraints: Click on: Risk Solver Platform > Optimization Model > Constraints command. From the Constraints drop-down menu, select Normal and then click on the <= sign on the fly-out menu 19 Figures 8.11 and 8.12 Each added constraint should include: – The cell with the constraint formula. – The cell with the RHS value, or a directly entered numerical value. We can define more than one constraint at a time. The task pane lists all of the constraints of a problem. Use the Normal Constraint window of the task pane to change the left hand side, the RHS and sense of a constraint. 20 Figure 8.13 The final Risk Solver Task Pane lists – Decision variables – Constraints – Objective function of the model. Click on the Analyze without Solving button located in the upper-right corner of the task pane. The Model Diagnosis window in the bottom half of the task pane presents a summary of model characteristics. 21 Figure 8.14 We modify some of the Risk Solver’s Platform and Engine related options before we solve the model. – Change the lower bound of the decision variables (Decision Vars Lower) to 0. – Set the Solve Mode to Solve Complete Problem. – Set the Intended Model Type as Linear. The rest of the options is kept at their default values. 22 Figure 8.15 Max Time, is the maximum time that the Solver should take to find a solution to the model. The number of Iterations affects the number of iterations for which the Solver’s algorithm will run. Primal (Dual) Tolerance is an upper bound on the amount by which the primal (dual) constraints can be violated and be considered feasible. Set the value of Show Iterations to True if you want Solver to pause at every iteration. 23 Figure 8.15 (cont’d) If you set the value of Use Automatic Scaling to True, then Solver rescales the values of the objective function and constraints internally. Set the value of Bypass Solver Reports to False if you do not need the reports related to the current solution run. Set the value of Presolve to True to allow Solver to perform a presolve step prior to applying the Primal or Dual Simplex method. Select either option from Derivates drop-down list to determine how Solver computes derivates when solving Quadratic Programming (QP) problems. 24 Figure 8.16 To run the solver: – Click on: Risk Solver Platform > Solve Action > Optimize command. – From the Optimize drop-down menu select Solve Complete Problem. – Alternatively, click on the green arrow on the top-right corner of the task pane. During the time that Solver seeks for a solution, the Output tab of the task pane becomes active and presents a description of the different events that occur while the problem is being solved. 25 Figure 8.17 If Solver finds an optimal solution, then, we observe this solution in the background of our spreadsheet. This solution indicates that all constraints are met. 26 Infeasibility In an infeasible problem at least one of the constraints cannot be met. Example: Let consider this problem is infeasible due to “Demand” not being met. Select the “Demand” (Bound) Constraint from the Model tab of task pane, and change the Relation property to >= Constraint. 27 Figure 8.19 The Output window of the task pane conveys that the Solver could not find a feasible solution with this modified constraint. This solution is infeasible because there are not enough resources available to meet the demand,. 28 Figure 8.20 The Feasibility report identifies the exact constraints that are violated by the current solution. The feasibility report for this example indicates that constraint H13 >= H15 is violated. 29 Figure 8.21 The results of this infeasible solution are shown. 30 Unboundedness In an unbounded problem the objective function can reach an unreasonably large number (if we are maximizing) or small number (if we are minimizing). Such a situation implies that the constraints are not inclusive enough. 31 Figure 8.23 To observe unboundedness: – Select Objective from Solver task pane and change its sense to Minimize. – Set the value of Assume NonNegative to False from the General properties window of the Engine tab of the task pane. – Solve the problem. The Solver indicates that objective values did not converge. 32 Solver Reports The three main reports available when using the Risk Solver Platform are the Answer report, the Sensitivity report, and the Limits report. To generate these reports, click on: Risk Solver Platform > Analysis > Reports command. Select Optimization from the Reports drop-down menu. Next, select Answer, Sensitivity or Limits reports from the fly-out menu. 33 Answer Report The Answer Report provides the original and final values of the Objective Cell, Decision Variable Cells, and the Constraints. 34 Sensitivity Report The Sensitivity Report provides information about the Decision Variable Cells and the Constraints as well as their final values. 35 Limits Report The Limits Report provides information about the Objective Cell and the Decision Variable Cells. It also includes the value of each cell. 36 Applications of the Solver Transportation Problem Workforce Scheduling Capital Budgeting Warehouse Location 37 Transportation Problem A company ships their products from three different plants (one in LA, one in Atlanta, and one in New York City) to four regions of the United States (East, Midwest, South, West). Each plant has a capacity on how many products can be sent out, and each region has a demand of products they must receive. There is a different transportation cost between each plant, or each city, and each region. The company wants to determine how many products each plant should ship to each region in order to minimize the total transportation cost. 38 Transportation Problem (cont’d) Decision variables: – The amount to ship from each plant to each region Constraints : – Demand: the total number of products received by a region (from each plant) is greater than or equal to its demand – Capacity: the total number of products shipped from a plant (to each region) is less than or equal to its capacity Objective function: – Minimize the total transportation costs 39 Figure 8.27 Prepare the spreadsheet 40 Figure 8.28 Set the Objective Cell and choose Min for our objective function. Set the Variables Add both the capacity and demand constraints to the constraint list. Select Standard LP/Quadratic Engine as the solution method. Set the value of Assume Non-Negative property to True. 41 Figure 8.29 The solution 42 Workforce Scheduling A company wants to schedule its employees for every day of the week. Employees work 5 days consecutively, so the company wants to schedule on which day each employee starts working; that is how many employees start working each day. There is a certain number of employees needed each day of the week. The objective function is to find the schedule which minimizes the total number of employees working for the week. 43 Workforce Scheduling (cont’d) Decision variables: – The number of employees that will begin working (for 5 consecutive days) on each day of the week Constraints: – The total number of employees working on a given day (regardless of which day they started working) is greater than or equal to the number of employees needed on that particular day Objective function: – Minimize the total number of employees needed 44 Figure 8.30 Prepare the spreadsheet 45 Figure 8.31 Specify the Objective and choose Min for the objective function. Set the Variables Add the Constraint to the constraint list.. Specify Standard LP/Quadratic Engine for solving the problem. Set the Assume Non-Negative property to True. 46 Figure 8.32 The solution 47 Figures 8.33 and 8.34 Integer constraint must be added 48 Figure 8.35 Updated solution 49 Figure 8.36 What happens to the total number of employees required when the number of employs needed on a Saturday increases from 9 to 16? Modify the model: -Cell I19: =PsiOptParam(M10:M17) -Cell N10: = PsiOptValue($C22$,L10) -Copy N10 to N11:N17 -Set the value of Optimizations to Run property to 8 in the Platform tab of Solver task pane. Solve the problem. 50 Figure 8.37 The PsiOptParam() function of Risk Solver Platform supports multiple parameterized optimizations. The results present the total number of employees needed as Saturday requirements increase. To observe the solution of a run, select the corresponding Opt # from Risk Solver Platform > Tools group. 51 Capital Budgeting There are 20 projects that a company, or individual, can invest in. Each project has a net present value (NPV) and cost per year given. The company, or investor, wants to determine how much to invest in each project, given a limited amount of yearly funds available, in order to maximize the total NPV of the investment. 52 Capital Budgeting (cont’d) Decision variables: – Which projects we do and do not invest in. Constraints: – No more than the yearly available funds can be spent each year. Objective Function: – Maximize the total NPV. 53 Figure 8.38 Input table for the capital budgeting problem 54 Figure 8.39 Prepare the spreadsheet 55 Figures 8.40 and 8.41 Add binary constraint. 56 Figure 8.42 Select the Standard Evolutionary Engine as the solution method for this problem. Set the value of Assume Non-Negative property to True. Set the values of Convergence, and Maximum Time without Improvement as shown. Keep the rest of the parameters at their default values. 57 Figure 8.43 The Solver runs several iterations of the Genetic Algorithm to solve the problem. The objective function value for each iteration is plotted in the task pane. The Integer Gap for the solution found is zero. This solution is optimal. 58 Figure 8.44 The solution 59 Warehouse Location A company stores all of its products in one warehouse. The company has customers in cities around the United States. The company wants to determine the best location of their warehouse in order to minimize the total transportations costs. Each city’s location is given by its latitude and longitude. The number of shipments made to each city is also given. We are to determine the warehouse location based on its latitude and longitude values. 60 Warehouse Location (cont’d) Decision variables: – The latitude and longitude values of the location of the warehouse. Constraints: – The latitude and longitude for the warehouse location must be between the values of 0 and 120. Objective function: – Minimize the total distance traveled from the warehouse to each city. 61 Figure 8.45 Prepare the spreadsheet 62 Figure 8.46 Calculating the distance between each city and the possible warehouse location 63 Figure 8.47 The objective function formula 64 Figures 8.48 and 8.49 The completed optimization model is shown. The Standard GRG Nonlinear Engine is used to solve this nonlinear programming problem. 65 Figure 8.50 The Output tab of Solver’s task pane indicates that the Solver has converged to the current solution. 66 Figure 8.51 The solution 67 Summary The three parts of a mathematical model are decision variables, objective function, and constraints. The three primary types of mathematical models are linear, integer, and nonlinear programming problems. Using Risk Solver Platform involves three main steps: reading and interpreting the problem to determine the three parts of the model; preparing the spreadsheet so that Solver can read the data; and running the Solver. LP examples are Transportation and Workforce Scheduling. An IP example is Capital Budgeting, and an NLP example is the Warehouse Location problem. We use the multiple parameterized optimization capabilities of Risk Solver Platform to solve a multi-scenario Workforce Scheduling problem. 68 Additional Links (place links here) 69