Professional Documents
Culture Documents
LPsolver
LPsolver
Outline:
Decision Variables:
Objective Function:
Constraints:
If you don’t have any particular initial values you want to enter for your decision variables,
you can start by just entering a value of 0 in each decision variable cell.
The cell below “Total” and the cells below “LHS” in the spreadsheet are defined by using the
SUMPRODUCT function in the manner seen below.
If you are not familiar with “sumproduct”, you can use “= B3*B5+C3*C5” instead of
“sumproduct(B3:C3,B5:C5)”, and so on. See example below. Both serve the same purpose.
1.2 Constructing an Optimization Model Using Solver
Once you are satisfied with the basic spreadsheet model you have built, you are ready to
build an optimization model using Solver. To begin using Solver,
• click on “Tools” and select “Solver”.
A gray dialogue box will appear. You will build the constrained optimization model using
this dialogue box.
1.3 Selecting the Cell to Optimize
To select the cell you wish to optimize, look at the “Set Cell” window within the dialogue
box. Erase (or simply drag the cursor over) everything that is in that window. Then, either
If you wish to click on the optimization cell but the dialogue box is in the way, you can move
the dialogue box by positioning the arrow on the title bar at the top of the box and dragging it
out of the way.
1.4 Identifying Decision Variable Cells
Move the cursor to the “By Changing Cells” window within the dialogue box. Again, erase
anything that may be there (unless you put it there before and want to keep it). You now must
tell Excel which cells are decision variables—i.e., which cells Excel is allowed to change
when trying to optimize. To do this:
• type the addresses of every cell you wish to treat as a decision variable, separating
them by commas, or
• drag the cursor across all cells you wish to treat as decision variables.
If you wish to use the “dragging” method, but the decision variables to not all lie in a
connected rectangle in the spreadsheet you can “drag” them in one group at a time:
• drag the cursor across one group of decision variables,
• put a comma after that group in the “By Changing Cells” window,
• drag the cursor across the next group of decision variables,
• etc....
1.5 Defining Constraints
To begin entering constraints, click on the “Add” button to the right of the constraints
window. A new dialogue box will appear. The cursor will be in the “Cell Reference” window
within this dialogue box.
• Type the cell address that contains the quantity you want to constrain, or
• click on the cell that contains the quantity you want to constrain.
Again, if the dialogue box is in the way, you can move it by dragging the bar at the top of the
box. The default inequality that first appears for a constraint is “<=“. To change this,
(Notice that you may also force a decision variable to be an integer using this window. I do
not recommend that you use this integer feature for this course.)
After setting the inequality, move the cursor to the “Constraint” window.
• Type the number or the cell reference you want to use as the constraining value
for that constraint, or
• click on the cell you want to use as the constraining value for that constraint.
If you want to constrain a column (or row) of cells by using another column (or row) of cells
as the constraining values, you can input this whole collection of constraints at the same
time.
• When in the “Cell Reference” window, drag across the column (or row) of cells
you want to constrain.
• Then, in the “Constraint” window, drag across the column (or row) of cells that
you want to use as the constraining values.
If, in the process of building you optimization model, you discover that your spreadsheet is
missing some pieces (e.g., you want to constrain some quantity, but you did not include a cell
for that quantity in your spreadsheet),
• Click on the “Assume Linear Model” box - make sure a check appears in this box.
• Click on the “OK” button to return to the original dialogue box.
• “Optimal solution found”. This means that Solver has found the optimal solution.
• “Cell values did not converge”. This means that the objective function can be
improved to infinity. You may have forgotten a constraint or made a mistake in a
formula.
• “Solver could not find a feasible solution”. This means that Solver could not find
a feasible solution to the constraints you entered. You may have made a mistake
in typing the constraints or in entering a formula in your spreadsheet.
• “Conditions for Assume Linear Model not satisfied”. You may have forgotten to
include some non-negativity constraints, or you may have included a formula in
your model that is nonlinear. There is also a slim chance that Solver has made an
error. (This bug shows up occasionally.)
If Solver finds an optimal solution, you have some options. First, you must choose whether
you want Solver to keep the optimal values in the spreadsheet (you usually want this one) or
go back to the original numbers you typed in. Click the appropriate box to make you
selection. You also get to choose what kind of reports you want. Sometimes you want to
select “Sensitivity Report”. Once you have made your selections, click on “OK”. To view the
sensitivity report, click on the “Sensitivity Report” tab in the lower-left-hand corner of the
window.
1.9 Saving and Printing Files
To save a file, simply
Be sure to save your file on the correct disk and the correct directory. For assistance with
this, see a consultant.
If you created any sensitivity analysis reports, Excel will automatically bundle your
spreadsheet with these reports.
To print your spreadsheet, simply make sure the spreadsheet is on the screen, then
If you want to make changes in the way the file will print (e.g., print is sideways on the page
(landscape), etc.), select “Page Setup” instead. Make the appropriate changes, then select
“Print”. Again, see a consultant if you need additional help.
To print your sensitivity report, simply make sure the report is on the screen and repeat the
above steps.
2. The Diet Example
Solver Solution:
Formulas:
3. The Scheduling Example
Solver Solution:
Formulas:
4. The Transportation Example
Solver Solution:
Formulas:
LP Supplement: Sensitivity Analysis—“What if?”
If the net profit per table changes, will the solution change?
If the net profit per chair changes, will the solution change?
If more (or less) large bricks are available, how will this affect profit?
If more (or less) small bricks are available, how will this affect profit?
Summary of Output from Excel Solver
Adjustable Cells:
Final Value The value of the variable in the optimal solution.
Reduced Cost Increase in the objective function value per unit increase
in the value of a zero-valued variable (for small
increases).
Constraints:
Final Value The usage of the resource in the optimal solution.
Shadow price The change in the value of the objective function per unit
increase in the right hand side of the constraint:
∆Z = (Shadow Price)(∆RHS)
(Note: only valid if change is within the allowable range
for RHS values — see below.)