How to use Solver in MS Excel

Embed Size (px)

Citation preview

  • 8/13/2019 How to use Solver in MS Excel

    1/8

    MS EXCEL

    HOW TO USE SOLVER ADD-IN TO TACKLE OPTIMAZATION PROBLEMS

    You can use Solver to tackle multi variable forecasting and optimazation problems.When your forecasting problem contains more than one variable, you need to use the

    Solver add-in utility to analyze the scenario.

    Suppose we are running a coffee shop that currently sells three beverages: regular fresh-brewed coffee, premium caffe latte, and premium caffe mocha. We currently priceregular coffee at $1.25, caffe latte at $2.00, and caffe mocha at $2.25, but were not surewhat our revenue potential is and what emphasis we should give to each of the

    beverages. (Although the premium coffees bring in more money, their ingredients aremore expensive and they take more time to make than regular coffee.) We can makesome basic calculations by hand, but we want to structure our sales data in a worksheetso that we can periodically add to it and analyze it using the Solver.

    Note The Solver is an add-in utility, so you should verify that its installed on yoursystem before you get started. If the Solver command isnt on your Toolsmenu, chooseTools, Add-Ins, and select the SolverAdd-Inoption in the Add-Insdialog box. IfSolver isnt in the list, youll need to install it by running the Office Setup programagain and selecting it from the list of Excel add-ins.

    Setting up the problem

    The first step in using the Solver command is to build a Solver-friendly worksheet. Thisinvolves creating a target cellto be the goal of your problemfor example, a formula

    that calculates total revenueand assigning one or more variable cellsthat the Solvercan change to reach your goal. Your worksheet can also contain other values andformulas that use the target cell and the variable cells. In fact, for the Solver to do its

    job, each of your variable cells must beprecedentsof the target cell. (In other words, theformula in the target cell must reference and depend on the variable cells for part of itscalculation.) If you dont set it up this way, when you run the Solver youll get the errormessage, The Set Target Cell values do not converge.

    Figure 1 shows a simple worksheet that we can use to estimate the weekly revenue forour example coffee shop and to determine how many cups of each type of coffee we willneed to sell. The worksheet in the figure appears in Formula Auditing mode, which was

    enabled by choosing Tools, Formula Auditing, Formula Auditing Mode. Cell G4 isthe target cell that calculates the total revenue that the three coffee drinks generate. Thethree lines that converge in cell G4 were drawn by selecting that cell and choosingTools, Formula Auditing, Trace Precedents. The arrows show how the formula in cellG4 depends on three other calculations for its result. (To remove the arrows, chooseTools, Formula Auditing, Remove All Arrows.)

    The three variable cells in the worksheet are cells D5, D9, and D13these are the blankcells whose values we want the Solver to determine when it finds a way to maximize ourweekly revenue.

    In the bottom-right corner of our screen is a list of constraints we plan to use in ourforecasting. A constraintis a limiting rule or guiding principle that dictates how the

    business is run. For example, because of storage facilities and merchandisingconstraints, were currently able to produce only 500 cups of coffee (both regular and

    premium) per week. In addition, our supply of chocolate restricts the production of caffe

  • 8/13/2019 How to use Solver in MS Excel

    2/8

    mochas to 125 per week, and a milk refrigeration limitation restricts the production ofpremium coffee drinks to 350 per week.

    Figure 1: The commands on the Tools, Formula Auditingsubmenu help you visualizethe relationship between cells. Here the target cell depends on three other cells, each ofwhich contains a formula.

    These constraints structure the problem, and well enter them in a special dialog boxwhen we run the Solver command. Your worksheet must contain cells that calculate thevalues used as constraints (in this example, G8, G7, and D13). The limiting values forthe constraints are listed in cells G11 through G13. Although listing the constraints isntnecessary, it makes the worksheet easier to follow.

    Tip: Name key cells

    If your Solver problem contains several variables and constraints, youll find it easiest toenter data if you name key cells and ranges in your worksheet by using the Insert, Name,Define command. Using cell names also makes it easy to read your Solver constraintslater.

    Running the Solver

    After youve defined your forecasting problem in the worksheet, youre ready to run theSolver add-in. The following steps show you how to use the Solver to determine themaximum weekly revenue for your coffee shop given the following constraints:

    No more than 500 total cups of coffee (both regular and premium) No more than 350 cups of premium coffee (both caffe latte and caffe mocha) No more than 125 caffe mochas

    In addition to telling you the maximum revenue, the Solver calculates the optimumdistribution of coffees in the three coffee groups. To use the Solver, complete thefollowing steps:

    1. Click the target cellthe one containing the formula thats based on the variablecells you want the Solver to determine. In our example, as shown in Figure 1, thetarget cell is G4.

  • 8/13/2019 How to use Solver in MS Excel

    3/8

    2. Choose Tools, Solver. The Solver Parametersdialog box will open, as shownhere:

    3. If the Set Target Celltext box doesnt already contain the correct reference,select the text box and then click cell G4 to insert $G$4as the target cell.

    4. Select the Maxoption following the Equal Tolabel, because you want to findthe maximum value for the target cell.

    5. Click the button at the right end of the By Changing Cellstext box to collapsethe dialog box. Select each of the variable cells. If the cells adjoin one another,simply select the group by dragging across the cells. If the cells arenoncontiguous, as in our example, hold down the Ctrl key and click each cell(this will place commas between the cell entries in the text box).

    For our example, select cells D5, D9, and D13 (the three blank cells reserved for thenumber of cups of coffee that need to be sold in each category), which will place thefollowing value in the By Changing Cellstext box: $D$5,$D$9,$D$13, as shown here:

    Tip: Use theGuessbutton to preview the result

    If you click the Guessbutton, the Solver tries to guess at the variable cells in yourforecasting problem. The Solver creates the guess by looking at the cells referenced inthe target cell formula. Dont rely on this guess, thoughits often incorrect!

  • 8/13/2019 How to use Solver in MS Excel

    4/8

    6. Constraints arent required in all Solver problems, but this problem has three.Click the Addbutton to add the first constraint using the Add Constraintdialog

    box.

    The first constraint is that you can sell only 500 cups of coffee in one week. To enter

    this constraint, click cell G8 (the cell containing the total cups formula), select

  • 8/13/2019 How to use Solver in MS Excel

    5/8

    Tip

    To modify one of the constraints that appears in the Solver Parametersdialog box,select the constraint and click the Changebutton. To customize the iteration andcalculation parameters in the Solver utility, click the Optionsbutton and make your

    adjustments.

    10.Your forecasting problem is ready to go, so click the Solvebutton to calculatethe result.

    After a brief pause the Solver will display the Solver Resultsdialog box describing howthe optimization analysis went. If the Solver runs into a problem, youll see an errormessage, and you can click the Helpbutton to learn more about the difficulty. If theSolver finds a solution, you see the following dialog box:

    11.To display the new solution in your worksheet, select the Keep Solver Solutionoption in the Solver Resultsdialog box and then click the OKbutton. TheSolver will place an optimum value in the target cell and will fill the variablecells with the solutions that best match the constraints you specified, as shown inFigure 2.

    In this example, youve learned that if youre limited to selling 500 cups of coffee perweek, you can expect a maximum of $918.75 in revenue and your optimum drinkdistribution is 150 cups of regular coffee, 225 cups of caffe latte, and 125 cups of caffemocha. Although this financial model doesnt consider several realistic businessvariables, such as the costs associated with running a shop and the benefits of makingvolume purchases, it does help you to forecast much more easily and quickly than you

    could using pencil and paper.

  • 8/13/2019 How to use Solver in MS Excel

    6/8

    Figure 2: When the Solver finishes, the values that produce the optimum result in thetarget cell will appear in the variable cells.

    Maximum revenueThree variables that represent the mix of drink quantities for maximum return, given

    the constraints

    Editing your Solver forecast

    Perhaps the best feature of a Solver forecast is that you can easily edit it to evaluate newgoals and contingencies. For example, if you decide that you want to earn exactly $700

    per week from coffee drinks, you can use the Solver to tell you what the optimumcombination of drinks would be. Setting a target value in the Solver is a little like usingthe Goal Seek command to determine a value for an unknown variable, although withSolver you can use more than one variable.

    To edit the Solver forecast you created in the previous exercise to find the variablesneeded to reach a specific goal, follow these steps:

    1. Activate the worksheet in which you previously used the Solver. In the variablecells, leave the values that were generated by the Solver in the previous exercise(namely, 150 in D5, 225 in D9, and 125 in D13).

    2. Choose Tools, Solver. The Solver Parametersdialog box will appear, stilldisplaying the target, variables, and constraints from your last Solver problem.Youll adjust these to compute a new forecasting goal.

    3. Select the Value Ofoption and type 700in the text box to the right. The ValueOfoption sets the target cell to a particular goal so that you can determine thevariable mix you need to reach your milestone. (In this example, the variablecells represent the numbers of cups of different types of coffee.) Your dialog boxshould look like this:

  • 8/13/2019 How to use Solver in MS Excel

    7/8

    4. Click the Solvebutton to find a solution to your forecasting problem. When theSolver has finished, click the OKbutton in the Solver Results dialog box.

    Figure 3 shows the solution the Solver generates if, before you ran the Solver, thevariable cells had contained the values that were generated in the previous exercise(namely, 150, 225, and 125). The new Solver results indicate that you can make $700 byselling 100 mochas, 175 lattes, and 100 regular coffees.

    Figure 3: When you specify a target goal, the Solver computes an optimum product mixthat meets your constraints.

    What if there is more than one solution to the problem?

    In the previous example, the Solver determined that you could sell 100 mochas, 175lattes, and 100 regular coffees to reach your sales goal of $700. But you can also reachthe $700 mark using a different product mix; for example, you could sell 94 regularcoffees, 151 lattes, and 125 mochas to reach $700. (Using this mix, your revenue would

    actually be $700.75.) So, how did the Solver decide what the optimum product mixwould be? The Solver simply started with the current numbers in the variable cells andadjusted them until it found an acceptable solution (subject to the constraints describedin the previous example). This is why, if you use different starting values in the variable

  • 8/13/2019 How to use Solver in MS Excel

    8/8

    cells before you run the Solver, you can get different results from a problem withmultiple solutions.

    What if Solver reaches its iteration limit without finding a solution?

    The starting values in the variable cells can affect the solution: Solver might fail to finda solution or it might time out before reaching a solution. Enter values in variable cellsthat fall close to what you believe the final values will be. If Solver still reaches itsiteration limit without arriving at a solution, you can adjust the starting values and restartor click Continue to use the maximum solution time. You can adjust both the maximumiterations and maximum time by using the Optionsbutton in the Solver Parametersdialog box.

    If you would like to use a particular product mix, you can take advantage of the way theSolver reaches its results. Enter the values that you think might be acceptable in thevariable cells before you run the Solver, and Excel will use those as starting values whenit computes the solution.