Define and solve a problem by using Solver
Solver is part of a suite of commands sometimes called what-if analysis tools. With Solver, you can find an optimal value for a formula in one cell - called the target cell - on a worksheet. Solver works with a group of cells that are related, either directly or indirectly, to the formula in the target cell. Solver adjusts the values in the changing cells that you specify - called the adjustable cells - to produce the result that you specify from the target cell formula. You can apply constraints to restrict the values that Solver can use in the model, and the constraints can refer to other cells that affect the target cell formula.In this article
Step through Solver trial solutions
Change how Solver finds solutions
Algorithms and methods used by Solver
Overview
Use Solver to determine the maximum or minimum value of one cell by changing other cells. For example, you can change the amount of your projected advertising budget and see the effect on your projected profit amount.
Example of a Solver evaluation
In the following example, the level of advertising in each quarter affects the number of units sold, indirectly determining the amount of sales revenue, the associated expenses, and the profit. Solver can change the quarterly budgets for advertising (cells B5:C5), up to a total budget constraint of $20,000 (cell F5), until the value for the total profit reaches the maximum possible amount. The values in the adjustable cells are used to calculate the profit for each quarter, so the values are related to the formula in the target cell F7, =SUM(Q1 Profit:Q2 Profit).
Adjustable cells
Constrained cell
Target cell
After Solver runs, the new values are as follows.
Define and solve a problem
- On the
Datatab, in theAnalysisgroup, clickSolver.If the
Solvercommand or theAnalysisgroup is not available, you need to load the Solver Add-in program.How to load the Solver Add-in program
- Click the
Microsoft Office Button
, click Excel Options, and then click theAdd-inscategory. - In the
Managebox, clickExcel Add-ins, and then clickGo. - In the
Add-ins availablebox, select theSolver Add-incheck box, and then clickOK.
- Click the
- In the
Set Target Cellbox, enter a cell reference or name for the target cell. The target cell must contain a formula . - Do one of the following:
- If you want the value of the target cell to be as large as possible, click
Max. - If you want the value of the target cell to be as small as possible, click
Min. - If you want the target cell to be a certain value, click
Value of, and then type the value in the box.
- If you want the value of the target cell to be as large as possible, click
- In the
By Changing Cellsbox, enter a name or reference for each adjustable cell. Separate the nonadjacent references with commas. The adjustable cells must be related directly or indirectly to the target cell. You can specify up to 200 adjustable cells. - If you want Solver to automatically propose the adjustable cells based on the target cell, click
Guess. - In the
Subject to the Constraintsbox, enter any constraints that you want to apply.How to add, change, or delete a constraint
Add a constraint
- In the
Solver Parametersdialog box, underSubject to the Constraints, clickAdd. - In the
Cell Referencebox, enter the cell reference or name of the cell range for which you want to constrain the value. - Click the relationship (
<=,=,>=,int, orbin) that you want between the referenced cell and the constraint . If you clickint,integerappears in theConstraintbox. If you clickbin,binaryappears in theConstraintbox. - In the
Constraintbox, type a number, a cell reference or name, or a formula . - Do one of the following:
- To accept the constraint and add another, click
Add. - To accept the constraint and return to the
Solver Parametersdialog box, clickOK.
- To accept the constraint and add another, click
Notes:
- You can apply the
intandbinrelationships only in constraints on adjustable cells. - When the
Assume Linear Modelcheck box in theSolver Optionsdialog box is selected, there is no limit on the number of constraints. For nonlinear problems, each adjustable cell can have up to 100 constraints, in addition to bounds and integer restrictions on the variables.
Change or delete a constraint
- In the
Solver Parametersdialog box, underSubject to the Constraints, click the constraint that you want to change or delete. - Click
Changeand then make your changes, or clickDelete.
- In the
- Click
Solveand do one of the following:- To keep the solution values on the worksheet, click
Keep Solver Solutionin theSolver Resultsdialog box. - To restore the original data, click
Restore Original Values.
Notes:
- You can interrupt the solution process by pressing ESC. Microsoft Office Excel recalculates the worksheet with the last values that are found for the adjustable cells.
- To create a report that is based on your solution after Solver finds a solution, you can click a report type in the
Reportsbox and then clickOK. The report is created on a new worksheet in your workbook. If Solver doesn't find a solution, the option to create a report is unavailable. - To save your adjusting cell values as a scenario that you can display later, click
Save Scenarioin theSolver Resultsdialog box, and then type a name for the scenario in theScenario Namebox.
- To keep the solution values on the worksheet, click
Step through Solver trial solutions
- After you define a problem, click
Optionsin theSolver Parametersdialog box. - In the
Solver Optionsdialog box, select theShow Iteration Resultscheck box to see the values of each trial solution, and then clickOK. - In the
Solver Parametersdialog box, clickSolve. - In the
Show Trial Solutiondialog box, do one of the following:- To stop the solution process and display the
Solver Resultsdialog box, clickStop. - To continue the solution process and display the next trial solution, click
Continue.
- To stop the solution process and display the
Change how Solver finds solutions
- In the
Solver Parametersdialog box, clickOptions. - In the
Solver Optionsdialog box, choose one or more of the following options:Solution time and iterations
- In the
Max Timebox, type the number of seconds that you want to allow for the solution time. - In the
Iterationsbox, type the maximum number of iterations that you want to allow.
Note If the solution process reaches the maximum time or number of iterations before Solver finds a solution, Solver displays the
Show Trial Solutiondialog box.Degree of precision
- In the
Precisionbox, type the degree of precision that you want. The smaller the number, the higher the precision.
Integer tolerance
- In the
Tolerancebox, type the percentage of error that you want to allow in the solution.
Degree of convergence
- In the
Convergencebox, type the amount of relative change that you want to allow in the last five iterations before Solver stops with a solution. The smaller the number, the less relative change is allowed.
Note You can click the
Helpbutton in the dialog box to get more information about other options. - In the
- Click
OK. - In the
Solver Parametersdialog box, clickSolveorClose.
Save or load a problem model
- Click
Options. - Click
Save ModelorLoad Model. - When you save a model, enter the reference for the first cell of a vertical range of empty cells in which you want to place the problem model. When you load a model, enter the reference for the entire range of cells that contains the problem model.
Tip You can save the last selections in the
Solver Parametersdialog box with a worksheet by clicking theMicrosoft Office Button
, and then by clicking Save. You can also define more than one problem for a worksheet by clickingSave Modelto save problems individually.
Algorithms and methods used by Solver
The Microsoft Office Excel Solver tool uses the Generalized Reduced Gradient (GRG2) nonlinear optimization code, which was developed by Leon Lasdon, University of Texas at Austin, and Alan Waren, Cleveland State University.
Linear and integer problems use the simplex method with bounds on the variables and the branch-and-bound method, implemented by John Watson and Daniel Fylstra, Frontline Systems, Inc. For more information about the internal solution process that is used by Solver, contact:
Frontline Systems, Inc.
P.O. Box 4288
Incline Village, NV 89450-4288
(775) 831-0300
Web site: http://www.solver.com
E-mail: info@solver.com
Portions of the Microsoft Office Excel Solver program code are copyright 1990, 1991, 1992, and 1995 by Frontline Systems, Inc. Portions are copyright 1989 by Optimal Methods, Inc.
![]()