How To Use Excel Solver
How To Use Excel Solver
Introduction
We will be using the Solver facility in Microsoft Excel (created by Frontline Systems Inc.) to
solve linear and integer linear programming problems.
Solver is an add-in to Excel. For older versions of Windows/Excel, check that you have it by
going to Tools and seeing if Solver… is listed. If it is not, go to Add-ins… and select Solver
Add-in. For Windows 7, you will find it under Data, Analysis. If it is not there, go to File,
Options, Add-ins… If you have trouble finding Solver, go to Help and type “Solver Add-in”.
Exercise 1
1) Open a new Excel Worksheet. (Remember to save it often to avoid data loss.)
2) Enter the data into an Excel Spreadsheet in a similar way to that shown in Figure 1.
The inputs for the cells are exactly as shown, except for Cells B6, G8, G9 and G10 which are
input as follows.
Cell Content
B6 =SUMPRODUCT(B4:F4,B$2:F$2)
G8 =SUMPRODUCT(B8:F8,B$2:F$2)
G9 =SUMPRODUCT(B9:F9,B$2:F$2)
G10 =SUMPRODUCT(B10:F10,B$2:F$2)
1
Notes:
The ‘$’ symbols are a way of fixing the following part of the cell reference (making it
“absolute” rather than “relative”). They can be omitted, but if they are included you can
type one formula and then copy and paste the rest. For more information on this, type
“absolute reference” into the Excel Help and read the two topics “About cell and range
references” and “Switch between relative, absolute, and mixed references”.
SUMPRODUCT() is a function in Excel which multiplies corresponding components in
the given arrays and returns the sum of those products (i.e. the Dot product). For example
in cell G8, Excel will perform the calculation (B8*B2+C8*C2+D8*D2+E8*E2+F8*F2).
The cells B2, C2, …, F2 represent the values of the decision variables. You will instruct
Solver to try changing these cells to maximise your objective function (cell B6). It’s often
handy first to try out a few values for the decision variables by hand; this allows you to
see whether your objective function and constraint calculations are working properly.
3) Bring up the Solver window from the Tools menu and enter the parameters as shown in
Figure 2.
Note: The constraints are not entered directly into the large window at the bottom, but
rather by using the Add button.
4) For older versions of Windows, go to the Options menu of Solver, tick the Assume Linear
Model and Assume Non-negative boxes. For Windows 7, the solver window looks slightly
different: select the solving method Simplex LP.
5) Solve it!
2
Subject to x1 3 x 2 4 x3 3 x 4 2 x5 8
8 x1 x 2 9 x3 x5 10
0 x j 1, j 1,...,5.
x j integer, j 1,...,5
Notes: (1) All the constraints are specified using Add. The last set of constraints is of type
“int” (integer).
(2) Since the only possible values for the variables are 0 or 1, it is possible to combine
the last two constraints. Try using the type “bin” (binary) for the variables.
(3) This problem has (at least) two different optimal solutions, i.e. two different
solutions that satisfy the constraints and give the maximum value for the objective
function. Experiment with different initial values for the variables in order to try to
find different optimal solutions.
(4) For ILP problems, Solver will invoke a branch-and-bound algorithm. For large
problems, solution time will typically become (very) large compared to solving the LP
relaxation of the problem.
Exercise 3
Look at the other examples in your notes we have studied in the lectures. Try putting them
into Solver and verifying the results.
When you have found a solution, you can get Solver to produce various reports.
Of particular interest are the Answer Report and the Sensitivity Report:
The Answer Report is available for both LP and ILP models. It summarises
information about the solution found, including which constraints are binding and
which are not binding.
The Sensitivity Report is available only for LP models. It summarises how sensitive
the optimal solution is to individual changes in the model; i.e. how much a single
value of the model’s input data can be changed on its own while keeping the found
solution optimal. It specifies by howx` much the coefficients in the objective function
can change and by how much the constant values (the right hand side, RHS) in the
constraints can change.
3
MATH2013 Introduction to Operational Research
Mathematical Programming Software
Additional notes to the Lab session – general information
Solvers
`Solvers’ is a general name to denote which algorithms are implemented. You have solvers
that can handle Linear Programming (LP) only, but also solvers that can handle both LP and
Integer Programming (IP) and even non‐linear optimisation problems.
Modelling systems are providing user interfaces to allow users to model large problems
efficiently, and set‐up instances to be solved by linking into e.g. corporate databases.
Some solvers and modelling systems are tailored towards large corporations and academic
researchers. These are typically expensive and not easy for learning the basics for users new
to the area.
Example 1: Microsoft’s Solver add‐in to Excel
Very good as a first introduction to, but not for professional use.
Available whenever you have Excel. The Solver add‐in must be activated the first time you
wish to use it. An instance of a problem is modelled in an Excel spreadsheet. The equations
are specified in a Solver window.
Solution values are shown in the Excel spreadsheet, and also in separate sheets.
LP problems are solved by a simplex algorithm; IP problems with b‐a‐b (some issues); non‐
linear optimisation problems are ‘solved’ by a range of heuristics.
See also: the computer lab, and the extra examples.
Example 2: LINGO
LINDO, LINGO, What’s best. Quite reliable and at least semi‐professional. Solver + modelling
Free trial versions and software manuals available at www.lindo.com. A student version of
LINGO is typically included when purchasing the book of Winston (see L1).
The book ‘Optimization Modeling with LINGO’ by Linus Schrage is freely available from Lindo,
with many management science problems, and how to model them in LINGO. Highly
recommended!
The trial versions have the drawback that only problems of small size can be solved.
Professional packages
The industry solver standard is likely CPLEX. It is very powerful and runs behind the scenes of
many other software packages of various large consultancy firms. It is also used by many
researchers as it can be called from C++ and other programming environments.
An industry modelling system standard is MPL by Maximal Software, see www.maximal‐
usa.com. Provides links to a series of different compatible solvers.
Patrick Beullens, 29/10/2012