Holding Cost Belongs to Time, Not Leftover Inventory
Why period-specific inventory costs must be charged against the inventory that actually exists when the cost applies, and how terminal-cost shortcuts can distort ordering decisions.
Holding Cost Belongs to Time, Not Leftover Inventory
A surprisingly common modeling mistake is to put the right cost on the wrong quantity.
Suppose you are building an ordering model over 20 weeks. Inventory is expensive to hold, so you add a carrying cost. A convenient implementation is to look at whatever inventory remains at the end of the horizon and charge an overage penalty against it.
For some purposes, that can be a reasonable approximation. It discourages the model from buying inventory it does not expect to consume.
Then the business adds another inventory-related cost. Maybe warehouse congestion becomes expensive during peak season. Maybe a temporary capacity surcharge applies in weeks 8 through 11. Maybe financing costs spike during a specific period. Maybe storage at one location becomes materially more expensive for a few weeks.
The tempting implementation is to add that cost to the same terminal inventory penalty.
That is where the model quietly stops representing the economics.
The issue is not that the cost is too large or too small. The issue is that the cost belongs to a point in time, while terminal inventory belongs to the end of the horizon.
Those are different quantities.
Start With the Decision
Before writing the cost function, define what the system actually controls.
For a basic replenishment problem, let:
- (q_t) = quantity ordered in period (t)
- (I_t) = inventory remaining at the end of period (t)
- (D_t) = demand in period (t)
- (A_t) = arrivals in period (t)
The inventory balance is:
[ I_t = I_{t-1} + A_t - D_t ]
with the appropriate treatment of lost sales, backorders, or nonnegative inventory depending on the business.
Now suppose there is an additional carrying charge (c_t) that varies by week.
The economically natural cost is:
[ \sum_t c_t I_t ]
If the surcharge applies only in weeks 8 through 11, then (c_t = 0) outside those weeks.
That sounds obvious when written down. Yet many production systems do something closer to:
[ \bar{c} I_T ]
where (I_T) is inventory at the end of the planning horizon and (\bar{c}) somehow contains the temporary surcharge.
Those formulations are not interchangeable.
Why the Terminal Shortcut Breaks
Consider two otherwise identical planning problems.
In the first, the expensive storage period occurs in week 3.
In the second, it occurs in week 18.
Assume the company starts with a large amount of inventory and gradually consumes it over the horizon.
When the surcharge occurs in week 3, a large quantity may still be sitting in the network. When it occurs in week 18, most of that inventory may already be gone.
A terminal penalty sees neither distinction. It sees only (I_T).
If both plans end with 100 units, the terminal formulation charges the same surcharge in both cases.
But the business did not experience the same cost.
The correct exposure is the inventory present during the expensive weeks.
This is the general rule:
If a cost is caused by state at time (t), charge it against state at time (t).
Do not attach a time-local cost to a convenient quantity somewhere else in the model just because that quantity already exists.
Ask What Generates the Cost
The fastest way to debug this class of problem is to stop thinking about formulas and ask what physically or economically generates the charge.
For each cost term, ask:
- What event causes money to be spent or value to be lost?
- What quantity determines the magnitude of that cost?
- When does that quantity exist?
- Does the cost depend on an action, a state, or an outcome?
- Is the cost paid once, repeatedly, or only if a threshold is crossed?
A purchase cost is generally caused by ordering units.
A transportation cost may be caused by shipments, trucks, pallets, lanes, or modes.
A warehouse carrying cost is caused by inventory occupying space over time.
An obsolescence cost may be caused by units remaining after a product transition.
A stockout cost is caused by unmet demand, not by low ending inventory.
A cash cost of capital is caused by capital being tied up over time.
These distinctions matter because they tell you what variable belongs in the objective.
State Costs and Action Costs Are Different
A useful modeling distinction is between actions and states.
Ordering 5,000 units is an action.
Having 5,000 units sitting in a warehouse three weeks later is a state.
The same order can create very different inventory trajectories depending on demand, existing inventory, lead time, other arrivals, transfers, and uncertainty.
If the economic consequence is generated by the state, pricing the action directly may be a poor approximation.
For example, suppose an order of 10,000 units arrives just before a high-cost storage window. Charging the order quantity may make sense if the surcharge is literally an inbound handling fee. It does not make sense if the surcharge is warehouse occupancy. Some of those 10,000 units may sell immediately. Other inventory from earlier orders may still occupy the warehouse.
The model should price the thing that causes the cost.
Uncertainty Makes the Distinction More Important
Under deterministic demand, you may be able to calculate the inventory path directly from a forecast.
Under uncertainty, the inventory present during a costly week is itself uncertain.
For scenario (s), let inventory be (I_{t,s}). Expected time-dependent carrying cost becomes:
[ \mathbb{E}[C] \approx \sum_s p_s \sum_t c_t I_{t,s} ]
where (p_s) is the probability or simulation weight of scenario (s).
Now the ordering policy is being evaluated against the inventory trajectories it actually creates.
This matters because two policies with similar expected ending inventory can have very different paths.
One may buy early and carry substantial stock through the expensive period. Another may delay replenishment, accept more stockout exposure, and avoid the surcharge. A third may shift inventory to another location.
The right choice depends on the complete economics, not on ending inventory alone.
The Cost Can Change the Optimal Policy
Suppose a buyer can order either 10,000 units today or wait four weeks.
Ordering today may provide:
- lower purchase cost,
- lower stockout risk,
- better MOQ economics,
- more protection against lead-time uncertainty.
But it may also create:
- four additional weeks of holding cost,
- peak-season storage exposure,
- working-capital cost,
- obsolescence risk.
This is why the cost should not be treated as a reporting adjustment after the optimization runs.
If the cost is material enough to change the preferred action, it belongs in the decision logic.
The optimization problem is choosing among economic tradeoffs. Hiding one of those tradeoffs in a post-processing calculation means the solver never gets to make the actual decision.
Constraints Still Matter
Correctly modeling the cost does not mean the model can freely avoid it.
Real ordering systems operate under constraints such as:
- minimum order quantities,
- case packs,
- vendor calendars,
- lead times,
- warehouse capacity,
- supplier capacity,
- transportation schedules,
- purchase budgets,
- contractual commitments,
- shelf-life restrictions,
- fixed order costs.
Suppose storage is expensive in week 10. The model might prefer to postpone an order until week 11, but a six-week lead time makes that impossible. Or the vendor may require a 20,000-unit MOQ, forcing the company to hold more inventory than it economically prefers.
That is not a modeling failure.
That is exactly the tradeoff the model is supposed to expose.
A useful output is not merely, “storage cost increased by $42,000.” It is, “the model incurred $42,000 because avoiding it would have required violating the MOQ or accepting $71,000 of expected lost margin.”
Now you have a decision explanation.
Terminal Costs Still Have a Purpose
None of this means terminal costs are bad.
Finite-horizon models have a real problem: the world does not end when the optimization horizon ends.
If a 26-week model assigns no value or cost to inventory remaining after week 26, it may make absurd decisions near the boundary. It can overbuy because future holding cost is invisible, or underbuy because future demand is invisible.
A terminal value function or terminal inventory penalty is one way to approximate what happens beyond the modeled horizon.
That is a legitimate role.
But terminal value and within-horizon operating cost solve different problems.
A useful decomposition is:
[ \text{Total Cost}
\text{Action Costs} + \text{Within-Horizon State Costs} + \text{Outcome Costs} + \text{Terminal Value} ]
Keep those concepts separate even if the final objective is one scalar number.
A Practical Modeling Pattern
For a production replenishment model, I generally want the objective to make the economics visible.
Conceptually:
[ \max \quad \text{Expected Margin}
\text{Purchase Cost}
\text{Logistics Cost}
\text{Holding Cost}
\text{Stockout Cost}
\text{Other State-Dependent Costs} + \text{Terminal Value} ]
For inventory-related costs, define a period-specific coefficient:
[ h_t = h_t^{normal} + h_t^{special} ]
and charge:
[ \sum_t h_t I_t ]
If the special cost applies only to selected periods, simply set the special component to zero elsewhere.
If it applies only above a capacity threshold, model the excess explicitly. For example:
[ E_t \ge I_t - K_t ]
[ E_t \ge 0 ]
and charge the surcharge against (E_t), not all inventory.
That distinction can be economically important. A warehouse congestion fee caused only by inventory above 50,000 units should not penalize the first 50,000 units unless the business actually pays that way.
If the Exact State Is Expensive to Model
Sometimes the planning engine does not expose weekly inventory cleanly. Maybe the existing optimization was designed around aggregate horizon quantities. Maybe adding state variables would materially increase model size. Maybe the cost is being introduced into a legacy system where changing the mathematical core is risky.
Then approximation may be reasonable.
But approximation should be deliberate.
One practical approach is to reconstruct expected inventory during the active cost window from starting inventory, scheduled arrivals, candidate orders, and cumulative demand.
For example:
[ \hat I_t = I_0 + \sum_{\tau \le t} A_\tau - \sum_{\tau \le t} \hat D_\tau ]
and evaluate the special cost using (\hat I_t) only in the periods where it applies.
This is still an approximation, especially under uncertainty, but it preserves the most important causal relationship: the cost is tied to inventory during the relevant weeks.
That is usually much better than smearing the cost into a terminal leftover penalty.
Evaluate the Policy in Simulation
If the ordering logic is deployed repeatedly, do not stop at the deterministic optimization objective.
Replay the policy under realistic demand and lead-time paths.
Track at least:
- realized profit,
- average and percentile inventory by week,
- units exposed to the special cost,
- total holding and surcharge cost,
- lost sales or backorders,
- order frequency,
- order quantity distribution,
- capacity violations or near-violations,
- ending inventory,
- decision stability across replans.
The key comparison is between policies, not isolated model outputs.
Maybe adding the time-dependent cost reduces average inventory by 8% but increases stockouts dramatically. Maybe it changes only the timing of orders and preserves service. Maybe the effect is concentrated in 3% of SKUs. Maybe the entire cost term is economically irrelevant once MOQs are considered.
Simulation tells you whether the new logic actually changes decisions and whether those changes survive uncertainty.
Common Failure Modes
Charging the wrong quantity
The cost applies to inventory in week 10, but the model charges ending inventory in week 20.
Double counting
A temporary surcharge is added to a standard carrying-cost coefficient even though the accounting estimate already includes it.
Treating an accounting allocation as marginal economics
Finance reports a warehouse cost of $0.40 per unit per week, but most of that cost is fixed. Reducing one unit of inventory does not actually save $0.40.
Optimization needs the cost that changes with the decision.
Ignoring thresholds
The cost exists only above capacity, but the model charges every unit.
Using average inventory when timing matters
Two policies have the same average inventory but radically different exposure during the costly period.
Forgetting uncertainty
Expected demand produces a smooth inventory path that never occurs in reality. The expensive tail scenarios are exactly where congestion or emergency storage costs appear.
Optimizing the metric instead of the economics
The team sees inventory turns deteriorate and adds a large inventory penalty until turns improve. The model then destroys profitable availability to satisfy a reporting target.
A metric is evidence about the system. It is not automatically an objective function.
What to Do in Practice
When someone asks you to add a new cost to an optimization model, do not start by looking for the easiest place in the objective to put the coefficient.
Start with the physical story.
Write down:
- what decision creates exposure,
- what state determines the charge,
- when the charge occurs,
- whether the cost is marginal or allocated,
- whether it applies to all units or only excess units,
- how uncertainty changes exposure,
- what operational constraints prevent the model from avoiding it.
Then build the smallest formulation that preserves that causal structure.
Finally, test the resulting policy in simulation and inspect why orders changed.
A mathematically valid cost term can still represent the wrong economics.
The objective is not to make every business cost appear somewhere in the solver. The objective is to make the solver face the same tradeoffs the business actually faces.