Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Using the Solver in Excel 2010

Table of Contents
Overview .................................................................................................................. 1
Before you start ................................................................................................... 1
Loading the Solver add-in ........................................................................................ 1
Chocolate Example .................................................................................................. 2
The dilemma! ....................................................................................................... 2
A solution ............................................................................................................. 2
Changing some constraints .................................................................................. 4
Allocation of funds example .................................................................................... 5
Exercise ................................................................................................................ 7
Solution ................................................................................................................ 7
More practice....................................................................................................... 8
Other resources ....................................................................................................... 8

Overview
These notes are an introductory guide to using the Solver add-in for Excel 2010.
Solver is a what-if analysis tool for optimization. You can use the Solver to find
the optimum value for a particular cell by adjusting the values of several cells.

Before you start

You will need:

the chocolate_solver_practice.xls file,


the allocation_solver.xls file,
the SOLVSAMP.XLS file,
Excel 2010 with the solver add-in installed.

Loading the Solver add-in


To use the Solver add-in you first need to load it in Excel. In
Excel, the Solver is located under the Data tab, in the Analysis
group. If you do not have the Solver installed, complete the
following steps.
1. Go to the File tab and choose Options An Excel Options dialog box appears.
2. Select Add-Ins, and then from the Manage box, select Excel Add-ins and click on
Go
3. An Add-Ins dialog box appears. Select the Solver Add-in check box, and then
click OK
WMS IT Team

4. The Solver command should now be available from the Analysis group on the
Data tab.
Chocolate Example
This example is an adaptation of a problem at
http://www.reading.ac.uk/web/FILES/its/solver2007.pdf
The dilemma!

You have a $20 voucher to spend on chocolate in a particular speciality shop. A


small (100g) bar costs $1.70, a large (250g) one is $3.20. However, there's a special
deal on the small bars whereby if you buy three small bars you get one small bar
free.
You want to buy as much chocolate as possible, and, ideally, you want to spend
every cent as the shopkeeper doesn't give change for a voucher.
How many of each sort of chocolate bar should you buy?

A solution

Open the chocolate_solver.xls file. We have set up the spreadsheet to reflect this
basic data. We want to:
maximise the amount of chocolate (cell D12)
only buy whole bars (the shopkeeper probably wont sell us part of a bar)
keep within our $20 budget

Examine the data and the formulae to make sure you understand them. To
establish how to get the most chocolate for your voucher, complete the following
steps:
1. Go to the Data tab and within the Analysis group, choose Solver A Solver
Parameters dialog box appears.
a) For the Set Objective box, click on cell D12.
(Cell D12 calculates the total weight of the chocolate.)
b) Under To: choose Max
(You want to maximise the total weight of the chocolate.)
c) Click into the By Changing Variable Cells box.
i) Click on cell C7.
ii) Drag through to cell C9.
iii) $C$7:$C$9 should appear.
(Cells C7 to C9 represent the various ways you can buy the chocolate.)

Page | 2

Using the Solver in Excel 2010

d) Click into the Subject to the Constraints box. To enter the constraint that
the total cost must equal $20:
i) Click on Add An Add Constraint dialog box appears.
ii) Under Cell Reference click on cell E12. $E$12 should appear.
iii) Under Constraint select = and click on cell C14. (or we could have typed
in 20.00)
iv) Click on Add
e) To enter the constraint that you cant buy part of a chocolate bar:
i) Under Cell Reference click on cell C7 and drag through to cell C9.
$C$7:$C$9 should appear.
ii) Under Constraint choose int for integer.
(An integer is a whole number.)
iii) Click on Add
f) To enter the constraint that you cant have a negative number of bars:
i) Under Cell Reference click on cell C7 and drag through to cell C9.
$C$7:$C$9 should appear.
ii) Under Constraint choose >= and type in: 0
iii) Click on Add Click on Cancel
2. You should be back in the Solver Parameters dialog box. The settings in the
dialog box should look similar to those in the image below.

3. Click on the Options button. An Options dialog box appears.


Using the Solver in Excel 2010

Page | 3

Ensure that the Ignore Integer Constraints option is unchecked.


Click on OK You should be back in the Solver Parameters dialog box.
Click on the Solve button.
A Solver Results dialog box appears. In the worksheet, the numbers of each
type of chocolate bar have altered. If we buy 2 large bars and 10 small ones, the
total weight is 1500 grams and we have used up the $20 voucher exactly.
8. For now, select the Restore Original Values option and click on OK

4.
5.
6.
7.

Changing some constraints

Do we really have to use up the total value of the voucher? What happens if we
relax this requirement slightly and amend the constraint so that total cost must be
< or = to $20.
1. Go to the Data tab and within the Analysis group, choose Solver A Solver
Parameters dialog box appears.
To enter the constraint that total cost must be < or = to $20
a) Select the $E$12=$C$14 constraint and click on Change A Change
Constraint dialog box appears.
b) Change the = to <= and click on OK
2. You should be back in the Solver Parameters dialog box. Click on the Solve
button.
3. A Solver Results dialog box appears. In the worksheet, the numbers of each
type of chocolate bar have altered. The total weight is now 1550 grams and we
have spent $19.80. This solution suggests we buy 3 large and 8 small bars to
give us an extra 50 grams of chocolate.

