Excel_Solver Example .docx

advertisement
Using Excel's Solver for LP Problems
Revised from documents prepared by Mike Flodin, Scott MacDonald, and Rhoda Gage
11/30/1998
Here are step-by-step instructions for using the Excel Solver program to solve linear programming
problems. The example is from the Case Study at the end of Chapter 4, page 262.
There is also an example on page 215 of the text.
Example: The sample output is for the following linear programming problem.
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 sample output below, 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.
Inputs For Excel
x y z u v w Objective
Constraints
=50000*A2+10000*B2+20000*C2+70000*D2
0 0 0 0 0 0 +20000*E2+50000*F2
=A2+D2 10
=B2+E2 20
=C2+F2 10
=A2+B2+C2 15
=D2+E2+F2 30
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 sample output, cell G2 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. Ignore constraints of the form x  0 for this step.
Example: I have chosen to put my constraints in cells H and I 2, 3, 4, 5, and 6.
4. Now click the Data tab, then click Analysis (on the far right), and choose Solver. If "Solver…"
does not appear under the "Analysis" menu, then this option was not installed when Excel
was installed on your computer. Click the Office button, choose Excel Options, then Add-Ins.
Click Go under Manage Add-Ins; check Solver, and click OK.
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 G2—which you should enter as $G$2 since this is a stationary cell, one you don’t want Excel
to change, OR you can click on cell G2, and Excel will put it in for you.)
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 "$A$2:$F$2" (without the
quotation marks).)
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)
Under "cell reference", enter one of the cells containing a constraint formula (from
column H, step 3). You can also click on the cell in the spreadsheet, and Excel will put
it in for you.
(ii) Choose the direction of the inequality from the pull down menu.
(iii)Enter the numeric value from column I, step 3, in the "Constraint" box.
The first constraint in the example would look like
(iv) To add a constraint that only uses one variable (such as A3  0), use the same method, but
use the variable directly ("cell reference" is "A3", direction ">=" and constraint "0").
(v) Choose the "Add" button if you have more constraints, or "OK" if you are done.
5. Click on "Options" and click on "Assume Linear Model" and click "OK".
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