What is one more oven hour worth?
Sensitivity analysis asks how the best answer changes when a number in the model changes. The most useful figure it gives is the shadow price, the value of one more unit of a limit.
A manager can use it to decide whether a second oven shift is worth paying for.
By the end of this lesson
Note
I can say how the best profit changes when a limit changes.
Key words
| Word | What it means |
|---|---|
| Sensitivity | how much an answer moves when an input moves |
| Shadow price | the extra profit from one more unit of a limit |
| Binding constraint | a limit that the best plan uses up exactly |
| Slack | the part of a limit that the best plan leaves unused |
The cells students fill in are left blank in this preview.
A shadow price values one more unit
Suppose the oven could run for 9 hours instead of 8. The baker solves the model again with the new limit and compares the two profits.
The difference is the shadow price of the oven. It says what one extra hour is worth, so it is the most the baker should pay for it.
Solve again with a 9 hour oven
docker exec jupyter python3 -c "from scipy.optimize import linprog; r = linprog([-20, -30], A_ub=[[1, 2], [3, 2]], b_ub=[9, 18]); print(-r.fun)"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Solve again with 19 kg of flour
docker exec jupyter python3 -c "from scipy.optimize import linprog; r = linprog([-20, -30], A_ub=[[1, 2], [3, 2]], b_ub=[8, 19]); print(-r.fun)"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Worked example: the two shadow prices
| Change | Best profit | Gain over 145 | Shadow price |
|---|---|---|---|
| Oven 9 hours instead of 8 | 157.5 | 12.5 | 12.5 pounds an hour |
| Flour 19 kg instead of 18 | 147.5 | 2.5 | 2.5 pounds a kilogram |
The cells students fill in are left blank in this preview.
The solver reports the shadow prices itself
You do not have to solve twice. The result of linprog holds the prices in ineqlin.marginals, one for each limit row.
The numbers come out negative because the solver minimised the negated profit. Drop the minus sign and you have the shadow prices.
Read the prices from the solver
docker exec jupyter python3 -c "from scipy.optimize import linprog; r = linprog([-20, -30], A_ub=[[1, 2], [3, 2]], b_ub=[8, 18]); print(r.ineqlin.marginals)"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
A common mistake
Warning
Many people think a shadow price holds however large the change. It holds only for small changes, while the same limits stay binding. In the bakery the oven price of 12.5 pounds is true from 6 to 18 hours and no further.
Slack means a shadow price of zero
A limit that the best plan does not use up has slack. More of it adds nothing, so its shadow price is 0.
Give the bakery a 20 hour oven and flour becomes the only real limit. The best plan is then 9 cake batches and no loaves, and the oven is never full.
Worked example: the oven price at each size
| Oven hours | Best plan | Best profit | Value of the next hour |
|---|---|---|---|
| 6 | 6 loaves, 0 cakes | 120 | 12.5 |
| 8 | 5 loaves, 1.5 cakes | 145 | 12.5 |
| 12 | 3 loaves, 4.5 cakes | 195 | 12.5 |
| 18 | 0 loaves, 9 cakes | 270 | 0 |
| 20 | 0 loaves, 9 cakes | 270 | 0 |
The cells students fill in are left blank in this preview.
Going further
Use the table and the price of 12.5 pounds to guess the best profit for an oven of 10 hours. Then check your guess by changing the limit in a command.
Explain why the guess fails for an oven of 30 hours.