Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Sensitivity Analysis: What Is One More Hour Worth?

Open In Colab

Sensitivity Analysis: What Is One More Hour Worth?

Last week the solver found the best weekly plan of Qahwa House’s central kitchen: 40 batches of House Blend, 4 of Yemeni Haraz, 17 of Date Maamoul and no Saffron Cake, for 53,900 SAR a week. The roaster and the staff were binding; the oven had 6 hours to spare.

That plan rests on numbers that are estimates (contributions, demand) or that money can change (hours). A manager rarely asks only “what is the best plan?”. The next questions are: what would one more hour of the roaster be worth? How far can a price move before the plan changes? Which of the offers on my desk should I take? Answering them is sensitivity analysis, and an LP answers them almost for free.

This month the manager has four offers: a second roaster shift, staff overtime, hours on a neighbour’s oven, and a campaign to sell more House Blend. We will value each of them, and find that the most obvious way to do it ranks them wrongly.

After this reading you can:

  • define a shadow price and find it both by re-solving and from PuLP (constraint.pi);

  • explain why a constraint with slack has a shadow price of zero;

  • find the range over which a shadow price holds with a parameter sweep, and explain why it stops;

  • read reduced costs (variable.dj) and price out a product against the shadow prices;

  • find how far a contribution can move before the plan changes;

  • explain the dual: the shadow prices as a price list for the kitchen’s resources;

  • value a set of offers by re-solving the model, not by multiplying a shadow price.

Textbook: Albright & Winston, Business Analytics: Data Analysis and Decision Making, Chapter 13 (sensitivity analysis).

Setup

The first cell installs PuLP when you are in Colab; on your own computer, install it once with pip install "pulp[highs]>=4.3,<5". PuLP 4 needs a solver named explicitly; the course uses HiGHS (free, open source, installed by pulp[highs]), which also reports the shadow prices and reduced costs used here.

Loading...

Each product’s contribution_sar per batch, the hours of the roaster, the oven and the staff one batch uses, and max_batches, the most the branches can sell in a week. The kitchen has 50 roaster hours, 40 oven hours and 160 staff hours a week.

1. The model as a function

We will solve the same model dozens of times with one number changed, so we wrap week 9’s model in a function. Besides the plan, it returns what the solver knows about each constraint and each variable once the LP is solved:

  • constraint.slack: the unused part of the resource;

  • constraint.pi: the shadow price of the constraint (section 2);

  • variable.dj: the reduced cost of the variable (section 4).

Running HiGHS 1.16.0 (git hash: f3f113d): Copyright (c) 2026 under MIT licence terms
Includes third-party software components, see THIRD_PARTY_NOTICES.md for full details
Optimal · 53,900 SAR a week
House Blend     40.0
Yemeni Haraz     4.0
Date Maamoul    17.0
Saffron Cake     0.0
Loading...

The base plan is week 9’s: 40, 4, 17 and 0 batches, 53,900 SAR. The roaster and the staff have no slack; the oven has 6 hours. (The + 0.0 turns the solver’s “−0” into a plain 0.)

2. Shadow prices: what one more hour is worth

The simplest sensitivity question: what if we had one more hour? Give the kitchen one more hour of each resource in turn, re-solve, and compare the profit.

Loading...

One more roaster hour adds 390 SAR, one more staff hour 175 SAR, one more oven hour nothing. The solver reports the same numbers without re-solving: they are the constraints’ shadow prices (also called dual values or dual prices).

Shadow price of a constraint: the change in the optimal objective when the constraint’s right-hand side rises by one unit, all other numbers fixed.

It is the most a manager should pay for one more unit of the resource. A roaster hour that costs less than 390 SAR is worth buying; one that costs more is not.

Slack means a zero price. The oven already has 6 idle hours, so a seventh changes nothing. This is a general rule, called complementary slackness: a constraint with slack has a shadow price of 0, and a constraint with a positive shadow price is binding. Never pay for more of a resource you are not using up.

Where the 390 comes from

Why 390, when an hour of roaster earns 900 SAR on House Blend and 600 on Yemeni Haraz? Compare the two plans:

Loading...

House Blend is already at its demand limit, so the extra hour goes to Yemeni Haraz: +0.4 batch, worth +600 SAR. But 0.4 batch of Yemeni needs 1.2 staff hours, and the staff is fully used, so the solver takes them from Date Maamoul: −0.3 batch, −210 SAR. Net: 600 − 210 = 390 SAR.

A shadow price is not the profit of any single product: it includes every knock-on change the extra hour causes in the best plan. That is why only the model can compute it.

3. How far does a shadow price hold?

A shadow price is a rate, valid for small changes. If 1 roaster hour adds 390 SAR, do 30 hours add 30 × 390? Only if the plan keeps adjusting the same way. A parameter sweep answers it: solve the model for many values of one number and watch the profit.

Loading...

