ML Systems Lab Open interactive version →
Intermediate 26 min read Pricingoptimizationconstraintsprice bounds

Price Optimization Under Constraints

From a demand curve to a chosen price — with fairness, competitive, inventory, and legal constraints turning it into a constrained optimization

Once you have a demand curve and an objective, "find the best price" looks like one line of calculus: argmax over P of (P − c)·Q(P). In production it almost never is, because the unconstrained optimum is usually a price you are not allowed to ship. The real problem is a *constrained* optimization, and the constraints are where the engineering lives.


Start with the clean unconstrained problem. Given estimated demand Q(P) and cost c, maximize expected profit π(P) = (P − c)·Q(P). Set dπ/dP = 0 → this recovers the standard markup rule P* = c·|ε| / (|ε| − 1) when elasticity is constant. That P* is the textbook answer — and it is frequently outside the feasible set: too high to be fair or legal, too low to protect margin, or inconsistent with sibling products.


Then layer the constraints that make it shippable — this is the actual job. Real optimizers add: price floors/ceilings (regulatory caps, MAP agreements, brand-minimum prices); a min-margin guarantee (P ≥ c·(1 + m), never sell below a floor markup); catalog consistency (a 500ml pack can't cost more per-ml than the 1L; variants must order sensibly); capacity/inventory limits (if you can only fulfill K units, don't set a price whose Q(P) far exceeds K); and no-surge-above-X legal caps in regulated markets. Each turns the free argmax into a bounded/constrained one.


Mechanically, you handle it with bounded search or Lagrangian methods. If the constraint is a simple box (P ∈ [P_min, P_max]), clip: the constrained optimum is the unconstrained P* if it's inside the box, else the nearer boundary (profit is concave, so the best feasible price is the closest allowed one to P*). For coupled constraints (a total-inventory or catalog-consistency limit spanning many prices), use a Lagrangian: add λ·(constraint) to the objective, and λ is the *shadow price* — how much profit one more unit of slack (one more unit of inventory, one more dollar of allowed ceiling) would buy. The headline lesson: the unconstrained optimum is a starting point, not the answer, and the binding constraints — not the calculus — usually determine the shipped price.

Key points

Takeaway

Choosing a price is a constrained optimization, not a one-line argmax: the unconstrained profit-maximizer P* = c·|ε|/(|ε|−1) is a starting point that usually violates floors, ceilings, min-margin, catalog-consistency, capacity, or legal caps. Because profit is concave, box constraints resolve by clipping to the nearer boundary; coupled constraints resolve with a Lagrangian whose multiplier λ is the shadow price of relaxing the constraint. The binding constraint, not the calculus, typically determines the shipped price.

Recap

Check your understanding

Q1. Your unconstrained profit-maximizing price is $14, but a regulatory ceiling caps price at $11. Where is the best feasible price?

Q2. In a Lagrangian formulation π(P) + λ·(K − Q(P)) for an inventory limit K, select the two correct statements about the multiplier λ at the optimum.

Q3. Why is a catalog-consistency constraint (a 1L pack must not cost more per-ml than a 500ml pack) harder to handle than a simple price ceiling?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →