Skip to main content

Cost model

The cost model the optimizer minimizes: holding cost + shortage cost = expected total cost.

The two cost components

AInventory's optimizer minimizes a cost function with two terms:

Expected total cost = E[Holding] + E[Shortage]

Both are calculated as averages over all Monte Carlo scenarios for a SKU.

Holding (cost of carrying inventory)

Holding captures the cost of having units in stock that did not sell:

Holding = (Σ_{h=1}^{W} inv_end[h]) × storage_rate

The storage rate is the cost per unit per period of carrying inventory (including the cost of tied-up capital, physical space, and obsolescence risk). The sum of ending inventories over the W horizons of the window penalizes accumulated excess: the more surplus stock held for longer, the higher the holding cost.

Shortage (cost of stockout)

Shortage captures the cost of being unable to fulfill demand:

Shortage = unserved_units × shortage_penalty

The shortage penalty reflects the unit cost of not having inventory when it is needed: lost sales, contractual penalties, emergency replenishment, or damage to the customer relationship. In most contexts, the shortage penalty far exceeds the storage rate — sometimes by an order of magnitude — which leads the optimizer to favor high service levels.

Why there is no ordering cost

The model does not include an ordering cost (setup cost or fixed cost per order). In practice, most product categories in AInventory have marginal or zero ordering costs (electronic purchase orders, established supplier relationships). The only constraint on order size is the MOQ (Minimum Order Quantity): if the computed Q is smaller than the supplier's MOQ, it is rounded up to the MOQ.

Implication of the no-ordering-cost model

Without an ordering cost, the model never has an incentive to place large orders to "make the trip worthwhile"; the only brake is the MOQ. This means the optimal order size genuinely reflects the needed coverage without distortions from artificial economies of scale.

The total cost vs k curve

For policies that use the k factor, the optimizer evaluates each value in the k grid and computes the corresponding expected total cost. The resulting curve is U-shaped (convex) with a minimum:

  • For very low k: holding is small but shortage dominates. Stock is insufficient to cover high-demand scenarios.
  • For very high k: shortage is nearly zero but holding dominates. Stock exceeds what realistic demand can absorb.
  • At the optimal point k*: marginal increments of k no longer reduce shortage enough to offset the increase in holding.

The system identifies k* as the argmin of that curve:

k* = argmin_{k} E[holding(k) + shortage(k)]

Cost dominance as a diagnostic

The composition of total cost at the optimal k also has diagnostic value:

  • If holding dominates: the system is oversized for this SKU. The optimizer may be responding to an excessively high shortage penalty parameter, or the SKU may have a very stable demand pattern that does not justify so much buffer.
  • If shortage dominates: the system is undersized. The lead time is probably long, demand is highly volatile, or the shortage penalty does not reflect the true cost of stockouts.

Neither case is a model error: they are signals about input parameters or SKU characteristics that the planner can investigate.