Profit Optimization and Price Modelling using Excel Solver Add in

Thursday, July 5, 2012

Profit Optimization and Price Modelling using Excel Solver Add in

Today, I tackle the problem of profit optimization using Microsoft Excel Solver add-in. I have been training professionals in Advanced Excel skills specifically using "What-If Analysis" and Solver in the past few months in Rwanda and Kenya. 


This post is optimized for Excel 2007 and 2010 - though it will work in Excel 2003 as well. 


Download the accompanying Excel Work book here
The Excel Solver Add-in


Excel's Solver is a numerical optimization add-in (an additional file that extends the capabilities of Excel).  It can be fast, easy, and accurate.  It is not, however, a 100 percent guaranteed silver bullet.  This document shows how to load and use Solver.  It concludes with two important caveats concerning Solver.

Organization:

            Accessing Excel’s Solver

            Reviewing the Solver Parameters Dialog Box

            Using Excel’s Solver: General Description

            Using Excel’s Solver: An Example (Profit Optimization.xls)

            Two Dangers of Numerical Optimization


Accessing Excel’s Solver


To use the Solver, click on the Data tab on the rib on to view the Solver tool on the right hand corner
 

If Solver is not listed you must manually include it in the algorithms that Excel has available.  To do this, click on the Office Button select Tools from the menu bar and choose the "Add-Ins . . ." item.  In the Add-Ins dialog box, scroll down and click on the Solver Add-In so that the box is checked as shown by the picture below:


After selecting the Solver Add-In and clicking on the OK button, Excel takes a moment to call in the Solver file and adds it to the Tools menu.

When you click on the Tools menu, it should be listed somewhere as shown above on the right.



If the Solver add-in is not listed in the Add-Ins dialog box, click on the Select or Browse button and navigate to the Solver add-in (called solver.xla in Windows and Solver on the MacOS) and open it.  It should be in the Library directory in the folders where Microsoft Office is installed.

If you cannot find the Solver Add-In, try using the Mac’s Find File or Find in Windows to locate the file.  Search for “solver.”  Note the location of the file, return to the Add-Ins dialog box (by executing Tools: Add-Ins…), click on Select or Browse, and open the Solver Add-In file.

What if you still cannot find it?  Then it is likely your installation of Excel failed to include the Solver Add-In.  Run your Excel or Office Setup again from the original CD-ROM and install the Solver Add-In.  You should now be able to use the Solver by clicking on the Tools heading on the menu bar and selecting the Solver item.

Although Solver is proprietary, you can download a trial version from Frontline Systems, the makers of Solver, at www.frontsys.com.

It is imperative that you successfully load and install the Solver add-in because without it, neither Solver nor the Dummy Dependent Variable Analysis add-in will be available.



Reviewing the Solver Parameters Dialog Box


After executing Tools: Solver . . . , you will be presented with the Solver Parameters dialog box below:



Let us review each part of this dialog box, one at a time.

Set Target Cell is where you indicate the objective function (or goal) to be optimized.   This cell must contain a formula that depends on one or more other cells (including at least one “changing cell”).  You can either type in the cell address or click on the desired cell. 

(NOTE: If you click on the Collapse Dialog button, , the dialog box disappears and it will be easier to select a cell.)

Equal to: gives you the option of treating the Target Cell in three alternative ways.  Max (the default) tells Excel to maximize the Target Cell and Min, to minimize it, whereas Value is used if you want to reach a certain particular value of the Target Cell by choosing a particular value of the endogenous variable.  If you choose Value, you must enter the particular value you want to attain in the box to the immediate right unless you want the value to be 0 (which is the default). 

Making the value equal to 0 enables Solver to find equilibrium solutions or roots to first-order conditions.

By Changing Cells permits you to indicate which cells are the adjustable cells (i.e., endogenous variables). As in the Set Target Cell box, you may either type in a cell address or click on a cell in the spreadsheet.  Excel handles multivariable optimization problems by allowing you to include additional cells in the By Changing Cells box. Each noncontiguous choice variable is separated by a comma. If you use the mouse technique (clicking on the cells), the comma separation is automatic.

Guess controls the initial position of the changing cells.  Excel uses the current values of the cells as the default.  Solver is sensitive to the initial values. If a solution cannot be found, try different starting values.

Subject to the Constraints is used to impose constraints on the endogenous variables.  We will rely on this important part of Solver when we do Constrained Optimization problems. 

You can also use the Constraints part of Solver to help it find a solution.  For example, in a profit maximization problem, you could tell Solver that Quantity must be greater than or equal to 0 (i.e., that negative values of Q are not allowed).  If Excel has trouble finding a solution to a problem, limiting the possible values of the choice variables will help it find a solution.  

Solver allows equality (Lagrange) or inequality (Kuhn-Tucker) constraints.  

Add..., Change..., Delete buttons are used to create and alter the constraints you set.  These buttons lead to dialog boxes on which you indicate your choices; then hit OK.

Returning to the top right-hand side of the Solver Parameters dialog box, we have the following:

Solve is obviously the button you click to get Excel's Solver to find a solution.  This is the last thing you do in the Solver Parameters dialog box.

Close is just like cancel; it closes the Solver dialog box, and no changes are made.

Options...allows you to adjust the way in which Solver approaches the solution.. 


As you can see, a series of choices are included in the Solver Options dialog box that direct Solver’s search for the optimum solution and for how long it will search.  These options may be changed if Solver is having difficulty finding the optimal solution.  Lowering the Precision, Tolerance, and Convergence values slows down the algorithm but may enable Solver to find a solution.

The Load and Save Model buttons enable you to recall and keep a complicated set of constraints or choices so that you do not have to reenter them every time.

