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
- The unconstrained problem is argmax over P of (P − c)·Q(P). With constant elasticity this gives the markup rule P* = c·|ε|/(|ε| − 1). That P* is the textbook answer and is frequently outside the feasible set — too high, too low, or inconsistent with sibling SKUs.
- Constraints are the real job: floors/ceilings, min-margin, catalog consistency, capacity, legal caps. A min-margin guarantee (P ≥ c·(1+m)), a per-unit consistency rule across pack sizes, an inventory limit K, and regulatory no-surge caps each shrink the feasible region — and the binding one usually sets the shipped price.
- For box constraints, clip to the boundary. Profit is concave in P, so if the unconstrained P* violates [P_min, P_max], the best feasible price is the nearer boundary — not an interior compromise. Moving toward P* is always improving until you hit the wall.
- For coupled constraints, use a Lagrangian and read λ as a shadow price. Adding λ·(constraint) to the objective, λ tells you the marginal profit of relaxing the constraint by one unit — the value of one more unit of inventory or one more dollar of allowed ceiling. It converts "what's the price" into "what's the constraint worth."
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
- Unconstrained problem: argmax over P of (P − c)·Q(P). Constant elasticity → markup rule P* = c·|ε|/(|ε| − 1). This P* is a starting point, not the shipped price.
- Constraints are the real job: price floors/ceilings, min-margin (P ≥ c·(1+m)), catalog consistency across pack sizes, capacity/inventory K, and legal no-surge caps. The binding one usually sets the price.
- Box constraints → clip to the boundary: profit is concave in P, so a violated optimum resolves to the nearer allowed bound, never an interior compromise.
- Coupled constraints → Lagrangian: add λ·(constraint); λ is the shadow price — the marginal profit of relaxing the constraint by one unit (one more unit of inventory, one more dollar of ceiling).
- Headline: the unconstrained optimum is where you start; the binding constraint — not the calculus — is usually what determines the price you actually ship.
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?
- A) At $11 — profit is concave, so on [P_min, $11] profit keeps rising toward $14, making the nearest allowed price to the optimum best.
- B) At the midpoint $12.50, since regulatory caps are conventionally split evenly between the unconstrained optimum and the legal ceiling.
- C) At $14 — a regulatory ceiling only restricts the price for tax-reporting purposes, not the price actually charged to customers.
- D) At P_min — a binding ceiling on one side of the price range always forces the optimum to jump to the opposite boundary instead.
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.
- A) λ is the shadow price of capacity: the marginal profit gained from one additional unit of available inventory.
- B) λ equals zero whenever the capacity constraint is slack rather than actively binding at the chosen price.
- C) λ is always numerically equal to the price elasticity of demand evaluated at the optimal price.
- D) λ represents the statistical probability that the constraint gets violated once the pricing model is deployed.
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?
- A) It isn't harder — catalog consistency is just another independent box constraint applied separately to each SKU's own price, with no coupling at all.
- B) It couples multiple prices together into one joint constraint across variants, requiring a Lagrangian instead of per-item clipping.
- C) Consistency constraints make the profit function non-concave everywhere, so no feasible pricing optimum can ever be found.
- D) It requires estimating a completely separate demand curve for every milliliter of product, which is statistically infeasible.
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 →