E-Commerce Pricing

Problem Statement

Determine the optimal sales price for the items on an e-commerce platform.

Full example scenario

A backend engineer at an e-commerce company is tasked with optimizing pricing across a range of electronics products, taking into account supply, demand, customer behavior and shipping costs. What price should be charged for each product, in order to maximize total revenue?

  • The total quantity sold of each product cannot exceed the available stock.

  • Demand for each product decreases as its price increases, following a demand-elasticity relationship: \(Q = Q_0 \times (1 - E \times (P - P_0) / P_0)\), where \(Q\) is demand, \(Q_0\) the base demand, \(P_0\) the base price, \(P\) the new price and \(E\) the price elasticity.

  • Shipping costs are deducted from revenue and vary by product size and weight: \(SC = \text{Base Shipping Cost} + (2 \times \text{Size (kg)} + 1.5 \times \text{Weight (kg)}) \times \text{units sold}\).

  • Prices must be at least 80% of the base price, to ensure profitability.

  • The catalog data can be found in e_commerce_pricing.csv, with the columns Product ID,Product Name,Stock Quantity,Base Demand,Base Price,Size (kg),Weight (kg),Base Shipping Cost,Price Elasticity.

What an optimal solution looks like

Optimal price, quantity sold and net revenue per product.

Above the 80% floor At the 80% floor Bubble size ∝ net revenue ($10K–$217K)
$0 $300 $600 $900 $1,200 0 100 200 300 400 Optimal price Demand (units) A Smartphone A $585.83 · 373.4 units $216,879 net revenue B Laptop B $1,105.00 · 164.2 units $179,854 net revenue C Tablet C $320.00 · 340.0 units $106,760 net revenue D Smartwatch D $120.00 · 140.0 units $16,380 net revenue E Camera E $409.75 · 103.1 units $41,525 net revenue F Headphones F $80.00 · 300.0 units $22,800 net revenue G Speaker G $218.29 · 141.3 units $29,716 net revenue H Monitor H $271.38 · 123.6 units $32,070 net revenue I Keyboard I $40.00 · 388.8 units $13,608 net revenue J Mouse J $24.00 · 448.0 units $9,408 net revenue

Letters match each product's initial (A = Smartphone A, B = Laptop B, ... J = Mouse J).

One product zoomed in: Smartphone A's demand and net revenue as price changes.

Base price $700 · base demand 300 units · elasticity 1.5 · shipping $5/unit.

Demand (units sold) 0 750 units Net revenue ($) $0 $220K Price ($) $ $0 $400 $700 $1,000 floor $560 optimal $585.83 base $700 demand→0 at $1,167
Demand curve (linear) Net revenue curve (parabola) Red zone = below the 80% floor (disallowed)

Demand falls in a straight line as price rises. Net revenue — (price − shipping) × demand — is the parabola underneath: its peak, at $585.83, is the optimal price. The floor at $560 sits just left of that peak, so it never actually binds for this product.

Built with Modeler

The problem above is stated as a single shot: you hand over the whole problem and get a model back. Modeler takes the other route — you start with the business question you actually have, and it works with you until the problem is pinned down, the data is in, the code runs, and the answer holds up when the problem changes.

The tabs below walk the same pricing problem through that route, one Modeler capability at a time.

Instead of writing the whole prompt up front, you start with the business question you actually have. Modeler searches the knowledge base, asks one clarifying question at a time — always the most important one first — and tells you which parts of the model are still missing. The options it offers come from examples in the knowledge base and from how similar problems are usually modeled in your industry, so you can answer with a number instead of prose.

I run pricing for our electronics storefront. I want to set the prices on our product catalog to bring in as much revenue as possible. I know if we raise prices too much we’ll lose sales, and I don’t want to drop prices too far below what we currently charge either. Can you help me build a pricing model for this?

This is a pricing/revenue-optimization problem. Before anything else I need to know exactly what “as much revenue as possible” means — plain revenue, or revenue net of some cost — because that choice changes the objective function itself, not just a constraint.

Great use case — pricing models are a classic optimization application that can deliver real business value. Let me ask a few focused questions to nail down the details before we build the specification.

Question 1: What is your primary objective — maximize total revenue (price times units sold), or maximize total profit (revenue minus costs such as cost of goods or shipping)?

  1. Revenue only — maximize the sum of price times units sold across all products, ignoring costs.

  2. Gross profit — subtract the cost of goods (unit cost) from revenue so the model avoids pricing below cost.

  3. Net profit — also account for shipping or fulfillment costs per unit sold.

Learn More:
• Backend Engineer ★★★
• Price Optimization ★☆☆

Let’s go with option 3 — net revenue, subtracting the per-unit shipping cost for each unit sold, since we don’t track a separate cost-of-goods per product. One more requirement while we’re at it: whatever price the model lands on for a product, it should never go below 80% of that product’s current base price — we don’t want to protect margin at all costs, but we don’t want the model discounting so deep that it looks like a clearance sale.

That’s the objective settled (net revenue, shipping deducted per unit sold) plus a numeric floor, volunteered before I even asked about limits. Recording both. What’s still open is the shape of the demand side — nothing yet says how units sold respond to the price we choose, and that relationship is what turns this from a bounds problem into an actual optimization.

Good, that is saved. Here’s what the specification holds so far:

  • Objective: maximize total net revenue — sum of (price − shipping cost) × units sold, across all products.

  • Constraint recorded: price ≥ 80% of base price, per product.

  • Still open: how demand responds to the price you choose.

That last piece is the most important modeling decision left, so that’s the next question — how should demand change as price moves away from each product’s base price?

Modeler updates the specification after every answer, even while it is still incomplete — so you can always see what it has understood and what it is still waiting on. A few more short rounds like this one settled the rest: a price-elasticity demand curve, no explicit price ceiling beyond where demand hits zero, no cross-product constraints, and a skip-with-warning rule for any product whose data implies non-positive demand at its base price.