Economic order quantity: a convex optimization example, solved and checked
The economic order quantity is a classic convex optimization problem. Here it is solved by a real solver (CLARABEL) and checked: every constraint, and the optimality certificate. Change the numbers below and solve your own.
Solve your own version free, no account needed
Say it or snap it
You can give ProvenDecisions this problem out loud or as a photo. The app wrote down both, solved them, and got the same checked answer as the typed version.
What the app heard: “A shop sells 1200 units a year, each order costs $50 to place and holding one unit for a year costs $3, what order size minimizes the yearly ordering plus holding cost?”

The problem
A shop sells 1200 units a year. Each order costs $50 to place and holding one unit for a year costs $3. What order size minimizes yearly ordering plus holding cost?
How the model was built
The objective as written from the problem, before the numbers are multiplied out:
- Orders a year = 1200 ÷ q. The shop sells 1200 units a year and buys q units each time it orders, so it orders 1200 ÷ q times a year (100 at a time is 12 orders; 300 at a time is 4). That is why we divide by q: larger orders mean fewer orders.
- Ordering cost = $50 × (1200 ÷ q) a year: the number of orders times $50 each.
- Average stock = q ÷ 2. Each delivery brings q units, which sell down steadily to 0 before the next one, so on average half an order is on the shelf.
- Holding cost = $3 × (q ÷ 2) a year: the average stock times $3 per unit per year. Larger orders mean more stock.
- The best order size balances the two costs; the solver's answer is below.
The model
Each line has a plain-language note on the right.
| make this as small as possible | |
| order size (units per order) is at least 0.001 |
What is being decided
There is one decision variable.
| Variable | Type | Meaning |
|---|---|---|
| q | real number | order size (units per order) |
Goal and limits
Minimize the objective subject to 1 constraint, of which 1 are simple bounds on a single variable.
Problem type
Conic (convex), complexity level 4: convex nonlinear functions such as log, exp, square roots or powers. Solved with CLARABEL at the Medium solver tier.
The answer at a glance
The optimal value of each decision, as the solver returned it.
Which constraints hold the answer in place
No constraint is binding. Changing a binding constraint changes the answer; a slack one can move a little without effect.
| # | Constraint | Value | Limit | Slack | Binding |
|---|---|---|---|---|---|
| 1 | q >= 0.001 | 200.001 | 0.001 | 200 |
Algebraic model (low level)
Decision variables, objective and every constraint written out; this is exactly what the solver receives.
Model code (cvxpy)
The same model in cvxpy, ready to run.
import cvxpy as cp
q = cp.Variable(name='q') # order size (units per order)
objective = cp.Minimize(3*q/2 + 60000/q)
constraints = [
q >= 0.00100000000000000,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='CLARABEL')
print(problem.status, problem.value)
print('q =', q.value)Solve your own
This is the model as the app reads it. Change any number and solve it in the free box on the front page (no account needed).
minimize 50*1200/q + 3*q/2
subject to
q >= 0.001
# q = order size (units per order)
# asked: the optimal order size qChecked: the app's answer matches the reference answer in our test set. Built 2026-11-10.
Related examples
Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.