algo-sc-eoq

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Economic Order Quantity (EOQ)

经济订货批量(EOQ)

Overview

概述

EOQ determines the order quantity that minimizes total inventory cost = ordering cost + holding cost. Formula: EOQ = √(2DS/H) where D=annual demand, S=ordering cost per order, H=holding cost per unit per year. Assumes constant demand and instantaneous replenishment.
EOQ用于确定能最小化总库存成本(订货成本+持有成本)的订货量。公式为:EOQ = √(2DS/H),其中D=年需求量,S=每次订货的订货成本,H=单位产品年持有成本。该模型假设需求恒定且补货瞬时完成。

When to Use

适用场景

Trigger conditions:
  • Setting standard order quantities for inventory replenishment
  • Balancing ordering frequency against warehousing costs
  • Baseline calculation before applying safety stock adjustments
When NOT to use:
  • When demand is highly uncertain (use newsvendor model)
  • When products are perishable with short shelf life
  • When quantity discounts change the cost structure significantly
触发条件:
  • 为库存补货设定标准订货量
  • 平衡订货频率与仓储成本
  • 在调整安全库存前进行基准计算
不适用场景:
  • 需求高度不确定时(使用报童模型)
  • 产品易腐、保质期短
  • 数量折扣显著改变成本结构时

Algorithm

算法

IRON LAW: EOQ Assumes CONSTANT, KNOWN Demand
If demand is variable or uncertain, EOQ gives the wrong answer.
Real-world application: use EOQ as a starting point, then add
safety stock for demand variability and lead time uncertainty.
Total cost curve is flat near EOQ — ±20% from optimal Q changes
total cost by only ~2%.
IRON LAW: EOQ Assumes CONSTANT, KNOWN Demand
If demand is variable or uncertain, EOQ gives the wrong answer.
Real-world application: use EOQ as a starting point, then add
safety stock for demand variability and lead time uncertainty.
Total cost curve is flat near EOQ — ±20% from optimal Q changes
total cost by only ~2%.

Phase 1: Input Validation

阶段1:输入验证

Determine: D (annual demand in units), S (fixed cost per order), H (holding cost per unit per year = unit cost × holding rate, typically 20-30% of unit value). Gate: All costs positive, demand estimate reasonable.
确定:D(年需求量,单位为件),S(每次订货的固定成本),H(单位产品年持有成本=单位成本×持有费率,通常为单位价值的20-30%)。 **校验门限:**所有成本为正数,需求估算合理。

Phase 2: Core Algorithm

阶段2:核心算法

  1. EOQ = √(2 × D × S / H)
  2. Number of orders per year = D / EOQ
  3. Reorder point = d × L (daily demand × lead time in days)
  4. Total annual cost = (D/Q × S) + (Q/2 × H) at Q = EOQ
  1. EOQ = √(2 × D × S / H)
  2. 年订货次数 = D / EOQ
  3. 再订货点 = d × L(日需求量×提前期天数)
  4. 年总成本 = (D/Q × S) + (Q/2 × H),其中Q = EOQ

Phase 3: Verification

阶段3:验证

Check: ordering cost component ≈ holding cost component (they're equal at EOQ). Total cost is at minimum. Gate: Ordering cost ≈ holding cost (±5%).
检查:订货成本部分≈持有成本部分(在EOQ点两者相等)。总成本处于最小值。 **校验门限:**订货成本≈持有成本(误差±5%)。

Phase 4: Output

阶段4:输出

Return EOQ with cost breakdown and reorder point.
返回EOQ及成本明细、再订货点。

Output Format

输出格式

json
{
  "eoq": 500,
  "orders_per_year": 20,
  "reorder_point": 150,
  "annual_cost": {"ordering": 2000, "holding": 2000, "total": 4000},
  "metadata": {"demand": 10000, "order_cost": 100, "holding_cost": 4.0}
}
json
{
  "eoq": 500,
  "orders_per_year": 20,
  "reorder_point": 150,
  "annual_cost": {"ordering": 2000, "holding": 2000, "total": 4000},
  "metadata": {"demand": 10000, "order_cost": 100, "holding_cost": 4.0}
}

Examples

示例

Sample I/O

输入输出示例

Input: D=10,000 units/year, S=$100/order, H=$4/unit/year Expected: EOQ = √(2×10000×100/4) = √500000 = 707 units
**输入:**D=10,000件/年,S=100美元/次订货,H=4美元/件/年 **预期结果:**EOQ = √(2×10000×100/4) = √500000 = 707件

Edge Cases

边缘情况

InputExpectedWhy
Very high S, low HLarge EOQ, few ordersMinimize expensive ordering
Very low S, high HSmall EOQ, frequent ordersMinimize expensive holding
D = 0EOQ = 0, no orderingNo demand, no orders needed
输入预期结果原因
极高S,低H大EOQ,订货次数少最小化高昂的订货成本
极低S,高H小EOQ,订货频繁最小化高昂的持有成本
D = 0EOQ = 0,无需订货无需求,无需订货

Gotchas

注意事项

  • Holding cost underestimation: H should include: capital cost, storage, insurance, obsolescence, handling. Companies often only count warehouse rent, understating true H.
  • Flat cost curve: Total cost is insensitive near EOQ. Rounding EOQ to a convenient number (full pallet, container) costs very little.
  • Quantity discounts: Price breaks at certain quantities may make it cheaper to order MORE than EOQ. Compare total cost at EOQ vs discount breakpoints.
  • Lead time variability: EOQ doesn't address when to order, only how much. Add safety stock: SS = z × σ_demand × √(lead time).
  • Multi-item coordination: When multiple items share ordering costs (same supplier), use joint replenishment models, not individual EOQs.
  • **持有成本低估:**H应包含:资金成本、仓储费、保险费、损耗费、搬运费。企业常仅计算仓库租金,从而低估实际H。
  • **成本曲线平缓:**EOQ附近总成本变化不敏感。将EOQ取整为方便的数值(如整托盘、整集装箱),成本几乎无变化。
  • **数量折扣:**当达到特定订货量可享受价格折扣时,可能订比EOQ更多的货更划算。需比较EOQ点与折扣临界点的总成本。
  • **提前期波动:**EOQ仅解决订多少的问题,不解决何时订货。需添加安全库存:SS = z × σ_demand × √(提前期)。
  • **多产品协同:**当多个产品共享订货成本(同一供应商)时,应使用联合补货模型,而非单独计算各产品的EOQ。

Scripts

脚本

ScriptDescriptionUsage
scripts/eoq.py
Compute Economic Order Quantity and cost breakdown
python scripts/eoq.py --help
Run
python scripts/eoq.py --verify
to execute built-in sanity tests.
脚本描述使用方法
scripts/eoq.py
计算经济订货批量及成本明细
python scripts/eoq.py --help
运行
python scripts/eoq.py --verify
可执行内置的合理性测试。

References

参考资料

  • For EOQ with quantity discounts, see
    references/eoq-discounts.md
  • For safety stock calculation, see algo-sc-safety-stock
  • 带数量折扣的EOQ,请参阅
    references/eoq-discounts.md
  • 安全库存计算,请参阅algo-sc-safety-stock