Each extra staff hour is worth 175 SAR up to 172 hours. The 173rd is worth only 105 SAR. What happened at 172 hours? The extra staff hours were baking more Date Maamoul, 0.25 batch an hour, and at 172 hours the plan makes 20 batches, which need all 40 oven hours. The oven has become a second binding constraint. From then on an extra staff hour can only shift baking from Date Maamoul to Saffron Cake, which uses less oven time but earns less, so it is worth 105 SAR. Beyond 232 hours Saffron Cake reaches its demand limit of 30 batches and more staff is worth nothing.

<Figure size 1000x600 with 4 Axes>

The profit is a piecewise linear curve of each capacity: straight while the same constraints bind, bending at each point where another constraint becomes binding or a variable reaches a limit. The shadow price is the slope of the current piece, so it drops in steps as the resource becomes less scarce. (Each kink is a degenerate point where the solver may report either neighbouring slope; between kinks the reported price is exact.)

The roaster’s price holds much longer: 390 SAR an hour from 40 to 80 hours. At 80 hours Yemeni Haraz reaches its demand limit of 16 batches and further roaster hours have nothing to roast. Below 40 hours House Blend can no longer fill its demand and each lost hour costs 690 SAR.

ResourceShadow price this weekHolds fromtoWhy it stops
roaster390 SAR/h40 h80 hbelow: House Blend leaves its limit; above: Yemeni Haraz reaches 16
staff175 SAR/h92 h172 hbelow: Date Maamoul reaches 0; above: the oven fills up
oven034 hno limitbelow 34 h the oven would bind

Spreadsheet solvers print these ranges in a sensitivity report (“allowable increase” and “allowable decrease”). PuLP does not, but a sweep shows the same thing and also what happens beyond the range.

4. Reduced costs: pricing out the products

Shadow prices put a value on each hour. With them we can price out each product: what are the hours it uses worth in the best plan, and does its contribution cover them?

Loading...
  • Yemeni Haraz and Date Maamoul are made in between their limits, and their contribution exactly equals the value of their hours (2.5 × 390 + 3 × 175 = 1,500; 4 × 175 = 700). In an optimal plan, every product made “in between” breaks even at the shadow prices.

  • Saffron Cake uses 4 staff hours, which are worth 4 × 175 = 700 SAR as Date Maamoul, but it brings only 560. Its reduced cost is −140: each batch forced into the plan would cost 140 SAR of profit. It needs at least 140 SAR more contribution per batch, 700 SAR, to be worth making.

  • House Blend earns 160 SAR more than its hours are worth (reduced cost +160). It is held back only by its demand limit of 40 batches, so each extra batch the branches could sell would add 160 SAR.

The reduced cost (variable.dj) of a variable is this difference: how much the objective would change per unit if the variable were pushed away from its bound.

The branches’ proposal: cut the price of Saffron Cake

The branches suggest a 10% price cut on Saffron Cake (960 → 864 SAR a batch) so that they can sell 40 batches a week instead of 30. The reduced cost answers before we solve anything: Saffron Cake is already not worth making, and a lower price makes it worse; more demand for something we do not make is worth nothing. Let us confirm:

profit 53,900 SAR · Saffron Cake batches 0

Nothing changes: 53,900 SAR, still no Saffron Cake. Saffron Cake would enter the plan only if its contribution rose above 700 SAR, a price above 1,100 SAR a batch.

How far can a contribution move?

The same idea for every product: how far can its contribution move before the best plan changes? We sweep each contribution and keep the values for which this week’s plan (40, 4, 17 and 0) is still a best plan. At the edge of a range two plans tie for the best profit, and the solver may return either of them, so we do not ask which plan the solver returns: we ask whether this week’s plan still earns the best profit.

Loading...

Read the table with the grid in mind (0 to 2,500 SAR in steps of 5): an edge at 0 or 2,500 means “no limit in this direction”.

ProductNowThis week’s plan stays a best plan for a contribution of
House Blend900at least 740its hours are worth 390 + 2 × 175 = 740; above that, no limit: it is already at its demand
Yemeni Haraz1,500525 to 1,900below 525 its 3 staff hours earn more as pastry; above 1,900 it displaces House Blend
Date Maamoul700560 to 1,500below 560 Saffron Cake takes its place; above 1,500 it takes hours from House Blend
Saffron Cake560up to 700at 700 it ties with Date Maamoul and enters above it

Inside its range a contribution can change and the plan stays the same, although the profit changes by (batches × change). A wide range means the plan is robust to errors in that estimate: Yemeni Haraz’s contribution could be off by several hundred riyals and the manager would still make 4 batches. A narrow range means the estimate deserves a second look.

5. The four offers

Now the manager’s question. Each offer adds hours (or demand) for a weekly cost:

Loading...

The quick way to value an offer multiplies the shadow price by the amount. For the House Blend campaign the “shadow price” of its demand limit is House Blend’s reduced cost, 160 SAR a batch. The careful way re-solves the model with the offer included.