Clicking OK or Cancel returns you to the Solver Parameters dialog box.
We continue our review of Solver options by going over the remaining buttons in the Solver Parameters dialog box (which we display again below):



Reset All.  This button changes everything back to the original, default choices, blanking out the Set Cell, By Changing Cells, and Subject to the Constraints options. 

It is important to understand that a saved Excel workbook will remember the information included in the last Solver run.  

If you wish to explore a different problem and want to begin with a “clean” Solver quickly, then click on the Reset All button.  If you wish to keep a particular Solver model, then use the Options and Save Model . . . Buttons.

Help brings up limited documentation on Solver.  Better help is available by typing “solver” in the Index of Help (which can be accessed by executing Help: Contents and Index)



Using Excel’s Solver: General Description


When you run Excel’s Solver, it executes a series of macros and routines that constitute the Solver add-in.  Upon completion of the various algorithms, Excel presents the user with a Solver Results dialog box:


A message appears on the top left-hand side of the box.  In this case, Excel reports that “Solver has converged to the current solution.  All constraints are satisfied.” This is good news! 

Bad news is a message like, “Solver could not find a solution.” If this happens, you must diagnose, debug, and otherwise think about what went wrong and how it could be fixed.  The two quickest fixes are to try different initial values and to add constraints to the problem.

From the Solver Results dialog box, you elect whether to have Excel write the solution it has found into the Changing Cells (i.e., Keep Solver Solution) or whether to leave the spreadsheet alone and NOT write the value of the solution into the Changing Cells (i.e., Restore Original Values).  When Excel reports a successful run, you would usually want it to Keep the Solver Solution. 

On the right-hand side of the Solver Results dialog box, Excel presents a series of reports.  The Answer, Sensitivity, and Limits reports are additional sheets inserted into the current workbook.  They contain diagnostic and other information and should be selected if Solver is having trouble finding a solution.

Along the bottom of the Solver Results dialog box are four buttons:

OK is obviously the button you click after reading and choosing various options you want to keep.  This is the last thing you do in the Solver Results dialog box.

Cancel closes the Solver Results dialog box and no changes are made.

Save Scenario... enables the user to save particular solutions for given configurations.

Help brings up information from Excel’s Help application.




Using Excel’s Solver: An Example


You can see Solver in action by opening the file Profit Optimization.xls.  The OptimalSolution sheet has a simple profit-maximization problem set up, and Solver is ready to run.  Execute Tools: Solver to access the Solver Parameters dialog box shown below.

Click the Solve button and Excel converges on the optimal solution.


Two Dangers of Numerical Optimization

This may be the first time you have used a numerical algorithm to solve an optimization problem.  Although a full explanation of numerical methods for optimization is beyond the scope of this simple introduction, two basic ideas deserve mention.

1) Interpretation of Solver’s Results Needed

Solver determines if it has reached a solution by using a convergence criterion.  Once it cannot improve the current solution by more than 0.0001 (the default convergence value in the Options dialog box), it announces that it has found a solution and reports its value in 16-bit precision.  The reported solution might be a number like 2.99999999999999.

An important consequence of the convergence criterion is that Solver will often not get a truly exact answer.  Once it is close enough to meet the convergence criterion, it stops improving.  Usually, that is not a problem because we do not need the absolutely exact answer. 

Unfortunately, some people seem to think that an answer to the fifteenth decimal place is really exact.  That is crazy.  Most of the time, Solver will stop short of the absolutely exact answer.  Thus, there is no point in using all of the digits presented by Solver. 

You should always format Solver result cells so that they are easy for humans to read and understand.  If you get a Solver result like the one above, you should display it as 3.  In general, you will want to cut down on the many digits Solver displays.

2) Solver May Fail

A bigger problem concerns the ability of Solver (or any numerical algorithm) to find the correct solution.  In “The Numerical Reliability of Econometric Software” (Journal of Economic Literature, June 1999, pp. 633–665), McCullough and Vinod draw a distinction between a miserable and a disastrous result.  They might sound the same, but they are quite different. 

A miserable result is obtained when a numerical algorithm gives up and says that a solution cannot be found, an error occurred, or convergence could not be achieved.  The result is miserable because the computer cannot find the answer.  If this happens to you, we recommend changing the initial values from which Solver began its work.  Avoid extremely large or small numbers and 0 as initial values.  Another simple strategy is to add constraints to reduce the search area or to reformulate the problem (for instance by focusing on the first order conditions).  A large literature exists on ways to improve the performance of numerical algorithms – especially in the realm of nonlinear problems.

A disastrous result is much worse than a miserable one.  Solver happily announces that a solution has been found and offers up a 15- or 16-digit number for your inspection.  The problem, however, is that the solution is way off – not in the millionth or even tenth decimal place, but completely, totally wrong.  How this might happen takes us too far afield, but suffice it to say that it is good Solver practice always to check the solution by trying slightly different numbers to test Solver’s answer and by asking yourself if the answer makes sense. 

Solver really is a powerful way to solve optimization problems, but it is not perfect.  You need to be aware of this.  Remember always to format Solver’s results with an eye toward ease of understanding.  Do not give up if you get a miserable result, and stay alert even if Solver claims to have hit pay dirt—it may be a disastrous result!

When combined with the Dummy Dependent Variable Analysis add-in, Solver provides a fast, easy way to do Probit and Logit. 

----------------------------------------
Require training? We are the leaders of Advanced Excel Training for Professionals throughout East and Central Africa. Our training in Kenya, Uganda, Tanzania, Rwanda and Burundi take as little as one day and targets both onsite and offsite trainings.
Book your training today: Email me  or visit my training site

David Kandie is the lead trainer and consultant at OpenCastLabs Consulting in Kenya and Rwanda.

0 comments: