Design and Use of the Microsoft Excel Solver
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
Design and Use of the Microsoft Excel Solver Daniel Fylstra Frontline Systems Inc., PO Box 4288, Incline Village, Nevada 89450 Leon Lasdon Department of Management Science and Information Systems, College of Business Administration, University of Texas, Austin, Texas 78712 John Watson Software Engines, 725 Magnolia Street, Menlo Park, California 94025 Allan Waren Computer and Information Science Department, Cleveland State University, Cleveland, Ohio 44115 In designing the spreadsheet optimizer that is bundled with Microsoft Excel, we and Microsoft made certain choices in de- signing its user interface, model processing, and solution algo- rithms for linear, nonlinear, and integer programs. We describe some of the common pitfalls users encounter and remedies available in the latest version of Microsoft Excel. The Solver has many applications and great impact in industry and education. S ince its introduction in February 1991, the Microsoft Excel Solver has become the most widely distributed and almost based on the same technology used in the Excel Solver. This widespread availability has surely the most widely used general- spawned many applications in industry purpose optimization modeling system. and government. In education, increasing Bundled with every copy of Microsoft Ex- numbers of MBA and undergraduate busi- cel and Microsoft Office shipped during ness instructors have adopted the Excel the last eight years, the Excel Solver is in Solver as their tool for introducing stu- the hands of 80 to 90 percent of the 35 mil- dents to optimization: most management lion users of office-productivity software science textbooks now include coverage of worldwide. The remaining 10 to 20 per- the Excel Solver, and several recent texts cent of this audience use either Lotus use it exclusively in the optimization 1-2-3 or Quattro Pro, both of which now chapters. include very similar spreadsheet solvers, We review the background and design Copyright q 1998, Institute for Operations Research COMPUTERS/COMPUTER SCIENCE—SOFTWARE and the Management Sciences 0092-2102/98/2805/0029/$5.00 This paper was refereed. INTERFACES 28: 5 September–October 1998 (pp. 29–55)
FYLSTRA ET AL. philosophy of the Excel Solver. We seek to quired by the optimizers in much the explain why the Excel Solver works the same way that GAMS and AMPL do. way it does, to clear up some common The optimizers employ the simplex, misunderstandings and pitfalls, and to generalized-reduced-gradient, and branch- suggest ideas for good modeling practice and-bound methods to find an optimal so- when using spreadsheet optimization. We lution and sensitivity information. The also briefly survey applications of the Solver uses the solution values to update Excel Solver in industry and education the model spreadsheet and provides sensi- and describe how practitioners who are tivity and other summary information on not affiliated with the OR/MS community additional report spreadsheets. use it. The example models in this paper Background and Design Philosophy are available on Practice Online at of the Excel Solver (http://silmaril.smeal.psu.edu/pol.html) The Microsoft Excel Solver and its coun- and at http://www.frontsys.com/ terparts in Lotus 1-2-3 97 and Corel Quat- interfaces.htm. Much more information— tro Pro were not the first spreadsheet op- over 200 web pages at this writing—is timizers; that distinction belongs to What’s available on Frontline Systems’ World Best!, conceived by Sam Savage, Linus Wide Web site (http://www.frontsys.com). Schrage, and Kevin Cunningham in 1985 The Microsoft Excel Solver combines the and marketed by General Optimization functions of a graphical user interface Inc. for the Lotus 1-2-3 Release 2 spread- (GUI), an algebraic modeling language sheet [Savage 1985]. What’sBest! is still like GAMS [Brooke, Kendrick, and available in versions for each of the major Meeraus 1992] or AMPL [Fourer, Gay, and spreadsheets and is now sold and sup- Kernighan 1993], and optimizers for linear, ported by Lindo Systems Inc. Other early nonlinear, and integer programs. Each of spreadsheet optimizers included Frontline these functions is integrated into the host Systems’ What-If Solver [Frontline Sys- spreadsheet program as closely as possi- tems 1990], Enfin Software’s Optimal Solu- ble. Many of the decisions we and Micro- tions [Enfin Software 1988], and Lotus soft made in designing the Solver were Development’s Solver in earlier versions motivated by this goal of seamless of 1-2-3 [Lotus Development 1990]. integration. The design approach of What-If Solver, Optimization in Microsoft Excel begins implemented in the graphical user inter- with an ordinary spreadsheet model. The face of Excel, was chosen by Microsoft spreadsheet’s formula language functions over several alternatives including as the algebraic language used to define What’sBest!; by Borland (the original de- the model. Through the Solver’s GUI, the velopers of Quattro Pro) over an earlier user specifies an objective and constraints solver developed internally by that com- by pointing and clicking with a mouse pany; and later by Lotus over their own and filling in dialog boxes. The Solver internally developed solver. A major rea- then analyzes the complete optimization son for this outcome, we believe, is that model and produces the matrix form re- the Excel Solver had as its design goal INTERFACES 28:5 30
MICROSOFT EXCEL SOLVER “making optimization a feature of spread- cel—rather than traditional OR/MS pro- sheets,” whereas other packages, such as fessionals. An example is the terminology What’sBest!, “use the spreadsheet to do it uses in dialog boxes, such as “Target optimization.” In many small ways, the Cell” (for the objective) and “Changing Excel Solver caters to the tens of millions Cells” (for the decision variables). We used of spreadsheet users, rather than to the these terms—at Microsoft’s request—to tens of thousands of OR/MS professionals. mirror the terms used in the Goal Seek Although OR/MS professionals readily feature, which predated the Solver in learn to use the Excel Solver, they often Excel and in other spreadsheet programs. find certain aspects of its design puzzling The Goal Seek feature, which spreadsheet or at least different from their expecta- users often describe as “what-if in re- tions. In most cases, the differences are verse,” solves a nonlinear function of one due to (1) the architecture of spreadsheet variable for a specified value. Spreadsheet programs, (2) the expectations of the ma- users see the Excel Solver as a more pow- jority of spreadsheet users who are not erful successor to the Goal Seek feature OR/MS professionals, or (3) the desires of [Person 1997]. Figure 1 shows Excel’s Goal the spreadsheet vendors (Microsoft in the Seek dialog box, and Figure 2 shows the case of the Excel Solver). Solver Parameters dialog box with its The Architecture of Spreadsheet similar terminology. Programs The Desires of the Spreadsheet Vendors Because of the architecture of spread- The influence of the spreadsheet ven- sheet programs, it is easy to create spread- dors’ desires is reflected in the way the sheet models that contain discontinuous Solver determines whether the model is functions or even nonnumeric values. linear or nonlinear. By default, the Solver These models usually cannot be solved assumes that the model is nonlinear. The with classical optimization methods. The user must select the Assume Linear Model spreadsheet’s formula language is de- check box in the Solver Options dialog box signed for general computations and not just for optimization. Indeed, Excel sup- ports a rich variety of operators and sev- eral hundred built-in functions, as well as user-written functions. In contrast, GAMS, AMPL, and similar modeling languages include only a small set of operators and functions sufficient for expressing linear, smooth nonlinear, and integer optimiza- tion models. The Expectations of Spreadsheet Users Figure 1: The Goal Seek feature of Microsoft Excel predated the Solver. This feature uses The Excel Solver was designed to meet iterative methods to solve a simple equation the expectations of spreadsheet users—in (formula in the “set cell” equal to the “value”) particular, users of earlier versions of Ex- in one variable (the “changing cell”). September–October 1998 31
FYLSTRA ET AL. Figure 2: The Solver Parameters dialog is used to define the optimization model. The terms “Set Target Cell” (for the objective) and “Changing Cells” (for the variables) and the “Value of” option were derived from the earlier Goal Seek feature. to override this assumption; the Solver products, such as What’sBest! Personal does not attempt to automatically deter- Edition, represent the low end of the range mine whether the model is linear by in- of spreadsheet solver functionality, capac- specting the formulas making up the ity, and performance. More powerful ver- model. Most of Excel’s several hundred sions are available and these versions are built-in functions and all user-written most often used to solve problems in in- functions would have to be treated as “not dustry. For example, where the standard linear” (smooth nonlinear or discontinu- Excel Solver supports just 200 decision ous over their full domains) in an auto- variables, Frontline Systems’ Large-Scale matic test. But users sometimes create LP Solver (a component of the Premium models using these functions and then Solver Platform) supports up to 16,000 add constraints that result in a linear variables, and Lindo Systems’ What’sBest! model over the feasible region. Microsoft Extended Edition supports up to 32,000 wanted a general approach that would variables. Table 1 summarizes the charac- support such cases and specified the use teristics of the Premium Solver products of the check box, as well as the use of the offered by Frontline Systems. nonlinear solver as the default choice. Like most optimization software, the The Role of Bundled Spreadsheet Excel Solver has steadily improved in per- Solvers formance over the years. Although solu- The “free” bundled version of the Excel tion times are model dependent, in overall Solver described in this paper and similar terms, the Solver in Excel 97 offers about INTERFACES 28:5 32
MICROSOFT EXCEL SOLVER Premium Excel Built-In Premium Solver Premium Solver Solver Solver Plus Platform NLP variables/ 200/100 ` 400/200 ` 400/200 ` 1000/1000 ` bounds constraints bounds bounds bounds LP variables/ 200/ 800/unlimited 800/unlimited 2000/unlimited to constraints unlimited 16,000/unlimited Setup 1x 1–50x 1–50x 1–50x performance NLP 1x 1x 1.5x 2–10x performance LP performance 1x 2–3x 2–3x Large scale MIP performance 1x 5–10x 25–50x 25–50x Selection of Fixed set Fixed set Fixed set Multiple choices, field- optimizers installable LP/QP methods Simplex Enhanced Enhanced Sparse simplex, LU, w/bounds simplex simplex, Markowitz w/bounds dual, quadratic MIP methods B&B Enhanced B&B Enhanced Enhanced B&B, P&P, B&B, P&P, dual, simplex dual, simplex NLP methods GRG2 GRG2 Enhanced LSGRG, SQP, etc. GRG2 Reports Standard: Standard ` Standard ` Standard ` Linearity, Answer, Linearity, Linearity, Feasibility Limits, Feasibility Feasibility Sensitivity Table 1: The characteristics of the enhanced Excel Solvers are summarized in this table. For in- teger problems, “B&B” refers to branch and bound and “P&P” refers to preprocessing and probing. For nonlinear problems, “GRG” refers to the generalized reduced gradient method and “SQP” refers to sequential quadratic programming. five times the performance of that in Excel real-world optimization problems. 5.0 and perhaps 20 times the performance User Interface and Selection of the earliest version in Excel 3.0 (assum- of Objectives, Decision Variables, ing a constant hardware platform). The and Constraints Premium Solver further improves mixed- In the Excel Solver, as in an algebraic integer problem solution times by a factor modeling system, the optimization model of 25 to 50 over the Excel 97 Solver is defined by algebraic formulas (which (Table 1). While spreadsheet solvers are appear in spreadsheet cells). Excel’s for- unlikely to compete with dedicated optim- mula language can express a wide range izers, such as CPLEX and OSL, they do of mathematical relationships, but Excel provide a practical platform for solving has no facilities for distinguishing decision September–October 1998 33
FYLSTRA ET AL. variables from other variables or objectives usually guesses wrong” and advising stu- or constraints from other formulas. Hence, dents not to use it, but many spreadsheet the Excel Solver provides both interactive users find it useful. When one presses the and user-programmable ways to specify Guess button, the Solver places a selection which spreadsheet cells are to serve each in the By Changing Cells edit box that in- of these roles. cludes all input (nonformula) cells on In interactive use, the user selects Tools which the objective formula depends. This Solver . . . from the Excel menu bar, dis- selection will usually include the actual playing the Solver Parameters dialog box decision variables as a subset and may be (Figure 2). As noted earlier, this dialog box edited to remove ranges of cells that are is patterned after the Goal Seek feature not decision variables (for example, those (Figure 1). The “Value of” option offers a that are fixed parameters in the model). way to directly solve goal-seeking prob- Constraints lems using the Solver; when the user se- The key issue in a spreadsheet solver’s lects this option and enters a target value, user interface is the method of specifying an equality constraint is added to the opti- constraints. What’sBest! originally used a mization model, and there is no objective “Rule of Constraints” that required every to be maximized or minimized. (Alterna- formula cell dependent on the variables to tively, one may simply leave the Set Target be nonnegative—but this form was not in- Cell edit box blank and enter an equality tuitive for typical spreadsheet users and constraint in the Constraint list box.) In was not acceptable to the spreadsheet ven- either case, the problem is solved with a dors. (More recent versions of What’sBest! (constant) dummy objective, and the use a new constraint representation.) In Solver stops when the first feasible solu- the earlier Lotus-developed solver for tion is found. In this way, the Excel Solver 1-2-3, Lotus used logical expressions in the fulfills spreadsheet users’ expectations of a spreadsheet’s formula language, including more powerful Goal Seek capability that the relational operators ,4, 4, and .4, can be used to find solutions for systems to represent constraints. The solver dialog of equations and inequalities. box simply offered an edit box in which a Decision Variables and the Guess Button range of cells containing such logical for- Model decision variables are entered in mulas could be entered—thereby taking the By Changing Cells edit box. Excel al- full advantage of an existing spreadsheet lows one to enter a so-called multiple se- feature. lection, which consists of up to 16 ranges In the Excel Solver, in consultation with (rectangles, rows or columns, or single Microsoft, we chose a different way of cells) separated by commas. Alternatively, specifying constraints, for several reasons. one may press the Guess button to obtain First, spreadsheet logical formulas (expres- an initial entry in the By Changing Cells sions that evaluate to TRUE or FALSE in edit box. This feature often puzzles Excel, or 1 or 0 in Lotus 1-2-3) are more OR/MS professionals; Ragsdale [1997] in- general than constraints. They allow such cludes a sidebar saying that the “Solver relations as ,, ., and ,. (not equal), INTERFACES 28:5 34
MICROSOFT EXCEL SOLVER which are not easily handled by current constraints by clicking the corresponding optimization methods, as well as such log- buttons. ical operators as AND, OR, and NOT. Sec- In accord with the GUI conventions ond, relations such as A1 . 4 0, are eval- used throughout Excel, one can select uated by the spreadsheet as strictly blocks of cells for decision variables and satisfied or unsatisfied, whereas an optimi- for left-hand sides and right-hand sides of zation algorithm evaluates constraints constraints by typing coordinates or by within a tolerance. For example, if A1 4 clicking and dragging with the mouse. 10.0000005, the Excel Solver would treat The latter method is far more often used. A1 .4 0 as satisfied (using the default Excel also allows the user to define sym- Precision setting of 1016 or 0.000001), but bolic names for individual cells or ranges the logical formula 4 A1 .4 0 in a cell of cells (through the Insert Name menu would display as FALSE. Third, con- option). The Excel Solver will recognize straints almost always come in blocks or any names the user has defined for the ob- indexed sets, such as A1:A10 .4 0, and it jective, variables, and blocks of constraints is very advantageous for users to be able and will display them in the Solver Pa- to enter such constraints and later view rameters dialog box (Figure 3). and edit them in block form. Hence, the For those who prefer to use spreadsheet Excel Solver provides a Constraint list box logical formulas for constraints, the Excel in the Solver Parameters dialog box where Solver will read and write constraints in users can add, change, or delete blocks of this form, when the Load Model and Save Figure 3: Excel users can define symbolic names for single cells or ranges of cells, which the Solver will use. This dialog depicts the same model as in Figure 2 with the aid of defined names, resulting in a much more readable model. September–October 1998 35
FYLSTRA ET AL. Model buttons in the Solver Options dia- rithm will be used to solve the problem. log box are used. The Use Automatic Scaling check box Solver Options causes the model to be rescaled internally The user can control several options and before solution. The Assume Non- tolerances used by the optimizers through Negative check box places lower bounds the Solver Options dialog box (Figure 4). of zero on any decision variables that do In the standard Excel Solver, all such op- not have explicit bounds in the Con- tions appear in one dialog box; in the Pre- straints list box. mium Solver products, where many more The Precision edit box is used by all of options and tolerances are available, each the optimizers and indicates the tolerance optimizer has a separate dialog box. within which constraints are considered The Max Time and the Iterations edit binding and variables are considered inte- boxes control the Solver’s running time. gral in mixed-integer-programming (MIP) The Show Iteration Results check box in- problems. The Tolerance edit box (a some- structs the Solver to pause after each ma- what unfortunate name, but Microsoft’s jor iteration and display the current “trial choice) is the integer optimality or MIP- solution” on the spreadsheet. In lieu of gap tolerance used in the branch-and- these options, however, the user can sim- bound method. The GRG2 algorithm uses ply press the ESC key at any time to the Convergence edit box and Estimates, interrupt the Solver, inspect the current it- Derivatives, and Search option button erate, and decide whether to continue or groups. to stop. Modeling Practice The Assume Linear Model check box Excel, including the Solver, offers many determines whether the simplex method convenient ways to select and manipulate or the GRG2 nonlinear programming algo- blocks of cells for variables and con- straints. Modelers should take advantage of this feature by laying out optimization models with indexed sets (for example, products, regions, or time periods) along the columns and rows of tables or blocks of cells. We also highly recommend the practice of defining names for indexed sets of variables and constraints and even for single cells. For example, the structure of the model with names defined as shown in Figure 3 is far more easily grasped than the same model with cell coordinate ranges as shown in Figure 2. Blocks of Figure 4: The Solver Options dialog box is constraint values can often be computed used to select algorithmic options and to set tolerances for the Excel Solver’s solution more easily with Excel’s array of formulas, methods. which provide some of the high-level fea- INTERFACES 28:5 36
MICROSOFT EXCEL SOLVER tures of algebraic modeling languages, spect to the decision variables. In LP prob- though without all of the flexibility of lems, the matrix entries are constant and such languages. need to be evaluated only once at the start For further suggestions on modeling of the optimization. In nonlinear program- practice for spreadsheet optimization, we ming (NLP) problems, the Jacobian matrix encourage readers to consult Conway and entries are variable and must be recom- Ragsdale [1997]. puted at each new trial point. User Programmability The Jacobian matrix could be obtained The user-programmable interface of- either analytically by symbolic differentia- fered by the Excel Solver—a feature rarely tion of the spreadsheet formulas [Ng and found in other optimization modeling sys- Char 1979]; or during function evaluation tems—is critically important to the many through so-called automatic differentiation commercial users who are using Excel and methods [Griewank and Corliss 1991]; or Microsoft Office as a platform for develop- it could be approximated by finite differ- ing custom applications. Every interactive, ences [Gill, Murray, and Wright 1981]. This GUI-based action supported by the Excel choice is a major design decision in any Solver has a counterpart function call in optimization modeling system, with many Visual Basic for Applications (VBA), Ex- trade-offs. What’sBest! can be regarded as cel’s built-in programming language. (The using the symbolic algebraic approach; earlier Excel macro language is also sup- systems such as GAMS and AMPI use au- ported for backward compatibility.) All tomatic differentiation; and the Excel components of Excel share this feature, Solver uses finite differences. making it a flexible platform for decision The most important reason for choosing support applications. For example, the the finite difference approach for the Excel new marketing textbook [Lilien and Solver was the requirement, set by Micro- Rangaswamy 1997] includes a number of soft, that it support all of Excel’s built-in Excel Solver models that are controlled by functions as well as user-written functions. VBA programs. Symbolic differentiation would have been Model Extraction and Evaluation of the difficult for many of Excel’s several hun- Jacobian Matrix dred functions (and in fact, What’sBest! re- Like an algebraic modeling system such jects most of them) and impossible for user- as GAMS or AMPL, the Excel Solver ex- written functions. To use automatic tracts the optimization problem from the differentiation we would have had to mod- spreadsheet formulas and builds a repre- ify the Excel recalculator and require user- sentation of the model suitable for an op- written functions (often coded in other lan- timizer. For a linear programming (LP) guages) to supply both function and problem, the focus of this model represen- derivative values, neither of which was tation is the LP coefficient matrix. In more possible. On the other hand, finite general terms, this is the Jacobian matrix differences could be efficiently calculated of partial derivatives of the problem func- using the finely tuned Excel recalculator tions (objective and constraints) with re- as is. September–October 1998 37
FYLSTRA ET AL. The Solver is concerned only with those compute parameters of the model that do formulas that relate the objective and con- not depend on the decision variables, even straints to the decision variables; it treats if the optimization model is an LP. Indeed, all other formulas on the spreadsheet as it is often convenient to use IF, CHOOSE, constant in the optimization problem. Ex- and table LOOKUP functions in calculat- cel, 1-2-3, and Quattro Pro all implement a ing parameters, and we frequently see form of minimal recalculation in which these functions in models created by com- only those formulas that are dependent on mercial users of Frontline Systems’ Pre- the cell values that have changed need to mium Solver products. be recalculated. Computing finite differences does, how- In calculating finite differences, the ever, take time to recalculate the spread- [i,j]th element of the Jacobian matrix is ap- sheet. Bearing in mind that Excel will re- proximated by the formula calculate every formula on the current worksheet that depends on the decision fi (x ` d ej) 1 fi (x) where d 4 eps |1 4 xj|. variables—even those not involved in the d optimization model—modelers can mini- In this formula, ej is the jth unit vector and mize this time by keeping auxiliary calcu- eps is a perturbation factor, typically 1018 lations on a separate worksheet. Because approximately equal to the square root of of the significant overhead in recalculating the machine precision [Gill, Murray, and multiple worksheets, the Excel Solver cur- Wright 1981]. After an initial recalculation rently requires that cells for the decision to evaluate f(x), the Solver perturbs each variables, the objective, and the left-hand variable in turn, recalculates the spread- sides of constraints appear on the active sheet, and obtains values for the jth col- sheet, although model formulas and right- umn of the Jacobian matrix. Hence the hand sides of constraints can refer to other process requires n ` 1 recalculations for sheets. an n variable problem; each recalculation For users with models that take a long after the first perturbs just one variable time to recalculate, we strongly recom- and resets another, thereby taking advan- mend an upgrade to Excel 97, the latest tage of the spreadsheet’s minimal recalcu- version of Excel at this writing. Recalcula- lation feature. tion performance is greatly improved in Modeling Practice this version, and the Solver is correspond- The use of finite differences in the Excel ingly faster on the majority of models. Solver has a number of implications for Frontline Systems’ Premium Solver prod- spreadsheet modelers. The Solver’s model ucts offer additional ways to speed up processing allows users to employ any of evaluation of the Jacobian matrix (Table 1), Excel’s several hundred built-in functions, and we plan further improvements in this as well as user-written functions, in con- area. structing the spreadsheet. While many of Solving Linear Problems these functions have nonlinear or non- When a user checks the Assume Linear smooth values, they can be used freely to Model box (Figure 4) the Excel Solver uses INTERFACES 28:5 38
MICROSOFT EXCEL SOLVER a straightforward implementation of the ear solver in Excel 4.0, we added the Use simplex method with bounded variables Automatic Scaling check box to the Solver to find the optimal solution. This code op- Options dialog box. But this dug a deeper erates directly on the LP coefficient matrix pitfall for users with linear problems, since (that is, the Jacobian), which is determined this automatic scaling option had no effect using finite differences. The standard Excel on the linear solver—and users often over- Solver stores the full matrix, including looked the documentation of this fact in zero entries; however, no matrix rows are Excel’s online Help. required for simple variable bounds. In Excel 97, the Use Automatic Scaling Frontline Systems’ Large-Scale LP Solver box applies to both linear and nonlinear (Table 1) relies on a sparse representation problems. If the user checks this box and of the matrix and of the LU factorization the Assume Linear Model box, the Solver of the basis with dynamic Markowitz re- rescales columns, rows, and right-hand factorization, yielding better memory us- sides to a common magnitude before be- age and improved numerical stability on ginning the simplex method. It unscales large-scale problems. the solution values before storing them Automatic Scaling and Related Pitfalls into cells on the spreadsheet. With this en- Earlier versions of the standard Excel hancement, the simplex solver is able to Solver had no provision for automatic handle most poorly scaled models without scaling of the coefficient matrix; they used any extra effort by the user. values directly from the user’s spread- Linearity Test and Related Pitfalls sheet. Since it is easy to rescale the objec- For the reasons outlined earlier, the Ex- tive and constraint values on the spread- cel Solver asks the user to specify whether sheet itself, we did not think that the model is linear, but it does perform a automatic scaling would be needed, espe- simple numerical test to check the linearity cially for linear problems. We were wrong. assumption for reasonableness. This li- Over the years, we have received many nearity test gave rise to another pitfall, spreadsheet models from users—including again for poorly scaled models. Prior to business school instructors—that did not Excel 97, the Solver performed this test af- seem to solve correctly. In virtually all of ter it had obtained a solution using the these cases, the model was very poorly simplex method. It used these solution scaled—for example, with dollar amounts values x* and the initial values x0 for the in millions for some constraints and return variables to check that the objective and figures in percentages for others—yet none each constraint function fi (x), evaluated by of these users identified scaling as a prob- recalculating the spreadsheet, satisfied the lem. It seems that in the widespread move following condition: to emphasize modeling over algorithms, |fi (x*) 1 (fi (x0) ` ¹fi (x0)(x* 1 x0))| # tol. such issues as scaling (still important in using software) have been de-emphasized Here ¹fi (x0) is the function gradient, that or forgotten. is, the appropriate row of the LP coeffi- To improve performance of the nonlin- cient matrix, and tol is the Precision value September–October 1998 39
FYLSTRA ET AL. in the Solver Options dialog box with a the spreadsheet at the optimal point, default value of 1016. match the values provided by the LP solu- Given that the model might contain any tion within the Precision value in the of the hundreds of Excel built-in functions Solver Options dialog. As long as the user as well as user-written functions and that selects the Use Automatic Scaling box, so the test is performed at discrete points, that the values in the LP matrix are well this test cannot be perfect; very occasion- scaled internally, this test should be robust ally, a model with nonlinear, or even dis- even for poorly scaled models. continuous functions, will pass the linear- Modeling Practice ity test. In practice, however, this linearity Students (and instructors) who use Ex- test almost always detects situations in cel 97, with its automatic scaling and its which the user has accidentally set up a improved linearity test, can avoid the pit- model that doesn’t satisfy the linearity as- falls described earlier. We strongly encour- sumption—and truly linear models will age business school instructors to upgrade always pass the linearity test, as long as to Excel 97 as soon as possible. Schools they are well scaled. still using Windows 3.1 can obtain an aca- Unfortunately, linear models that are demic version of Frontline Systems’ Pre- poorly scaled will sometimes fail this test. mium Solver for Excel 5.0 with the same Since the resulting error message is “The enhancements, but support for this 16-bit conditions for Assume Linear Model are version will be limited in the future. Still, not satisfied,” the user who is not con- we emphasize that, while we have used scious of the effect of poor scaling may not scaling methods favored in the literature realize that this is the problem. (The only [Gill, Murray, and Wright 1981], no auto- saving grace is that very poorly scaled matic scaling method is perfect. It will al- models, which might otherwise yield in- ways be possible to create examples that correct answers in the absence of auto- cause problems in spite of automatic scal- matic scaling, almost always give this er- ing, and we suggest that instructors de- ror message instead.) vote at least some time to explaining the In Excel 97, we have substantially re- limitations of finite precision computer vised the linearity test. The Solver per- arithmetic to students. Ragsdale [1997] ad- forms a quick check before solving the dresses scaling briefly but effectively, for problem by verifying that the problem instance. The example model in Figure 5, functions, evaluated at several multiples of which is available for download on Prac- the initial variable values, satisfy the tice Online, is a poorly scaled variant of above condition. If the problem fails this the Working Capital Management work- test, the user is warned against using the sheet distributed with Excel. It will yield a simplex method. When the Solver finds an nonoptimal solution (of all zeroes) in Excel optimal solution using the simplex 5.0 and 7.0 and in Excel 97 if the Use Au- method it performs a further check. It ver- tomatic Scaling box is cleared. It yields the ifies that the objective function and con- correct solution in Excel 97 if the user straint slacks, obtained by recalculating checks the Use Automatic Scaling box. INTERFACES 28:5 40
MICROSOFT EXCEL SOLVER Figure 5: This spreadsheet, which can be downloaded from Practice Online as FIGURE5.XLS, is a poorly scaled model that “fools” the linearity test in earlier Excel versions, yielding the mes- sage “The conditions for Assume Linear Model are not satisfied.” Solving Nonlinear Problems differences as described earlier and re- When the Assume Linear Model box in evaluates it at the start of each major the Solver Options dialog is cleared, the iteration. Excel Solver uses the generalized reduced Automatic Scaling gradient method, as implemented in the A poorly scaled model can cause even GRG2 code [Lasdon et al. 1978], to solve more problems for GRG2 than for the sim- the problem. Like other gradient-based plex method. The earliest version of the methods, GRG2 is guaranteed to find a lo- Excel Solver used variable and constraint cal optimum only on problems with con- values directly from the spreadsheet, but tinuously differentiable functions and then as of Excel 4.0 (released in 1992), the only in the absence of numerical difficul- Solver rescales both variable and function ties (such as degeneracy or ill condition- values internally if the user checks the Use ing). However, GRG2 has a reputation for Automatic Scaling box in the Solver Op- robustness, compared with other nonlinear tions dialog box. Unlike the simplex code, optimization methods, on difficult prob- which uses gradient values for scaling (as lems where these conditions are not fully of Excel 97), the GRG2 algorithm in Excel satisfied. uses typical-value scaling. In this approach Problem Representation GRG2 rescales the decision variables and GRG2 requires function values and the problem functions by dividing by their ini- Jacobian matrix (which is not constant for tial values at the beginning of the solution nonlinear models). The Excel Solver ap- process. (We chose this approach because proximates the Jacobian matrix using finite our tests showed that gradient-based scal- September–October 1998 41
FYLSTRA ET AL. ing was not very effective on typical non- the feasibility tolerance (Precision option), linear spreadsheet models where scaling decreasing the convergence tolerance to was a problem.) make it more difficult to terminate in GRG2 Stopping Conditions phase one, trying central differences, and Like the simplex method, the GRG2 al- trying other starting points. gorithm will stop when it finds an optimal Nonsmooth Functions solution, when the objective appears to be The convergence results for gradient- unbounded, when it can find no feasible based methods, such as GRG2, depend on solution, or when it reaches the time limit differentiability of the problem functions. or maximum number of iterations. For The spreadsheet formula language is de- nonlinear models, an “optimal solution” signed to express arbitrary calculations, means that the Solver has found a local and users can easily create optimization optimum where the Kuhn-Tucker condi- models that include nonsmooth functions, tions are satisfied to within the conver- that is, functions with discontinuous val- gence tolerance; the message displayed is ues or first partial derivatives at one or “Solver found a solution.” GRG2 also more points. Examples of such functions stops when the current solution meets a are ABS, MIN and MAX, INT and “slow progress” test: The relative change ROUND, CEILING and FLOOR, and the in the objective is less than the conver- commonly used IF, CHOOSE, and gence tolerance for the last five iterations. LOOKUP functions. Expressions involving In this case, the message displayed is relations (outside the context of Solver- “Solver converged to the current solu- recognized constraints) and such Boolean tion.” In previous Excel versions, the con- operators as AND, OR, and NOT are dis- vergence tolerance was fixed at 1014 or continuous at their points of transition be- 1015 (depending on the version) and tween FALSE and TRUE values. could not be changed by the user. In Excel The presence of any of these (or many 97, there is new Convergence edit box other) functions in a spreadsheet does not (Figure 4) that sets this tolerance. necessarily mean that the optimization The message “Solver could not find a model is nonsmooth. For example, an IF feasible solution” occurs when the GRG2 function whose conditional expression is algorithm terminates with a positive sum independent of the decision variables and of infeasibilities. This almost always indi- whose result expressions are smooth is it- cates a truly infeasible model, but with self smooth. Similar statements apply to nonlinear problems this can occur (rarely) the other functions mentioned above. in feasible problems if GRG2 finds a local Even if the problem is nonsmooth, optimum of the phase one objective (the GRG2 may never encounter a point of dis- sum of the infeasibilities) or if GRG2 sim- continuity. This depends on the path that ply terminates in phase one due to slow the algorithm takes, which depends on the progress. Remedies available through the starting point. GRG2 may simply skip Solver Options dialog box (Figure 4) in- over a discontinuity or may never encoun- clude using automatic scaling, increasing ter a region where discontinuities occur. INTERFACES 28:5 42
MICROSOFT EXCEL SOLVER Problems occur when the finite difference factors it uses depend on the initial values process (which approximates partial deriv- of the variables. Users should take care to atives) spans both sides of a discontinuity, start the solution process with values for for then the estimated derivatives are the variable cells that are representative of likely to be very large. If GRG2 is converg- the values expected at the optimal solu- ing to a local solution where the objective tion, rather than with arbitrary values, is nonsmooth, inaccurate derivative esti- such as all zeroes. The example spread- mates near the solution are likely to cause sheet in Figure 6, which is available for it to oscillate about that point and to ter- download on Practice Online, is an Excel minate because of a small fractional version of a product-mix and pricing change in the objective. model from Fylstra [1992]. If the model is Modeling Practice solved with initial values of zero for all The path GRG2 takes and the scaling four variables, GRG2 stops immediately, Figure 6: This spreadsheet, which can be downloaded from Practice Online as FIGURE6.XLS, causes the GRG2 nonlinear solver to stop at a nonoptimal solution if the initial values of all variables are zero. GRG2 finds the correct optimal solution for initial variable values that make the profits per unit positive. September–October 1998 43
FYLSTRA ET AL. declaring this point to be an “optimal so- Figure 7, also available for download on lution” (in fact, this point is a Kuhn- Practice Online, is a variant of the Quick Tucker point). With initial values that Tour worksheet distributed with Excel. If make each quantity to build and the profit this model is solved in Excel 97 with the per unit positive, GRG2 finds the correct default convergence tolerance of 1014, the optimal solution. Alternatively, if one Solver stops with the message “Solver changes the constraint that requires pro- converged to the current solution” and an duction to be less than or equal to demand objective value of $79,705.55, just short of to an equality constraint, GRG2 is able to the true optimum. If the convergence tol- find the correct solution even with initial erance is tightened to 1015, the Solver values of zero, since it can solve for certain stops with “Solver found a solution” and variables in terms of others. an objective value of $79,705.62. (In Excel We encourage users who encounter dif- 5.0 and 7.0, solving this model yields the ficulty with slow progress or who receive optimal objective of $79,705.62, because the message “Solver converged to the cur- the convergence tolerance is hard-wired in rent solution” to upgrade to Excel 97, these versions to 1015.) which allows them to control the conver- GRG2 uses the value in the Precision gence tolerance. The example model in edit box shown in Figure 4 (default 1016) Figure 7: This spreadsheet, which can be downloaded from Practice Online as FIGURE7.XLS, shows how the GRG2 nonlinear solver can stop with the message “Solver converged to the cur- rent solution.” With a tighter convergence tolerance, it stops at a slightly better, optimal point with the message “Solver found a solution.” INTERFACES 28:5 44
MICROSOFT EXCEL SOLVER for its feasibility tolerance. Constraints are The branch-and-bound algorithm starts classified as active when they are within by solving the relaxed problem (without this (absolute) tolerance of one of their the integer constraints) using either GRG2 bounds and are violated when their bound or the simplex method, yielding an initial violation exceeds this tolerance. The de- best bound for the problem including the fault value is rather tight for nonlinear integer constraints. The algorithm then be- problems, and users may find that they gins branching and solving subproblems can solve some problems with nonlinear with additional (or tighter) bounds on the constraints faster or even to a better result integer variables. A subproblem whose so- if they increase this value. We recommend lution satisfies all of the integer constraints 1014 for nonlinear problems but caution is a candidate for the solution of the over- against using values greater than 1012. all problem; the candidate with the best Users requiring high accuracy may prefer objective value so far is saved as the in- the default value. For nonlinear problems, cumbent. The algorithm uses the best ob- maximum accuracy results from choosing jective of the remaining nodes to be fath- central differences and the default feasibil- omed to update the best bound. Each time ity tolerance. the algorithm finds a new incumbent, it When a model is nonsmooth or noncon- computes the relative difference between vex, we recommend trying several differ- its objective and the current best bound, ent starting points. If GRG2 reaches yielding an upper bound on the improve- roughly the same final point, one can be ment in the objective that might be ob- fairly confident that this is a global solu- tained by continuing the solution process: tion. If not, one can choose the best of the Objective(Incumbent) 1 Objective(BestBound) solutions obtained. . Objective(BestBound) For further information on reduced gra- dient methods and the GRG2 solver, see If this value is less than or equal to the Lasdon and Smith [1992]. Tolerance edit box value (Figure 4), the al- Solving Problems with Integer gorithm stops. Some users have failed to Constraints notice that the default tolerance amount is When a problem includes integer vari- not zero but 0.05 and have therefore con- ables, the Excel Solver invokes a branch- cluded that the Excel Solver was not find- and-bound (B&B) algorithm that can use ing the correct integer solution. We chose either the simplex method or GRG2 to this default value, at Microsoft’s request, solve its subproblems. The user indicates to limit the time taken by nontrivial inte- which of the decision variables are integer ger problems. It often happens that the by adding constraints, such as A1:A10 4 branch-and-bound algorithm finds a rea- integer (or, in Excel 97, A1:A10 4 binary), sonably good solution fairly quickly and where A1:A10 is a range of variable cells. then spends a great deal of time finding (One enters such constraints by selecting (or verifying that it has found) the true in- “int” or “bin” from the Relation list in the teger optimal solution. Add or Change Constraints dialog box.) In the standard Excel Solver, the branch- September–October 1998 45
FYLSTRA ET AL. and-bound algorithm uses a breadth-first a classroom environment, instructors may search that branches on the unfathomed wish to have students set this value to node with the best objective. Frontline Sys- zero to ensure that the Solver will con- tems’ Premium Solver products use much tinue branching until it finds the optimal more elaborate strategies (Table 1). These integer solution. include a depth-first search that continues Users attempting to solve nonlinear in- until it finds an incumbent, followed by a teger problems should also take careful breadth-first search; more sophisticated note of the limitations cited above for the rules for choosing the next node to be fath- branch-and-bound algorithm when used omed; rules for reordering the integer vari- with GRG2. ables chosen for branching; use of the dual- Even small, academic-size integer prob- simplex method for the subproblems; and lems may require a great deal of solution preprocessing-and-probing (P&P) strategies time with the standard Excel Solver. Here for binary integer variables. These im- again, we recommend an upgrade to Excel provements often dramatically reduce solu- 97, which will improve solution times for tion time on integer problems (Table 1). both linear and nonlinear subproblems. It is possible to solve nonlinear integer An even better alternative is Frontline Sys- problems with the Excel Solver, but users tems’ Premium Solver for Excel 97, which should be aware of the intrinsic limitations offers algorithmic improvements to reduce of this process. On a linear problem, the both the number of subproblems and the simplex method can conclusively deter- time spent on each one. An academic ver- mine whether each subproblem is feasible sion of the Premium Solver is available and, if so, return the globally optimal so- and has proven quite popular with busi- lution to that subproblem. On nonlinear ness school instructors. integer problems, the GRG algorithm (or Saving the Solution and Producing any gradient-based method) may fail to Solver Reports find a feasible solution for a subproblem When one of the Excel Solver’s optimiz- even though one exists, or it may return a ers returns a solution, the Solver places the local optimum that is not global. This also solution values into the decision variable means that the best bound used by the cells, recalculates the spreadsheet, and dis- branch-and-bound algorithm will be based plays the Solver Results dialog box on local optima found by GRG2 and this (Figure 8). From this dialog box, the user may not be the global optimum. Because can choose to keep the optimal solution, or of this, the branch-and-bound algorithm is discard it and restore the initial values of not guaranteed to find the true integer op- the variables. In addition, the user can se- timum for nonlinear problems, although lect one or more reports, which the Solver it will often succeed in finding a “good” will then produce in the form of addi- integer solution. tional worksheets inserted into the current Modeling Practice workbook. It is important for users to understand Assuming that the user (or a Visual Ba- the role of the Tolerance edit box value. In sic program controlling the Solver) decides INTERFACES 28:5 46
MICROSOFT EXCEL SOLVER Figure 8: The Solver Results dialog box is displayed whenever the Solver stops. It allows the user to keep the solution or restore the original values of the variable cells and produce one or more of the Solver’s reports. to keep the solution, the Solver updates all solution. of the model’s results appropriately, in- The Answer Report provides the initial cluding the objective, the constraints, and and final values of the variables and the other auxiliary calculations that depend on objective and optimal values for each con- the decision variables. One can use any of straint’s left-hand side as well as slack these model values to draw charts and values for nonbinding constraints. graphs, update external databases, and the The Sensitivity Report provides final so- like using standard Excel facilities. A Vi- lution values and dual values for variables sual Basic program may also inspect the and constraints in both linear and nonlin- values and may further manipulate them ear models. For linear models, the dual or store them for later use. For example, it values are labeled “reduced costs” and is an easy classroom exercise to generate “shadow prices”; their values and ranges and graph the efficient frontier in a portfo- of validity are included in the report. For lio optimization problem in finance. nonlinear models, the dual values are The standard Excel Solver can produce valid only for small changes about the op- three types of reports: the Answer Report timal point, and they are labeled “reduced (Figure 9), the Sensitivity Report (Figure gradients” and “Lagrange multipliers.” 10), and the Limits Report (Figure 11). The The Solver creates the Limits Report by Premium Solver products (Table 1) can rerunning the optimizer with each deci- also produce a Linearity Report and a Fea- sion variable selected in turn as the objec- sibility Report. The Linearity Report high- tive, both maximizing and minimizing, lights the constraints involved when an at- while holding all other variables fixed at tempt to solve with the simplex method their optimal values. The report shows the fails the linearity test described earlier. The resulting lower limit and upper limit for Feasibility Report highlights an “irreduci- each variable and the corresponding value ble inconsistent system” of constraints of the original objective function. OR/MS [Chinneck 1997] when an attempt to solve professionals are sometimes puzzled by a linear problem yields no feasible the inclusion of this report, but Microsoft September–October 1998 47
FYLSTRA ET AL. Figure 9: The Answer Report summarizes the initial and final values of the variables, con- straints, and objective and indicates whether the constraints are binding (satisfied with equal- ity) or have slack. specified it for competitive reasons, since report values are automatically formatted the former Lotus-developed solver in 1-2-3 with dollars and cents, percent symbols, featured a similar report. scientific notation, or whatever custom Report Pitfalls formatting was used in the model. The pit- There are two pitfalls that users some- fall arises when users format their models times encounter with these reports. The to display variable and constraint values more common problem arises from the rounded to integers (say), which causes fact that the report spreadsheets are con- the corresponding dual values to be for- structed so that each cell “inherits” its for- matted as integers also. Not realizing this, matting from the corresponding cell in the some users think that the dual values are user’s model. This feature, which Micro- wrong. However, the Solver stores the soft specified, has the advantage that the dual values to full precision on the report INTERFACES 28:5 48
MICROSOFT EXCEL SOLVER Figure 10: The Sensitivity Report shows, for linear problems, reduced costs for the variables and shadow prices for the constraints, as well as the ranges of validity of these dual values. Figure 11: The Limits Report shows the objective value obtained by maximizing and minimiz- ing each variable in turn while holding the other variables’ values constant. September–October 1998 49
FYLSTRA ET AL. spreadsheet; one can inspect each value by form the label that appears for that cell in selecting it with the mouse, and one can the report. easily reformat the values to whatever pre- Users should avoid the pitfalls cited cision one desires. above. Because the default formatting for The second pitfall relates only to the cells is general, report values will appear Sensitivity Report. The Excel Solver recog- to full precision unless the user defines nizes constraints that are simple bounds custom formatting for the variable or con- on the variables and passes them in this straint cells. If one wants such formatting, form to both the simplex and GRG2 op- one must simply bear in mind its effect on timizers, where they are handled more ef- the reports. To see the dual values for sim- ficiently than if they were included as gen- ple variable bounds in the Constraints sec- eral constraints. If one of these constraints tion of the Sensitivity Report, one can is binding at the solution this actually modify the constraint right-hand side to means that the corresponding decision be (say) the formula 0 ` 5 rather than the variable has been driven to its bound. The constant 5. In this case, the Solver will not dual value for this binding constraint will recognize the constraint as a simple vari- appear as a reduced cost for the decision able bound. In Frontline Systems’ Pre- variable, rather than as a shadow price for mium Solver products, we changed this the constraint; it will be nonzero if the report so that dual values always appear variable was nonbasic at the solution. (In in the Constraints section of the report, fact, constraints that are simple bounds on even for constraints that are recognized as the variables are never listed in the Con- simple variable bounds, making this straints section of the Sensitivity Report.) work-around unnecessary. We encourage modelers to take advan- Use of the Solver in Industry tage of the fact that the reports are spread- We have heard many opinions about sheets. Not only can they view them but use of the Excel Solver from OR/MS pro- they can easily modify them, use them to fessionals. Many view spreadsheet solvers draw charts and graphs, transfer them to as suitable only for quite small problems other programs, or inspect them using Vi- or only for educational rather than indus- sual Basic programs. Since the reports trial use. Some wonder how such tools can show a text label as well as a cell reference be successfully employed by individuals for each variable and constraint, users can with little if any formal training in easily design their spreadsheet models so OR/MS methods. Some, seeing little usage that meaningful labels appear on the re- of the Excel Solver among their colleagues, ports. The algorithm for constructing these think that the Solver is widely distributed labels is very simple: starting from the but not very widely used. variable or constraint cell on the model We do not have enough systematic data worksheet, the Solver looks left and up for to project the actual number of users of the first text label in the same row and the Excel Solver among the 30-million-plus the first text label in the same column. It copies of Microsoft Office and Excel dis- then concatenates these two labels to tributed to date. But based on our contacts INTERFACES 28:5 50
MICROSOFT EXCEL SOLVER with users and the data we do have, we the textbooks that we feature on the Front- believe that OR/MS professionals are see- line Systems’ Web site). In other cases, ing only the proverbial tip of the iceberg these spreadsheet optimization models are and that use of the Excel Solver is far created by outside consultants with indus- more widespread than their comments try expertise, rather than OR/MS expertise would suggest. per se. Problem Size OR/MS Training Having worked with commercial users Every day we see successful Solver ap- for more than five years, we are very con- plications created by spreadsheet users fident that spreadsheet solvers are capable with little or no formal OR/MS training. of solving the majority of industrial LP Users of Frontline Systems’ Premium models, as well as many integer and non- Solver products are typically solving LP linear models. We base this belief on our models in the range of several hundred to own experience and on information about a few thousand (some as large as 10,000) problem size gained in discussions with decision variables and constraints and in- other vendors of (non-spreadsheet-based) teger and nonlinear problems of some- optimization software. In fact, we believe what smaller size. Although this group is that the median-size industrial LP model self-selected for applications more ambi- is smaller than many OR/MS profession- tious than those built with the standard als might expect—possibly as small as Excel Solver, we estimate that 90 to 95 per- 2,000 rows and columns. Spreadsheet op- cent of these users have no affiliation with timizers can readily handle problems well the OR/MS community. They are clearly above this size. “dispersed practitioners” [Geoffrion 1991]. Model Developers Yet this is just another layer of the ice- OR/MS professionals usually create op- berg. A much larger number of Excel timization models in situations where the Solver users visit Frontline Systems’ World modeling task is challenging enough and Wide Web site (www.frontsys.com), which the economic value of the problem is large receives more than 10,000 “hits” per day. enough to justify expert consulting help. We have some survey data on these users These problems are often much larger than that indicate that a surprising number of our median size estimate. But this is a tiny Solver applications are below 200 vari- part of the spectrum of optimization appli- ables in size but are of sufficient value that cations that we see. Many spreadsheet their developers are planning to distribute models are straightforward, successful copies of these applications within their adaptations of classic forms, such as trans- organizations or commercially. This portation, blending, multiperiod inventory, survey data and our experience in techni- and portfolio-optimization problems. cal support lead us to believe that this These models are created by functional class of applications is at least five managers who base them on the examples times and perhaps 10 times larger than supplied with Excel or found in various the class of applications above 200 books (indeed, such users often seek out variables. September–October 1998 51
You can also read