From 2b9e22071524f8ce503b118693c9e36164f4e76f Mon Sep 17 00:00:00 2001 From: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> Date: Fri, 2 Oct 2026 23:09:32 -0400 Subject: [PATCH] fix(inventory): keep discrete EOQ positive for low demand Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> --- specialized/supply-chain-strategist.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/specialized/supply-chain-strategist.md b/specialized/supply-chain-strategist.md index f3b52086..b2dc5bfb 100644 --- a/specialized/supply-chain-strategist.md +++ b/specialized/supply-chain-strategist.md @@ -88,10 +88,14 @@ class InventoryManager: EOQ = sqrt(2 * D * S / H) """ d = self.params.annual_demand + if d <= 0: + raise ValueError("Discrete-unit EOQ requires positive annual demand") s = self.params.order_cost h = self.params.unit_price * self.params.holding_cost_rate eoq = np.sqrt(2 * d * s / h) - return round(eoq) + # This discrete-unit example must order at least one unit when demand + # is positive; rounding a small EOQ to zero breaks the annual report. + return max(1, round(eoq)) def calculate_safety_stock(self) -> float: """