问题
考虑一个商品补货问题:
零售商以 p p p 元/件的采购价 (purchase price) 从供应商处采购某种商品, 以 r r r 元/件的零售价 (retail price) 售卖给消费者, 其中 r > p r>p r > p .
零售商将商品存放在仓库中, 为此需要承担 h h h 元/(件·天) 的持有成本 (holding cost).
考虑到运费、人力等因素, 每次从供应商处补货, 零售商都需承担 K K K 元的固定成本 (fixed setup cost).
消费者不接受延迟发货, 这意味着当库存量无法满足消费者的需求时, 零售商就要承担缺货损失 (shortage cost).
消费者对商品的需求量是随机的, 但未来任意一段时间的需求量所服从的概率分布是已知的.
零售商从供应商处订货的提前期 (lead time) 为 L L L 天, 最小起订量为 m o q moq m o q 件.
零售商采用 (R, Q) 订货策略, 即当库存量下降到再订货点 (R eorder Point) R R R 时, 就触发补货, 订货量 (Order Q uantity) 为 Q Q Q . 此外, 由于操作上的原因, 两次订货之间的时间间隔不能少于 τ \tau τ 天. 零售商希望尽可能维持 α \alpha α 的服务水平 (service level) , 同时尽可能降低成本, 需要由算法来决策 R R R 和 Q Q Q .
求解
确定再订货点
计算从当前起的 L L L 天之内不发生缺货的概率 α ~ \tilde\alpha α ~ , 若此概率小于或等于目标服务水平 α \alpha α 、且距离上次补货不少于 τ \tau τ 天时, 就触发补货.
用随机变量 D τ 1 , τ 2 D_{\tau_1, \tau_2} D τ 1 , τ 2 表示时间段 [ τ 1 , τ 2 ) [\tau_1, \tau_2) [ τ 1 , τ 2 ) 内的需求, f τ 1 , τ 2 ( x ) f_{\tau_1, \tau_2}(x) f τ 1 , τ 2 ( x ) 表示 D τ 1 , τ 2 D_{\tau_1, \tau_2} D τ 1 , τ 2 的概率质量函数, F τ 1 , τ 2 ( x ) F_{\tau_1, \tau_2}(x) F τ 1 , τ 2 ( x ) 表示 D τ 1 , τ 2 D_{\tau_1, \tau_2} D τ 1 , τ 2 的累积分布函数, 即
f τ 1 , τ 2 ( x ) = P r o b ( D τ 1 , τ 2 = x ) F τ 1 , τ 2 ( x ) = P r o b ( D τ 1 , τ 2 ≤ x ) \begin{aligned}
f_{\tau_1, \tau_2}(x) &= Prob(D_{\tau_1, \tau_2}= x) \\
F_{\tau_1, \tau_2}(x) &= Prob(D_{\tau_1, \tau_2}\leq x)
\end{aligned}
f τ 1 , τ 2 ( x ) F τ 1 , τ 2 ( x ) = P r o b ( D τ 1 , τ 2 = x ) = P r o b ( D τ 1 , τ 2 ≤ x )
用 t 0 t_0 t 0 表示当前时刻, s 0 s_0 s 0 表示当前的库存. 用 ( t 1 , s 1 ) , ( t 2 , s 2 ) , ⋯ , ( t n , s n ) (t_1, s_1), (t_2, s_2), \cdots, (t_n, s_n) ( t 1 , s 1 ) , ( t 2 , s 2 ) , ⋯ , ( t n , s n ) 表示在途库存, 即 t i t_i t i 时刻将会入库 s i s_i s i 单位货物. 这里 t 0 < t 1 < t 2 < ⋯ < t n < t 0 + L t_0<t_1<t_2<\cdots<t_n<t_0+L t 0 < t 1 < t 2 < ⋯ < t n < t 0 + L .
如果没有在途库存, 则从当前起的 L L L 天内不发生缺货等价于 [ t 0 , t 0 + L ) [t_0, t_0+L) [ t 0 , t 0 + L ) 内的需求 D t 0 , t 0 + L D_{t_0, t_0+L} D t 0 , t 0 + L 不超过当前的库存 s 0 s_0 s 0 , 即
α ~ = P r o b ( D t 0 , t 0 + L ≤ s 0 ) = F t 0 , t 0 + L ( s 0 ) \begin{aligned}
\tilde\alpha &= Prob(D_{t_0, t_0+L}\leq s_0) \\
&= F_{t_0, t_0+L}(s_0)
\end{aligned}
α ~ = P r o b ( D t 0 , t 0 + L ≤ s 0 ) = F t 0 , t 0 + L ( s 0 )
如果有一批在途库存 ( t 1 , s 1 ) (t_1, s_1) ( t 1 , s 1 ) , 则从当前起的 L L L 天不发生缺货等价于 [ t 0 , t 1 ) [t_0, t_1) [ t 0 , t 1 ) 内的需求 D t 0 , t 1 D_{t_0, t_1} D t 0 , t 1 不超过 s 0 s_0 s 0 且 [ t 0 , t 0 + L ) [t_0, t_0+L) [ t 0 , t 0 + L ) 内的总需求 D t 0 , t 0 + L D_{t_0, t_0+L} D t 0 , t 0 + L 不超过总库存 s 0 + s 1 s_0+s_1 s 0 + s 1 . 因此
α ~ = P r o b ( ( D t 0 , t 1 ≤ s 0 ) ∩ ( D t 0 , t 0 + L ≤ s 0 + s 1 ) ) = P r o b ( ( ⋃ x = 0 s 0 D t 0 , t 1 = x ) ∩ ( D t 0 , t 0 + L ≤ s 0 + s 1 ) ) = P r o b ( ⋃ x = 0 s 0 ( ( D t 0 , t 1 = x ) ∩ ( D t 0 , t 0 + L ≤ s 0 + s 1 ) ) ) = P r o b ( ⋃ x = 0 s 0 ( ( D t 0 , t 1 = x ) ∩ ( D t 1 , t 0 + L ≤ s 0 + s 1 − x ) ) ) = ∑ x = 0 s 0 P r o b ( ( D t 0 , t 1 = x ) ∩ ( D t 1 , t 0 + L ≤ s 0 + s 1 − x ) ) = ∑ x = 0 s 0 P r o b ( D t 0 , t 1 = x ) ⋅ P r o b ( D t 1 , t 0 + L ≤ s 0 + s 1 − x ) = ∑ x = 0 s 0 f t 0 , t 1 ( x ) ⋅ F t 1 , t 0 + L ( s 0 + s 1 − x ) \begin{aligned}
\tilde\alpha &= Prob((D_{t_0, t_1}\leq s_0)\cap (D_{t_0, t_0+L}\leq s_0+s_1)) \\
&= Prob((\bigcup_{x=0}^{s_0}D_{t_0, t_1}=x)\cap (D_{t_0, t_0+L}\leq s_0+s_1)) \\
&= Prob(\bigcup_{x=0}^{s_0}((D_{t_0, t_1}=x)\cap (D_{t_0, t_0+L}\leq s_0+s_1))) \\
&= Prob(\bigcup_{x=0}^{s_0}((D_{t_0, t_1}=x)\cap (D_{t_1, t_0+L}\leq s_0+s_1-x))) \\
&= \sum_{x=0}^{s_0}Prob((D_{t_0, t_1}=x)\cap (D_{t_1, t_0+L}\leq s_0+s_1-x)) \\
&= \sum_{x=0}^{s_0}Prob(D_{t_0, t_1} = x)\cdot Prob(D_{t_1, t_0+L}\leq s_0+s_1-x) \\
&=\sum_{x=0}^{s_0}f_{t_0, t_1}(x)\cdot F_{t_1, t_0+L}(s_0+s_1-x)
\end{aligned}
α ~ = P r o b ( ( D t 0 , t 1 ≤ s 0 ) ∩ ( D t 0 , t 0 + L ≤ s 0 + s 1 ) ) = P r o b ( ( x = 0 ⋃ s 0 D t 0 , t 1 = x ) ∩ ( D t 0 , t 0 + L ≤ s 0 + s 1 ) ) = P r o b ( x = 0 ⋃ s 0 ( ( D t 0 , t 1 = x ) ∩ ( D t 0 , t 0 + L ≤ s 0 + s 1 ) ) ) = P r o b ( x = 0 ⋃ s 0 ( ( D t 0 , t 1 = x ) ∩ ( D t 1 , t 0 + L ≤ s 0 + s 1 − x ) ) ) = x = 0 ∑ s 0 P r o b ( ( D t 0 , t 1 = x ) ∩ ( D t 1 , t 0 + L ≤ s 0 + s 1 − x ) ) = x = 0 ∑ s 0 P r o b ( D t 0 , t 1 = x ) ⋅ P r o b ( D t 1 , t 0 + L ≤ s 0 + s 1 − x ) = x = 0 ∑ s 0 f t 0 , t 1 ( x ) ⋅ F t 1 , t 0 + L ( s 0 + s 1 − x )
下面我们推广到有 n n n 批在途库存 ( t 1 , s 1 ) , ( t 2 , s 2 ) , ⋯ , ( t n , s n ) (t_1, s_1), (t_2, s_2), \cdots, (t_n, s_n) ( t 1 , s 1 ) , ( t 2 , s 2 ) , ⋯ , ( t n , s n ) 的情况. 在给出详细的推导之前, 我们不妨先引用一下列夫·朗道 (Lev Landau) 在《量子力学: 非相对论理论》第九章中的论断
“The calculation … is in principle very simple; it is easier to do it oneself than to follow an account of it. Hence we shall give only the result of this calculation.”
因此, 我们有
α ~ = ∑ x 0 = 0 s 0 f t 0 , t 1 ( x 0 ) ∑ x 1 = 0 s 0 + s 1 − x 0 f t 1 , t 2 ( x 1 ) ⋯ ∑ x n − 1 = 0 ∑ i = 0 n − 1 s i − ∑ i = 0 n − 2 x i f t n − 1 , t n ( x n − 1 ) F t n , t 0 + L ( ∑ i = 0 n s i − ∑ i = 0 n − 1 x i ) \tilde\alpha = \sum_{x_0=0}^{s_0}f_{t_0, t_1}(x_0)\sum_{x_1=0}^{s_0+s_1-x_0}f_{t_1, t_2}(x_1)\cdots\sum_{x_{n-1}=0}^{\sum_{i=0}^{n-1}s_i-\sum_{i=0}^{n-2}x_i}f_{t_{n-1}, t_n}(x_{n-1})F_{t_n, t_0+L}(\sum_{i=0}^{n}s_i-\sum_{i=0}^{n-1}x_i)
α ~ = x 0 = 0 ∑ s 0 f t 0 , t 1 ( x 0 ) x 1 = 0 ∑ s 0 + s 1 − x 0 f t 1 , t 2 ( x 1 ) ⋯ x n − 1 = 0 ∑ ∑ i = 0 n − 1 s i − ∑ i = 0 n − 2 x i f t n − 1 , t n ( x n − 1 ) F t n , t 0 + L ( i = 0 ∑ n s i − i = 0 ∑ n − 1 x i )
可以看到, 当有多批在途库存时, 计算会变得非常反复. 我们有必要做一些近似.
确定订货量
第 t 0 t_0 t 0 天订货 Q Q Q 件, 第 t 0 + L t_0+L t 0 + L 天到货, 假设这批货到第 t 0 + L + t t_0+L+t t 0 + L + t 天消耗完(库存先进先出), 则
采购成本为 p ⋅ Q + K p\cdot Q + K p ⋅ Q + K , 平摊到每天为 p ⋅ Q + K t + 1 \dfrac{p\cdot Q + K}{t+1} t + 1 p ⋅ Q + K .
持有成本从入库开始计算, 直至这批货消耗完为止, 平摊到每天约等于 h ⋅ Q 2 \dfrac{h\cdot Q}{2} 2 h ⋅ Q .
缺货损失从入库开始计算, 直至 τ \tau τ 天后为止.
当 t < τ t<\tau t < τ 时, 缺货损失为单位利润 r − p r-p r − p 乘以 [ t 0 + L + t , t 0 + L + τ ) [t_0+L+t, t_0+L+\tau) [ t 0 + L + t , t 0 + L + τ ) 内的期望需求量 E D t 0 + L + t , t 0 + L + τ \mathbb ED_{t_0+L+t, t_0+L+\tau} E D t 0 + L + t , t 0 + L + τ .
当 t ≥ τ t\geq\tau t ≥ τ 时, 缺货损失为 0 0 0 .
为了统一形式, 我们规定当 τ 2 ≤ τ 1 \tau_2\leq \tau_1 τ 2 ≤ τ 1 时, D τ 1 , τ 2 ≡ 0 D_{\tau_1, \tau_2}\equiv 0 D τ 1 , τ 2 ≡ 0 . 这样一来, 缺货损失为 ( r − p ) ⋅ E D t 0 + L + t , t 0 + L + τ (r-p)\cdot\mathbb ED_{t_0+L+t, t_0+L+\tau} ( r − p ) ⋅ E D t 0 + L + t , t 0 + L + τ , 平摊到每天为 ( r − p ) ⋅ E D t 0 + L + t , t 0 + L + τ t + 1 \dfrac{(r-p)\cdot\mathbb ED_{t_0+L+t, t_0+L+\tau}}{t+1} t + 1 ( r − p ) ⋅ E D t 0 + L + t , t 0 + L + τ .
这批货到第 t 0 + L + t t_0+L+t t 0 + L + t 天消耗完到概率记作 p ( t ) p(t) p ( t ) , 则平摊到每天的期望成本为
c o s t ( Q ) = ∑ t = 0 ∞ p ( t ) [ p ⋅ Q + K t + 1 + h ⋅ Q 2 + ( r − p ) ⋅ E D t 0 + L + t , t 0 + L + τ t + 1 ] cost(Q) = \sum_{t=0}^{\infty}p(t)\left[\frac{p\cdot Q + K}{t+1}+ \frac{h\cdot Q}{2}+\frac{(r-p)\cdot\mathbb ED_{t_0+L+t, t_0+L+\tau}}{t+1}\right]
c o s t ( Q ) = t = 0 ∑ ∞ p ( t ) [ t + 1 p ⋅ Q + K + 2 h ⋅ Q + t + 1 ( r − p ) ⋅ E D t 0 + L + t , t 0 + L + τ ]
接下来我们来计算 p ( t ) p(t) p ( t ) .
采购单于第 t 0 + L t_0+L t 0 + L 天入库, 此时仓库中可能还有剩余的库存 s s s . 因此, 采购单入库后到第 t 0 + L + t t_0+L+t t 0 + L + t 天消耗完, 等价于第 t 0 + L t_0+L t 0 + L 天的总库存量 Q + s Q+s Q + s 到第 t 0 + L + t t_0+L+t t 0 + L + t 天消耗完. 这意味着 Q + s Q+s Q + s 能满足 [ t 0 + L , t 0 + L + t ) [t_0+L, t_0+L+t) [ t 0 + L , t 0 + L + t ) 的总需求, 但不能满足 [ t 0 + L , t 0 + L + t + 1 ) [t_0+L, t_0+L+t+1) [ t 0 + L , t 0 + L + t + 1 ) 的总需求, 即 D t 0 + L , t 0 + L + t ≤ Q + s < D t 0 + L , t 0 + L + t + 1 D_{t_0+L, t_0+L+t}\leq Q+s < D_{t_0+L, t_0+L+t+1} D t 0 + L , t 0 + L + t ≤ Q + s < D t 0 + L , t 0 + L + t + 1 .
如果没有在途库存, 则
p ( t ) = P r o b ( D t 0 , L > s 0 ) ⋅ P r o b ( D t 0 + L , t 0 + L + t ≤ Q < D t 0 + L , t 0 + L + t + 1 ) + ∑ x = 0 s 0 P r o b ( D t 0 , L = x ) ⋅ P r o b ( D t 0 + L , t 0 + L + t ≤ Q + s 0 − x < D t 0 + L , t 0 + L + t + 1 ) = ( 1 − F t 0 , L ( s 0 ) ) ⋅ ( F t 0 + L , t 0 + L + t ( Q ) − F t 0 + L , t 0 + L + t + 1 ( Q ) ) + ∑ x = 0 s 0 f t 0 , L ( x ) ⋅ ( F t 0 + L , t 0 + L + t ( Q + s 0 − x ) − F t 0 + L , t 0 + L + t + 1 ( Q + s 0 − x ) ) \begin{aligned}
p(t) &= Prob(D_{t_0, L}>s_0)\cdot Prob(D_{t_0+L, t_0+L+t}\leq Q< D_{t_0+L, t_0+L+t+1}) \\
&+ \sum_{x=0}^{s_0}Prob(D_{t_0, L}=x)\cdot Prob(D_{t_0+L, t_0+L+t}\leq Q+s_0-x< D_{t_0+L, t_0+L+t+1})\\
&=(1-F_{t_0, L}(s_0))\cdot (F_{t_0+L, t_0+L+t}(Q)-F_{t_0+L, t_0+L+t+1}(Q))\\
&+\sum_{x=0}^{s_0}f_{t_0, L}(x)\cdot(F_{t_0+L, t_0+L+t}(Q+s_0-x)-F_{t_0+L, t_0+L+t+1}(Q+s_0-x))\\
\end{aligned}
p ( t ) = P r o b ( D t 0 , L > s 0 ) ⋅ P r o b ( D t 0 + L , t 0 + L + t ≤ Q < D t 0 + L , t 0 + L + t + 1 ) + x = 0 ∑ s 0 P r o b ( D t 0 , L = x ) ⋅ P r o b ( D t 0 + L , t 0 + L + t ≤ Q + s 0 − x < D t 0 + L , t 0 + L + t + 1 ) = ( 1 − F t 0 , L ( s 0 ) ) ⋅ ( F t 0 + L , t 0 + L + t ( Q ) − F t 0 + L , t 0 + L + t + 1 ( Q ) ) + x = 0 ∑ s 0 f t 0 , L ( x ) ⋅ ( F t 0 + L , t 0 + L + t ( Q + s 0 − x ) − F t 0 + L , t 0 + L + t + 1 ( Q + s 0 − x ) )
下面考虑有在途库存的情况.
有了这些公式之后, 我们可以通过下面的算法确定订货量 Q Q Q .
1 2 3 4 5 6 7 Q = moq cost = cost(Q) while True : if cost(Q+1 ) > cost: return Q Q = Q+1 cost = cost(Q)
如果有箱规的约束, 也可以在此处一并考虑.