LP Solver Excel Guide
LP Solver Excel Guide
You use Solver when you want to find the best way to do something. Or, more formally,
when you want to find the values of certain cells in a spreadsheet that optimize
(maximize or minimize) a certain objective.
An optimization model has three parts: a target cell, changing cells, and constraints.
The target cell represents the objective or goal. For example, maximize monthly profit.
Changing cells are the spreadsheet cells that we can change or adjust to optimize the
target cell. For example, the amount of each product produced during the month.
Constraints are restrictions you place on the changing cells. For example, use no more
resources than are available and do not produce more of a product than can be sold.
Let's say we work for a drug company that can produce six products at their plant.
Production of each product requires labor and raw material.
Row 4 in Figure 1 gives the hours of labor needed to produce a pound of each
product, and row 5 gives the pounds of raw material needed to produce a pound of each
product. For example, producing a pound of product 1 requires 6 hours of labor and 3.2
pounds of raw material.
For each drug, the price per pound is given in row 6, the unit cost per pound is
given in row 7, and the profit contribution per pound is given in row 9. For example,
product 2 sells for $11.00 per pound, incurs a unit cost of $5.70 per pound, and
contributes $5.30 profit per pound.
This month's demand for each drug is given in row 8. For example, demand for
product 3 is 1041 pounds.
This month, 4500 hours of labor and 1600 pounds of raw material are available. How can
this company maximize its monthly profit?
If we knew nothing about Solver, we would attack this problem by constructing a
spreadsheet in which we track for each product mix the profit and resource usage
associated with the product mix. Then we would use trial and error to vary the product
mix to optimize profit without using more labor or raw material than is available and
without producing more of any drug than there is demand. We use Solver in this process
only at the trial-and-error stage. Essentially, Solver is an optimization engine that
flawlessly performs the trial-and-error search.
A key to solving the product mix problem is efficiently computing the resource usage and
profit associated with any given product mix. An important tool that we can use to make
this computation is the SUMPRODUCT function. The SUMPRODUCT function
multiplies corresponding values in cell ranges and returns the sum of those values. Each
cell range used in a SUMPRODUCT evaluation must have the same dimensions, which
implies that you can use SUMPRODUCT with two rows or two columns but not with a
column and a row.
As an example of how we can use the SUMPRODUCT function in our product mix
example, let's try to compute our resource usage. Our labor usage is given by calculating:
(Labor used per pound of drug 1) *
(Drug 1 pounds produced) +
(Labor use d per pound of drug 2) *
(Drug 2 pounds produced) +
...
per pound) *
We now can identity the three parts of our product mix Solver model:
Target cell
Changing cells
Our goal is to
maximize profit
(computed in cell
D12).
The number of
pounds produced of
each product (listed in
the cell range D2:I2).
Constraints
Do not use more labor and raw
material than are available. That is, the
values in cells D14:D15 (resources used)
must be less than or equal to the values in
cells F14:F15 (the available resources).
Do not produce more of a drug than
is in demand. That is, the values in the
cells D2:I2 (pounds produced of each drug)
must be less than or equal to the demand
for each drug (listed in cells D8:I8).
We can't produce a negative amount
of any drug.
To begin, select Solver on the Tools menu. (For instructions on installing Solver,
see Introduction to optimization with the Excel Solver tool.)
The Solver Parameters dialog box will appear.
2.
To input the target cell, click in the Set Target Cell box and then select our profit
cell (cell D12). To input our changing cells, click in the By Changing Cells box and
then point to the range D2:I2, which contains the pounds produced of each drug. The
dialog box should now look like the following figure.
3.
We're now ready to add constraints to the model. Click the Add button. You'll see
the Add Constraint dialog box.
4.
To add the resource usage constraints, click in the box labeled Cell Reference
and then select the range D14:D15. Choose <= from the list in the middle of the
dialog box. Click in the box labeled Constraint, and then select the cell range
F14:F15.
We have now ensured that when Solver tries different values for the changing cells,
Solver will consider only combinations that satisfy both D14 <= F14 (labor used is
less than or equal to labor available) and D15 <= F15 (raw material used is less than
or equal to raw material available).
5.
Now click Add in the Add Constraint dialog box to enter the demand
constraints. Simply fill in the Add Constraint dialog box as shown in the following
figure.
Adding these constraints ensures that when Solver tries different combinations for the
changing cell values, Solver will consider only combinations that satisfy the
following:
D2 <= D8 (the amount of drug 1 made is less than or equal to the demand
for drug 1)
E2 <= E8 (the amount of drug 2 made is less than or equal to the demand
for drug 2)
F2 <= F8 (the amount of drug 3 made is less than or equal to the demand
for drug 3)
G2 <= G8 (the amount of drug 4 made is less than or equal to the demand
for drug 4)
H2 <= H8 (the amount of drug 5 made is less than or equal to the demand
for drug 5)
I2 <= I8 (the amount of drug 6 made is less than or equal to the demand
for drug 6)
6.
Click OK in the Add Constraint dialog box. The Solve Parameters dialog box
should look like the following figure.
7.
We enter the constraint that all changing cells be non-negative in the Solver
Options dialog box, which we open by clicking the Options button in the Solver
Parameters dialog box.
Select the options Assume Linear Model and Assume Non-Negative, and then click
OK.
Why select these options?
Selecting the Assume Non-Negative option ensures that Solver considers only
combinations of changing cells in which each changing cell assumes a non-negative
value.
We selected Assume Linear Model because the product mix problem is a special
type of Solver problem called a linear model. Essentially, a Solver model is linear
under the following conditions:
...
(Drug 6 profit per pound) *
(Drug 6 pounds produced)
This computation follows a pattern in which the target cell's value is derived by
adding together terms of the form (changing cell)*(constant).
Our labor constraint is evaluated by comparing the labor available to the value
derived from:
(Labor used per pound of drug 1)*
(Drug 1 pounds produced) +
(Labor used per pound of drug 2)*
(Drug 2 pounds produced) +
...
(Labor used per pound of drug 6)*
(Drug 6 pounds produced)
Therefore, the labor constraint is evaluated by adding together terms of the form
(changing cell)*(constant) and comparing such sums to a constant. Both the labor
constraint and the raw material constraint satisfy the linear model requirement.
Our demand constraints take the form
(Drug 1 produced)<=(Drug 1 Demand)
(Drug 2 produced)<=(Drug 2 Demand)
...
(Drug 6 produced)<=(Drug 6 Demand)
Each demand constraint also satisfies the linear model requirement because each is
evaluated by adding together terms of the form (changing cell)*(constant) and
comparing such sums to a constant.
Having shown that our product mix model is a linear model, why should we
care?
8.
After clicking OK in the Solver Options dialog box, we're returned to the main
Solver dialog box. When we click Solve, Solver calculates an optimal solution (if one
exists) for our product mix model.
An optimal solution to the product mix model would be a set of changing cell values
(pounds produced of each drug) that maximizes profit over the set of all feasible
solutions. Again, a feasible solution is a set of changing cell values satisfying all
constraints. The changing cell values shown in Figure 2 are a feasible solution because all
production levels are non-negative, no production levels exceed demand, and resource
usage does not exceed available resources.
Figure 2: A feasible solution to the product mix problem fits within constraints.
The changing cell values shown in Figure 3 represent an infeasible solution for the
following reasons:
We produce more of drug 5 than is demanded.
Figure 3: An infeasible solution to the product mix problem doesn't fit within the constraints we
defined.
After clicking Solve, Solver quickly finds the optimal solution shown in Figure 4. You
need to select Keep Solver Solution to preserve the optimal solution values in the
spreadsheet.
Our drug company can maximize its monthly profit at a level of $6,625.20 by producing
596.67 pounds of drug 4, 1084 pounds of drug 5, and none of the other drugs! We can't
determine if we can achieve the maximum profit of $6,625.20 in other ways. All we can
be sure of is that with our limited resources and demand, there is no way to make more
than $6,625.20 this month.
1.
2.
Open Solver.
Click the D2:I2 <= D8:I8 constraint, and then click Change.
The Change Constraint dialog box appears.
3.
When you click Solve, you'll see the message, Solver could not find a feasible solution.
This message means that with our limited resources, we can't meet demand for all
products. We have not made a mistake in our model! Solver is simply telling us that if we
want to meet demand for each product, we need to add more labor, more raw material, or
more of both.
Open Solver.
Click the Options button, and then clear the Assume Non-Negative check box.
In the Solver Parameters dialog box, click the demand constraint D2:I2 <=
D8:I8, and then click Delete to remove the constraint.
When you click Solve, Solver returns the message, The Set Cell values do not
converge. This message means that if the target cell is to be maximized (as in our
example), there are feasible solutions with arbitrarily large target cell values. (If the target
cell is to be minimized, this message means there are feasible solutions with arbitrarily
small target cell values.)
In our situation, by allowing negative production of a drug, we in effect "create"
resources that can be used to produce arbitrarily large amounts of other drugs. Given our
unlimited demand, this allows us to make unlimited profits. In a real situation, we can't
make an infinite amount of money. In short, if you see Set values do not converge, your
model does have an error.
Test yourself
1.
Suppose our drug company could buy up to 500 hours of labor at $1 per hour.
Would they take advantage of this opportunity?
2.
At a chip manufacturing plant, four technicians (A, B, C, and D) produce three
products (products 1, 2, and 3). The chip manufacturer can sell 80 units of product 1
this month, 50 units of product 2, and at most 50 units of product 3. Technician A can
make only products 1 and 3. Technician B can make only products 1 and 2.
Technician C can make only product 3. Technician D can make only product 2. For
each unit produced, the products contribute the following profit: product 1, $6;
product 2, $7; product 3, $10. The time (in hours) each technician needs to
manufacture a product is shown in the following table.
Product Technician A Technician B Technician C Technician D
1
2.5
Cannot do
Cannot do
Cannot do
Cannot do
3.5
Cannot do
Cannot do
3.
4.
Each technician can work up to 120 hours per month. How can the chip
manufacturer maximize its monthly profit?
5.
Keyboards Joysticks
Profit/unit
$8
$11
$9
Labor usage/unit
.2 hour
.3 hour
.24 hour
.04 hour
Monthly demand
11,000
15,000
25,000
6.
7.
Each month, a total of 13,000 labor hours and 3,000 hours of machine time are
available. How can the manufacturer maximize its monthly profit contribution from
the plant?
8.
Resolve our drug example assuming a minimum demand of 200 units for each
drug must be met.
9.
Jason the jeweler makes diamond bracelets, necklaces, and earrings. He wants to
work at most 160 hours per month. He has 800 ounces of diamonds. The profit, labor
time, and ounces of diamonds required to produce each product are given below. If
demand for each product is unlimited, how can Jason maximize his profit?
Product
Unit Profit Labor Hours Per Unit Ounces of Diamonds Per Unit
Bracelet
$300
.35
1.2
Necklace $200
.15
.75
Earrings
.05
.5
$100