Loading...

By the shadow price, staff overtime looks like the best offer: 24 hours × 175 SAR = 4,200 SAR for 3,120, a net +1,080 SAR a week. Re-solving says it earns only +240: the 175 SAR price holds for the first 12 hours (up to 172), and the other 12 are worth 105 SAR each, less than the 130 SAR they cost. The roaster shift (+900) stays inside its range (50 + 10 = 60 ≤ 80 hours), so for it the quick estimate is exact. The oven rental buys hours that nobody uses (−400 SAR). The campaign earns a modest +200.

<Figure size 800x360 with 1 Axes>

How many overtime hours?

Overtime can be bought by the hour. Each hour inside the range earns 175 − 130 = 45 SAR; each hour beyond it loses 130 − 105 = 25 SAR. The sweep finds the best amount:

best: 12 overtime hours, net +540 SAR a week; all 24 hours: +240 SAR

Alone, the kitchen should buy 12 overtime hours (+540 SAR a week), not 24.

6. Offers interact

A shadow price answers a question about one number with everything else fixed. When the manager takes two offers at once, the plan moves in two directions, and the ranges move too. With 4 offers there are 2⁴ = 16 combinations; the model is fast, so we try them all.

Loading...

The best combination is the roaster shift + overtime + campaign: +2,180 SAR a week. The roaster shift and the overtime together earn +1,980, much more than their separate gains (900 + 240 = 1,140). Why?

  • The roaster shift makes 4 more batches of Yemeni Haraz (8 instead of 4), which take 12 staff hours from Date Maamoul (14 batches instead of 17).

  • That frees 6 oven hours, so Date Maamoul can now grow by 6 batches before the oven fills. The staff’s 175 SAR range now runs up to 184 hours, and all 24 overtime hours earn 175 SAR.

The two offers are complements: each makes the other more valuable. A shadow price cannot see that; re-solving can. The oven rental helps in one case only: with the overtime and without the roaster shift, it lets the extra staff hours keep baking Date Maamoul (overtime + oven nets +680). Once the roaster shift is in, the oven has room again and the rental adds nothing.

7. The dual: a price list for the kitchen

Collect the shadow prices into a price list: roaster 390, oven 0, staff 175 SAR an hour, and 160 SAR for each batch of House Blend demand (its reduced cost; the other products’ demand limits are not binding, so they are worth 0). Now value everything the kitchen has at those prices:

hours: 47,500 SAR + House Blend demand: 6,400 SAR = 53,900 SAR

50 × 390 + 40 × 0 + 160 × 175 + 40 × 160 = 53,900 SAR, exactly the best weekly profit. This is no coincidence. Imagine an outside company that wants to rent the whole kitchen for a week: every hour and every unit of demand. It must offer prices high enough that, for each product, the hours and demand that product uses are worth at least its contribution; otherwise the manager would rather make the product. The rent it pays is the price list times the quantities, and it looks for the cheapest acceptable price list. That is another LP, the dual of the kitchen’s LP:

Optimal · cheapest rent: 53,900 SAR
price_roast_h 390.0 price_oven_h 0.0 price_labour_h 175.0 demand_House_Blend 160.0 demand_Yemeni_Haraz 0.0 demand_Date_Maamoul 0.0 demand_Saffron_Cake 0.0 dtype: float64

The cheapest rent is 53,900 SAR, and the prices it sets are the shadow prices. Every LP has such a twin, its dual, and at the optimum the two objectives are equal (strong duality). The variables of the dual are the shadow prices of the original. You will rarely solve a dual by hand; the idea to keep is that shadow prices are the prices at which the kitchen’s resources are exactly worth what they earn.

8. Cautions

  • One number at a time, within its range. A shadow price or a reduced cost describes a small change of one number. For larger changes or several at once, re-solve (sections 3 and 6).

  • Linear programs only. Shadow prices come from the continuous LP. With whole batches (integer variables, week 12) there are no shadow prices; re-solving still works. Here, the whole-batch model happens to give the same values for these offers.

  • Degenerate points. Exactly at a kink, as at 172 staff hours, the solver may report either neighbouring price. If a shadow price matters to a decision, check it by re-solving with a little more and a little less.

  • The model’s own numbers are estimates. Sensitivity analysis tells you which estimates matter: those with narrow ranges. Simulation (week 14) lets them vary together.

Check your understanding

  1. The oven’s shadow price is 0. Explain why, and what that says about the oven rental offer.

  2. The roaster’s shadow price is 390 SAR an hour. How much would 20 more roaster hours add, and how do you know?

  3. Saffron Cake’s reduced cost is −140. What does that mean for the branches’ price-cut proposal?

  4. Why does the overtime look better than the roaster shift when valued by shadow prices, and worse when re-solved?

  5. Why are the roaster shift and the overtime worth more together than separately?