4. Choose Restore Original Values and experiment by changing some of the other
variables.

Page | 4

Using the Solver in Excel 2010

Allocation of funds example


Open the file allocation_solver.xls
This is an adaptation of a sample file that comes with Excel. Solver can be used to
find the allocation of funds to stocks that maximises the rate of return for a given
level of risk, or minimises the portfolio risk for a given level of return.
The worksheet contains figures for beta (market related risk) and the residual
variance for four stocks, as well as Government stock. The Government stock is
assumed to have a risk free rate of return and a variance of zero.
The beginning position is that equal amounts (20% of the portfolio) are invested in
each item, the average return is 16.4% and the variance is 7.1%.
To determine (using the Solver) the maximum rate of return for a given level of
risk, assuming...
the variance must be < or = to 7.1% (0.071)
the weight of each stock must be > or = to 0
the total weights must = 100% (1.0)
...complete the following steps.
1. Go to the Data tab and within the Analysis group, choose Solver A Solver
Parameters dialog box appears.
a) For the Set Objective box, click on cell E18.
b) Under To: choose Max
c) Click into the By Changing variable Cells box.
i) Click on cell E10.
ii) Drag through to cell E14.
iii) $E$10:$E$14 should appear.
d) To enter the constraint that the variance must be < or = to 7.1% (0.071):
i) Click on Add An Add Constraint dialog box appears.
ii) Under Cell Reference click on cell G18. $G$18 should appear.
iii) Under Constraint ensure that <= is showing and type in: 0.071
iv) Click on Add
e) To enter the constraint that the weight of each stock must be > or = to 0:
i) Under Cell Reference click on cell E10 and drag through to cell E14.
$E$10:$E$14 should appear.
ii) Under Constraint choose >= and type in: 0
iii) Click on Add
f) To enter the constraint that the total weights must = 100% (1.0)
Using the Solver in Excel 2010

Page | 5

i) Under Cell Reference click on cell E16. $E$16 should appear.


ii) Under Constraint choose = and type in: 1
iii) Click on Add Click on Cancel
2. You should be back in the Solver Parameters dialog box. Under Subject to
the Constraints:
$E$10:$E$14>=0
$E$16=1
$G$18<=0.071
should all be visible.
The settings in the dialog box should look similar to those in the image below.

3. Click on Solve
4. A Solver Results dialog box appears. In the worksheet, the weights of each
stock have altered, and the return has increased to 17.1% for the same risk (i.e.
the variance of 7.1%). For now,
select Restore Original Values and
click on OK

Page | 6

Using the Solver in Excel 2010

Exercise

Determine (using the Solver) the minimum portfolio risk assuming:


the return must be > or = to 16.4% (0.164)
the weight of each stock must be > or = to 0
the total weights must = 100% (1.0)
If you get stuck, the step by step instructions follow.

Solution

1. In the Solver Parameters dialog:


a) For the Set Objective box, click on cell G18.
b) Under Equal to: choose Min
c) Click into the By Changing Variable Cells box.
i) Click on cell E10.
ii) Drag through to cell E14.
iii) $E$10:$E$14 should appear.
d) To enter the constraint that the return must be > or = to 16.4% (0.164):
i) Click on Add An Add Constraint dialog box appears.
ii) Under Cell Reference click on cell E18. $E$18 should appear.
iii) Under Constraint choose >= and type in 0.164
iv) Click on Add
e) To enter the constraint that the weight of each stock must be > or = to 0:
i) Under Cell Reference click on cell E10 and drag through to cell E14.
$E$10:$E$14 should appear.
ii) Under Constraint choose >= and type in 0
iii) Click on Add
f) To enter the constraint that the total weights must = 100% (1.0):
i) Under Cell Reference click on cell E16. $E$16 should appear.
ii) Under Constraint choose = and type in 1
iii) Click on Add Click on Cancel

2. You should be back in the Solver Parameters dialog box. Under Subject to
the Constraints:
$E$10:$E$14>=0
$E$16=1
$E$18>=0.164
should all be visible. The dialog box should look similar to the one below.

Using the Solver in Excel 2010

Page | 7

3. Click on Solve
4. A Solver Results dialog box appears.
In the worksheet, the weights of each
stock have altered, and the risk (i.e. the
variance) has decreased to 6.2% for the
same (original) return of 16.4%. For
now, click on Restore Original Values
and click on OK
More practice

Experiment by changing some of the other variables. For example, what is the
maximum return available for a given level (or less) of risk, if, say, at least 20% of
the portfolio must be invested in Govt stock?
Examine the file SOLVSAMP.XLSit shows lots of uses for the Solver.

Other resources
The following websites are useful:
New and Improved Solver http://blogs.office.com/b/microsoftexcel/archive/2009/09/21/new-and-improved-solver.aspx
Lots of examples at http://www.solver.com/solutions/
Solver help http://www.solver.com/excel2010/solverhelp.htm

Page | 8

Using the Solver in Excel 2010

You might also like