Kennaraglósur Excel Flóknari aðgerðir: Solver 14 1 Excel Solver Excel Solver er viðbót (e. add-in) við Excel sem hjálpar til að finna bestu lausn á viðfangsefnum eins og þegar um er að ræða takmarkaðar auðlindir, hámarka arðsemi eða lágmarka kostnað. Solver gerir okkur kleift að skilgreina hvaða atriði við ætlum að hámarka, lágmarka eða láta ná ákveðnu gildi. Við getum sett skilyrði (e. constraint) sem afmarka möguleikana. Það þarf að tilgreina sérstaklega ef ætlun er að nota Solver og fleiri viðbætur og er það gert með því að smella á Office-hnappinn og velja Excel Options og velja síðan Add-Ins og þaðan að velja neðarlega í glugganum Manage: Excel Add-ins: Veldu síðan a.m.k. Solver Add-in til að leysa þetta verkefni, en helst þarftu að hafa merkt við þá sömu reiti og hér eru sýndir vegna annarra verkefna síðar. Athugaðu að þegar þú hefur gert þetta einu sinni þá þarft þú ekki að gera þetta aftur á þessari uppsetningu á tölvunni þinni, valið helst inni. Solver er að finna á Data-borðanum í Excel: 2 Kennsluefni/dæmi á ensku um solver Eftirfarandi kennsluefni er fengið frá Carlson School of Management, University of Minnesota. Vísað er til excel-skjals sem er að finna á Námskjá og heitir það Solver-daemi.xlsx Þú þarft að nota það til að vinna með. 2008 Jón Freyr Jóhannsson 1
Kennaraglósur 3 Using Solver In this example we will use these basic instructions to create solutions for different examples. (Use Electronics worksheet.) Follow the steps below to use Solver. 1. Create the worksheet for which you need a solution. 2. Select Tools, Solver. The Solver Parameters dialog box displays. 3. In the Target Cell: field, type (or select) the cell for which you want to find the optimal value. Hint: To collapse the dialog box, click, select the cells, then click again. 4. In the Equal To: field, select the desired option. This may be minimum, maximum, or a specific value. This is the goal you want Solver to achieve. 5. In the By Changing Cells: field, select (or type) the cells you want to change to achieve your goal. Hint: To select non-contiguous cells, press and hold Ctrl while clicking the desired cells. Note: You can click Guess. Solver will propose the appropriate changing cells based on your target cell. However, results may not be reliable. 6. To add constraints, click the Add button. (Adding constraints is optional). The Add Constraint dialog box displays. 7. In the Cell Reference: field, specify the desired constraint cell(s). 8. Select a comparative operator from the drop-down list in the middle of the dialog box. 2
9. In the Constraint: field, type a number or enter a cell to add your constraint. Note: If you select an Integer (int) constraint, the solution may take longer. The solution is rounded down. You cannot, for instance, create a partial television, so you might select Integer as a constraint. 10. If you want to add additional constraints, click Add and complete steps 7-9 for each constraint. 11. When finished adding constraints, click OK. You are returned to the Solver Parameters dialog box. The constraints display in alphabetical order. 12. Click Solve. Solver plugs trial values into your variable cells, recalculates the worksheets, and finds a solution to meet your objective and to satisfy your constraints. Your worksheet displays the results, and the Solver Results dialog box displays. 13. Select the desired option(s) and click OK. Options are described below. 3.1 Solver Result Options You have multiple options available from the Solver Results dialog box. Keep Solver Solution displays the results in the cells you specified. You cannot undo your solution. Restore Original Values restores the values that your variables held before activating Solver. (You can also click Cancel.) However, the solver parameters remain in the Solver Parameters dialog box if you save the file. Save Scenario allows you to save a scenario. Scenarios are covered in more detail in the Excel Advanced class. If you save a scenario, you are required to name it. This is a useful option when working with Solver. If you save as a scenario, click Cancel to return to the original values. You can view the saved scenario (or solution) by selecting Tools, Scenarios, selecting the desired scenario, and clicking Show. 2008 Jón Freyr Jóhannsson 3
Kennaraglósur Reports can create a variety of reports. These will be covered in more detail later in this class. See page 10. 3.2 Naming Cells If you assign a name to a target cell, Solver uses that name in its reports. If you don t name the cell, Solver creates a name based upon the column and/or row headings. To name a cell or range of cells, select the cell(s) you want to name, then click in the Name box (left of the Formula bar), type the desired name, and press Enter. Names cannot contain spaces. To edit named cell ranges, select Insert, Name, Define, to view the Name Define dialog box. 4
4 Linear Models You can set Solver to assume a linear model option. This can be activated only for models in which all the relationships are linear; models that use simple addition and subtraction and worksheet functions such as SUM are linear in nature. This information is provided in the event your class assignment involves linear programming. If you select a linear option, you will have additional fields in your Sensitivity report. See page 10 for more information on reports. 1. Select Tools, Solver. The Solver Parameters dialog box displays. 2. Enter the appropriate cells and constraints. 3. Click Options. The Solver Options dialog box displays. 4. Select Assume Linear Model and click OK. Note: You can set other options here, if desired. Consult Help for more information. Default settings are usually sufficient for most problems. 2008 Jón Freyr Jóhannsson 5
Kennaraglósur 5 Example CampMidwest Your company, CampMidwest, has inventory that includes items used to assemble camping kits. These kits consist of two types: standard or group. We will use Solver to determine the number of each kind of kit that can be assembled from existing inventory while maximizing profit. The constraints are that the numbers used to assemble cannot exceed the inventory, and we must have a minimum of 3 group kits. For this exercise use the following file: Solver Exercises.xls, worksheet CampMidwest. 1. Select Tools, Solver. The Solver Parameters dialog box displays. 6 2. In the Target Cell: field, enter E15. These are the total profits. Our goal is to maximize our total profits from the inventory available. 3. In the Equal To: field, select Maximum. 4. In the By Changing Cells: field, enter C4:D4. We want to determine how many kits we can assemble with the inventory available. 5. To add constraints, click the Add button. The Add Constraint dialog box displays.
6. In the Cell Reference: field, enter E6:E12 to specify the number of inventory items used. 7. Select <= in the middle of the dialog box. We want to indicate that the number of items used is less than or equal to the number of items available. 8. In the Constraint: field, select B6:B12, which is the amount of inventory available. 9. Click Add to add an additional constraint to indicate that we must have at least 3 group kits. 10. In the Cell Reference: field, enter D4>=3. This is to ensure that we have a minimum of 3 group kits assembled. 11. Click Add to add an integer constraint. We can t sell a partial camping kit. 12. Click OK. You are returned to the Solve Parameters dialog box. The constraints display in alphabetical order. 2008 Jón Freyr Jóhannsson 7
Kennaraglósur 13. Click Solve. Your result should display as follows. 14. If your results are the same as those above, click OK. If not, make changes and click Solve again. 8
6 Modifying a Constraint After using Solver in a worksheet, Excel retains the settings in the Solver Parameters dialog box. Follow these steps if you need to modify these settings. 1. Select, Tools, Solver. The Solver Parameters dialog box displays. 2. In the Subject to the Constraints: area, select the constraint you want to modify, and click Change. The Change Constraint dialog box displays. 3. Modify as necessary, and click OK. (Using the CampMidwest worksheet, modify the constraint to >=6). Note: If you have created a report (see below) before modifying a constraint, the report will not reflect your recent change. You may want to create another report. 2008 Jón Freyr Jóhannsson 9
Kennaraglósur 7 Creating Reports You can create three types of reports using Solver. Each provides information on how the solution was reached. Each report is created on a separate worksheet. Note: You can create a report at any time. However, if you want the original values to display in your Answer report, first enter the solver cells and constraints, click Solve, and create your report at that time. If you create a report after the solution has been displayed on your worksheet, the Answer report will only display the solved values in the original values field. The Answer report lists target cell results, the values of the cells that are changed, and the constraints. It also includes information about the value of each constraint. Status can be binding, not binding, or not satisfied. The slack value is the difference between the solution value of the constraint and the number that appears to the right of the constraint formula. A binding constraint has a slack value of 0. (Everything was used to solve the problem.) The Sensitivity report indicates how sensitive the model is to changes in the target cell formula and the changing cells. o The Adjustable Cells area displays a Reduced Gradient value. This indicates how a one-unit increase in the changing cell would affect the target cell. o The Constraints area displays a Lagrange Multiplier column, which indicates how the target cell would be affected by a one-unit increase in the corresponding constraint value. o If you selected Assume Linear Model, (page 5) the Sensitivity report includes several additional columns. The Reduced Cost column shows the increase in the target cell value per unit of change. The Objective Coefficient column shows the degree to which the changing cell and the target cell are related. The Allowable Increase and Decrease columns reflect the amount the Objective Coefficient must change before the changing cells are affected. In the constraints area, the Shadow Price column indicates the increase in the target value for each unit that the constraint increases. The Constraint RH displays the constraint values used in the problem. The allowable increase and Decree columns show the amount that the constraint value must change before the changing cells are affected. The Limits report indicates how much the values of the variable cells can be increased or decreased without breaking the constraints of your problem. The report lists the optimal value, as well as the lowest and highest values that can be used without violating the constraints. Note: Sensitivity Reports and Limits Reports and not relevant for problems with Integer constraints. 10
8 Example - Advertising You are planning an ad campaign for one of your new products. You want to reach the largest readership at the lowest possible cost. You will use six publications. Each publication reaches a different number of readers and charges a different rate per page. The following constraints will apply: The total budget for print advertising is $12,000,000. The total amount spent in Publications C and D should not exceed $7,500,000. You want to expose your ads to potential readers at least 800 million times. You plan to use each publication a minimum of six times. The total percent of the print advertising budget should be no more than 33.3% for any one publication. For this exercise use the following file: Solver Exercises.xls, worksheet Advertising. 2008 Jón Freyr Jóhannsson 11
Kennaraglósur 1. Select Tools, Solver. The Solver Parameters dialog box displays. 2. In the Set Target Cell: field, enter E8 (TotalCost). 3. In the Equal To: field, select Min. Our goal is to get the most advertising for the smallest investment. 4. In the By Changing Cells: field, enter D2:D7. We want to change the number of ads placed in each publication. 5. In the Subject to Constraints: area, click Add. 12
6. Enter the constraints as displayed below. $D2:$D7 = integer (this means that it will round down to the next integer. You can t, for instance, have advertisements in a half a publication.) $D2:$D7 >= $G$15 (The number of ads must be a minimum of six per publication.) $F$2:$F$7 <=$G$14 (No more than one-third of the budget should be used for any one publication.) $E$9 <= $G$12. (The total spent on publications C and D should be no more than $7,500,000.) TotalCost <=$G$11 (The maximum advertising expenditure is $12,000,000.) TotalAudience >= $G$13 (You want to reach at least 800 million viewers.) 7. Click Solve. The Solver Results screen displays. 8. Click OK to display the solution. OR Select Restore Original Values. Note: To create a report, select the desired report type; then click OK. You can do this with or without keeping the solver solution. To save the solution as a scenario, click Save Scenario. You can do this with or without keeping the solver solution. To view a saved scenario, click Tools, Scenarios. Select the scenario you want to view and click Show. 2008 Jón Freyr Jóhannsson 13