Using_Excels_Solver Scott Macdonald Doc.doc

advertisement
Using Excel's Solver for LP Problems
Revised from documents prepared by Mike Flodin and Scott MacDonald
6/5/2001
Here are step-by-step instructions for using the Excel Solver program to solve linear
programming problems.
Example: The attached sample output is for the following linear programming problem—
with a story thrown in.
Minimize p = 50,000x + 10,000y + 20,000z + 70,000u + 20,000v + 50,000w subject to
the constraints x  0, y  0, z  0, u  0, v  0, w  0,
x + u  10,
y + v  20,
z + w  10,
x + y + z  15, and
u + v + w  30
1. Identify the cells that will contain your variables. They must be together in a column or row.
Put some text next to these cells to keep track of which is which.
Example: In the attached sample output, cells A2, B2, C2, D2, E2, and F2 are reserved
for the variables, so are left blank. The cells right above these, namely A1, B1, C1, D1,
E1, and F1, are labeled to explain what the numbers that will be in the variable cells
actually mean.
2. Identify the cell that will contain your objective function. Enter the objective function as a
formula that uses the cells identified in step 1.
Example: In the attached sample output, cell H2 is reserved for the objective function.
The formula I have entered in there is, thus, the formula for the objective function.
3. Identify the cells that will contain your constraints and enter each constraint inequality as a
formula in a separate cell. For now, ignore the "number" side of the inequality; just enter the
formula side. Ignore constraints of the form x  0 for this step.
Example: I have chosen to put my constraints in cells B4, B5, B6, B7, and B8. The text in
cells A4, A5, A6, A7, and A8 is simply to help me keep track of what each number in the
final readout stands for.
4. Now choose "Solver…" from the "Tools" menu. If "Solver…" does not appear under the
"Tools" menu, then this option was not installed when Excel was installed on your
computer. If you have the disks or CD, you will want to install the solver now. (Click
“tools” then “add ons”)
When you select "Solver…", the following dialog box should appear:
a) Enter the cell of the objective function from step 2 under "set target cell". (In the
example, this is H2—which the program changes to $H$2, that's okay.)
b) Choose whether you want to minimize or maximize your objective. (In the example, we
are trying to minimize the objective.)
c) Enter the range of cells containing your variables (from step 1) in the box labeled "by
changing cells". (Since the cells in the example are A2-F2, we would enter "A2:F2"
(without the quotation marks)—the program changes this to $A$2:$F$2, that's still okay.)
d) Now you will need to add each constraint. Choose the "add" button next to the constraint
window to get a new dialog box.
(i)
(ii)
(iii)
Under "cell reference", enter one of the cells containing a constraint formula
(from step 3).
Choose the direction of the inequality from the pull down menu.
Enter the numeric value that we ignored in step 3 in the "Constraint" box.
The first constraint in the example would look like
To add a constraint that only uses one variable (such as A2  0), use the same
method, but use the variable directly ("cell reference" would be "A3", direction ">="
and constraint "0").
(v)
Choose the "Add" button if you have more constraints, or "OK" if you are done.
(iv)
5. Click on "Options" and click on "Assume Linear Model" and click "OK".
Example: In our example, when we are done entering constraints and the like, the dialog
should look like this:
6. Click on "Solve" and Excel will do the rest. Pay attention to the message Excel gives you to
help determine if everything worked correctly.
Download