Skip to main content

Inventory & Lot Sizing

Inventory Models & Production Planning

Classical and modern inventory management models covering economic order quantities, dynamic lot sizing, multi-echelon systems, and safety stock optimization. These foundational models underpin modern inventory management, production planning, and ERP systems.

6
Problems
139
Tests
11
Algorithms

EOQ → Dynamic Lot Sizing → Capacitated Lot Sizing → Multi-Echelon → Safety Stock → Vehicle Loading

  View on GitHub

Problem Collection

Six inventory, production planning, and logistics models

Economic Order Quantity

EOQ — Classic, Backorder, Quantity Discounts — 18 Tests

The foundational inventory model determining the optimal order quantity that minimizes total holding and ordering costs. Includes extensions for planned backorders (allowing stockouts with a penalty cost) and quantity discounts (all-units and incremental).

Classic EOQ:
Q* = √(2DK / h)    TC(Q) = DK/Q + hQ/2

EOQ with Backorders (shortage cost b per unit/yr):
Q* = √(2DK/h) · √((h+b)/b)    S* = Q*·b/(h+b)
TC = DK/Q + h(Q−S)²/(2Q) + bS²/(2Q)

Quantity Discounts (all-units price breaks):
Evaluate Q* at each price tier; select tier with lowest TC(Q) = Dc + DK/Q + hQ/2
D = annual demand, K = order cost, h = holding cost/unit/yr, b = backorder cost/unit/yr, c = unit price
Retail Warehousing E-Commerce
AlgorithmTypeComplexityDetails
EOQ Formula Exact O(1) Classic closed-form with backorder & discount extensions — Harris (1913)
View Source Code

Dynamic Lot Sizing

Wagner-Whitin (Exact) & Heuristic Methods — 31 Tests

Determine production/order quantities over a finite planning horizon with time-varying demand. Wagner-Whitin provides the optimal DP solution; Silver-Meal and Part Period Balancing offer fast heuristic alternatives for large-scale instances.

f(0) = 0
f(t) = min_{1 ≤ s ≤ t} { f(s-1) + K + h · ∑_{k=s}^{t} (k-s) · d_k }
Zero-inventory property: it is optimal to order only when inventory reaches zero
Manufacturing MRP Systems Procurement
AlgorithmTypeComplexityDetails
Wagner-Whitin DP Exact O(T²) Optimal forward DP exploiting zero-inventory ordering — Wagner & Whitin (1958)
Silver-Meal Heuristic O(T²) Minimize average cost per period; performs well on smooth demand — Silver & Meal (1973)
Part Period Balancing Heuristic O(T²) Order until cumulative holding cost ≈ setup cost — DeMatteis (1968)
View Source Code

Capacitated Lot Sizing

CLSP — NP-hard — 47 Tests

Extension of dynamic lot sizing with production capacity constraints per period. The capacity constraint makes the problem NP-hard (Bitran & Yanasse, 1982), requiring heuristic approaches. Models realistic manufacturing settings where production resources are limited.

min ∑_t (K_t · y_t + v_t · x_t + h_t · I_t)
s.t. I_{t-1} + x_t = d_t + I_t   ∀t
     x_t ≤ C_t · y_t   ∀t
     x_t, I_t ≥ 0,   y_t ∈ {0,1}
Manufacturing Production Planning ERP Systems
AlgorithmTypeComplexityDetails
MIP Solver (HiGHS) Exact NP-hard Standard ILP formulation via SciPy HiGHS — Pochet & Wolsey (2006)
Greedy Lookahead Heuristic O(T²) Forward pass consolidating future demand up to capacity — Pochet & Wolsey (2006)
Lot-for-Lot + Forward Greedy Heuristic O(T²) Baseline lot-for-lot with greedy capacity-aware merging — Maes & Van Wassenhove (1988)
View Source Code

Multi-Echelon Inventory

Serial & Distribution Systems — 17 Tests

Inventory management across multiple levels of a supply chain (e.g., warehouse to distribution center to retail). Optimizes base-stock levels considering lead times, demand variability, and inter-echelon dependencies for system-wide cost minimization.

Distribution Networks Spare Parts Hospital Supply Chains
AlgorithmTypeComplexityDetails
Echelon Base Stock Exact* O(L) Optimal for serial systems with backlogging — Clark & Scarf (1960)
Greedy Allocation Heuristic O(L²) Marginal cost allocation across echelons — Roundy (1985)

*Echelon base-stock is optimal for serial systems (Clark & Scarf, 1960); treated as heuristic for general distribution networks.

View Source Code

Safety Stock Optimization

Analytical & Simulation-Based — 14 Tests

Determine optimal safety stock levels to buffer against demand uncertainty while meeting target service levels. Supports continuous review (Q, R) and periodic review (s, S) policies with normal demand distributions.

Cycle Service Level (CSL):
SS = z_α · σ_D · √L
Assumes: normally distributed demand per period, constant lead time L. z_α = Φ¹(α) where α is the target CSL. Fill rate requires the standard normal loss function L(z), not this formula.
Retail Replenishment E-Commerce Fulfillment Spare Parts
AlgorithmTypeComplexityDetails
Analytical Safety Stock Analytical O(1) Closed-form normal-approximation for cycle service level targets
View Source Code

Vehicle / Container Loading

2D Bin Packing (Weight + Volume) — NP-hard — 12 Tests

Pack items with both weight and volume constraints into vehicles with limited weight and volume capacities, minimizing the number of vehicles used. Generalizes 1D bin packing to two resource dimensions.

Logistics Container Shipping Trucking
AlgorithmTypeComplexityDetails
First-Fit Decreasing (FFD) Heuristic O(n²) Sort by weight descending, first-fit placement — Johnson (1973)
View Source Code

Algorithm Overview

Method distribution across the inventory & lot sizing family

ProblemExact / AnalyticalHeuristic
EOQ EOQ Formula
Dynamic Lot Sizing Wagner-Whitin DP Silver-Meal PPB
Capacitated Lot Sizing MIP Greedy Lookahead Lot-for-Lot
Multi-Echelon Base Stock* Greedy Alloc.
Safety Stock Analytical
Vehicle Loading FFD

Try It Yourself

Interactive EOQ solver with cost curve visualization

EOQ Solver

Classic EOQ
EOQ with Backorders

Lot Sizing Solver

Enter period-by-period demands to compare Wagner-Whitin (optimal DP), Silver-Meal, and Part Period Balancing side by side.

Benchmark Instances

Standard test instances used across the family

ProblemInstanceSizeSource
EOQ Classic / Backorder / Discount Analytical (closed-form) Harris (1913), textbook standard
Dynamic Lot Sizing Wagner-Whitin 4-period / 6-period / 10-period T = 4–10 Wagner & Whitin (1958)
CLSP tight_6 / loose_4 / variable_8 T = 4–8 Trigeiro et al. (1989) style
Multi-Echelon 2-echelon serial / 3-echelon distribution L = 2–4 stages Clark & Scarf (1960) style
Safety Stock Normal demand / CSL targets Analytical Silver, Pyke & Peterson (1998)
Vehicle Loading 2D weight+volume instances n = 10–20 items Christensen et al. (2017) style
  Portfolio
ESC