Shadow price in linear programming

Linear programming is a mathematical method for optimizing the allocation of resources — maximizing profit, minimizing cost, that kind of thing. I’ve built dozens of these models over 20+ years in operations research, and one concept I lean on constantly, and that clients almost never intuit on their own, is the shadow price: what a change in one constraint does to your optimal solution.

shadow price linear programming

What is the shadow price

Here’s the plain-English version I give people before I show them any math: the shadow price is how much your optimal objective value would improve if you got one more unit of whatever a constraint is limiting. Let’s work through the textbook version first, then I’ll give you one that hits closer to home.

the shadow price is the amount the objective function improves when we get an extra unit of the resource represented by the constraint

Say you’re running a factory that makes two products, A and B, and you’re boxed in by labor, materials, and machine time. You want to maximize profit subject to those three constraints. I’d set this up as a linear programming problem like this:

Maximize P = 5A + 4B

Subject to:

  • 2A + 3B ≤ 12 (labor constraint)
  • A + 2B ≤ 8 (materials constraint)
  • A + B ≤ 5 (machine time constraint)

P is total profit from A and B, and the three constraints are how much labor, materials, and machine time you actually have. A and B are the decision variables — how many units of each you should produce to squeeze the most profit out of what you’ve got.

Shadow Price Linear Programming: Solving with Excel Solver

I formulated the problem above in Excel with this layout (one way to do it — not the only way, and probably not the most elegant one):

shadow price excel

Row two holds the decision variables at their optimal values (A=5, B=0). Row three is the objective function. Rows four, five, and six are the three constraints.

And here’s the setup in the Excel Solver menu that matches that layout:

shadow price solver

Ask for a Sensitivity Analysis report and solve, and you get this on a separate sheet:

shadow price sensitivity analysis

The bottom row shows that for cell $A$6 — the third constraint, machine time — the shadow price is 5. Get one more unit of machine time and your objective function climbs by 5. That’s it. That’s the whole idea, expressed as a number Excel just handed you for free.

The shadow price is the maximum that we should be willing to pay for an extra unit of recources in that constraint

A shadow price example that isn’t a factory

Factories and widgets make the math clean, but they make the concept feel abstract. So here’s the version I actually think about, because I run into it in my own tradeline business on this site.

Every card I hold has a credit limit, and that limit is a hard constraint on how much tradeline capacity I can sell off of it each cycle. Say a card sits at a $9,000 limit and, at that limit, it’s fully spoken for — every dollar of headroom is doing work, the constraint is binding. Now suppose I could push that card to a $10,000 limit for free. If crossing that $1,000 threshold bumps the card into the next payout bracket with a broker, the shadow price of that credit line isn’t some abstract “5” from a sensitivity report — it’s a real number of dollars per cycle, and it tells me exactly how much I should be willing to spend (an annual fee, a bit of extra spend to justify a credit-line-increase request) to get that extra $1,000.

Now compare that to a card that’s sitting at its limit but where nudging the limit up wouldn’t change what I earn from it at all — maybe it’s already past every payout bracket that matters, or I’m not placing it anywhere near capacity. That card’s shadow price is zero. Not because the constraint isn’t real, but because it isn’t the thing actually holding my results back. That’s precisely the “non-boundary constraint” idea from the factory example, just wearing a hoodie instead of a suit: it tells you where to spend your next dollar of effort, and just as usefully, where not to.

Conclusion

The shadow price tells you how sensitive your optimal solution is to a change in any given constraint. It’s never negative — giving yourself more of a resource can only help the objective function or leave it unchanged, never hurt it. But it’s often zero, like the first two constraints in the factory example above. A zero shadow price means don’t bother paying for more of that resource: the constraint isn’t the one binding your outcome, so relaxing it buys you nothing.

Solving these in a spreadsheet has limits — literally; here’s the time Excel ran out of resources on me.

Tradeline Supply
Things that I use, like, and am affiliated with:
Mint Mobile offers great cell phone service for $15 flat, get $15 off using the link. Get discounted phones with service activation and no contract.
I never spend money before I check Mr Rebates or Rakuten to get cashbacks, rebates, discounts, coupons or cheaper gift cards.

Leave a Reply