ss Module¶
Overview¶
The ss module contains code for solving the \((s,S)\) optimization problem.
Note
The notation and references (equations, sections, examples, etc.) used below refer to Snyder and Shen, Fundamentals of Supply Chain Theory (FoSCT), 2nd edition (2019).
See also
For an overview of single-echelon inventory optimization in Stockpyl, see the tutorial page for single-echelon inventory optimization.
API Reference¶
- s_s_cost_discrete(reorder_point, order_up_to_level, holding_cost, stockout_cost, fixed_cost, use_poisson, demand_mean=None, demand_hi=None, demand_pmf=None)[source]¶
Calculate the exact cost of the given solution for an \((s,S)\) policy with given parameters under a discrete (Poisson or custom) demand distribution.
Uses method introduced in Zheng and Federgruen (1991).
- Parameters
reorder_point (float) – Reorder point. [\(s\)]
order_up_to_level (float) – Order-up-to level. [\(S\)]
holding_cost (float) – Holding cost per item per period. [\(h\)]
stockout_cost (float) – Stockout cost per item per period. [\(p\)]
fixed_cost (float) – Fixed cost per order. [\(K\)]
use_poisson (bool) – Set to
Trueto use Poisson distribution,Falseto use custom discrete distribution. IfTrue, thenmeanmust be provided; ifFalse, thenhianddemand_pdfmust be provied.demand_mean (float, optional) – Mean demand per period. Required if
use_poissonisTrue, ignored otherwise. [\(\mu\)]demand_hi (int, optional) – Upper limit of support of demand per period (lower limit is assumed to be 0). Required if
use_poissonisFalse, ignored otherwise.demand_pmf (list, optional) – List of pmf values for demand values 0, …,
hi. Required ifuse_poissonisFalse, ignored otherwise.
- Returns
cost – Expected cost per period. [\(g(s,S)\)]
- Return type
float
- Raises
ValueError – If
reorder_pointororder_up_to_levelis not an integer.ValueError – If
holding_cost,stockout_cost, orfixed_cost<= 0.ValueError – If
demand_mean< 0, or ifdemand_hiis not a non-negative integer.ValueError – If
demand_pmfis not a list of lengthdemand_hi+ 1.
Equations Used (equation (5.7)):
\[g(s,S) = \frac{K + \sum_{d=0}^{S-s-1} m(d)g(S-d)}{M(S-s)},\]where \(g(\cdot)\) is the newsvendor cost function and \(M(\cdot)\) and \(m(\cdot)\) are as described in equations (4.71)–(4.75).
References
Y.-S. Zheng and A. Federgruen, Finding Optimal \((s,S)\) Policies is About as Simple as Evaluating a Single Policy, Operations Research 39(4), 654-665 (1991).
Example (Example 4.7):
>>> s_s_cost_discrete(4, 10, 1, 4, 5, True, 6) 8.034111561471642
- s_s_discrete_exact(holding_cost, stockout_cost, fixed_cost, use_poisson, demand_mean=None, demand_hi=None, demand_pmf=None)[source]¶
Determine optimal \(s\) and \(S\) for an \((s,S)\) policy under a discrete (Poisson or custom) demand distribution.
Uses method introduced in Zheng and Federgruen (1991).
- Parameters
holding_cost (float) – Holding cost per item per period. [\(h\)]
stockout_cost (float) – Stockout cost per item per period. [\(p\)]
fixed_cost (float) – Fixed cost per order. [\(K\)]
use_poisson (bool) – Set to
Trueto use Poisson distribution,Falseto use custom discrete distribution. IfTrue, thendemand_meanmust be provided; ifFalse, thendemand_hianddemand_pdfmust be provied.demand_mean (float, optional) – Mean demand per period. Required if
use_poissonisTrue, ignored otherwise. [\(\mu\)]demand_hi (int, optional) – Upper limit of support of demand per period (lower limit is assumed to be 0). Required if
use_poissonisFalse, ignored otherwise.demand_pmf (list, optional) – List of pmf values for demand values 0, …,
demand_hi. Required ifuse_poissonisFalse, ignored otherwise.
- Returns
reorder_point (float) – Reorder point. [\(s\)]
order_up_to_level (float) – Order-up-to level. [\(S\)]
cost (float) – Expected cost per period. [\(g(s,S)\)]
- Raises
ValueError – If
holding_cost,stockout_cost, orfixed_cost<= 0.ValueError – If
demand_mean< 0, or ifdemand_hiis not a non-negative integer.ValueError – If
demand_pmfis not a list of lengthdemand_hi+ 1.
Algorithm Used: Exact algorithm for periodic-review \((s,S)\) policies with discrete demand distribution (Algorithm 4.2)
References
Y.-S. Zheng and A. Federgruen, Finding Optimal \((s,S)\) Policies is About as Simple as Evaluating a Single Policy, Operations Research 39(4), 654-665 (1991).
Example (Example 4.7):
>>> s_s_discrete_exact(1, 4, 5, True, 6) (4.0, 10.0, 8.034111561471642)
- s_s_power_approximation(holding_cost, stockout_cost, fixed_cost, demand_mean, demand_sd)[source]¶
Determine heuristic \(s\) and \(S\) for an \((s,S)\) policy under a normal demand distribution.
Uses the power approximation by Ehrhardt and Mosier (1984).
- Parameters
holding_cost (float) – Holding cost per item per period. [\(h\)]
stockout_cost (float) – Stockout cost per item per period. [\(p\)]
fixed_cost (float) – Fixed cost per order. [\(K\)]
demand_mean (float) – Mean demand per period. [\(\mu\)]
demand_sd (float) – Standard deviation of demand per period. [\(\sigma\)]
- Returns
reorder_point (float) – Reorder point. [\(s\)]
order_up_to_level (float) – Order-up-to level. [\(S\)]
- Raises
ValueError – If
holding_cost,stockout_cost, orfixed_cost<= 0.ValueError – If
demand_meanordemand_sd< 0.
References
R. Ehrhardt and C. Mosier, A Revision of the Power Approximation for Computing \((s,S)\) Policies, Management Science 30, 618-622 (1984).
Equations Used (equations (4.77)-(4.80)):
\[ \begin{align}\begin{aligned}Q = 1.30 \mu^{0.494} \left(\frac{K}{h}\right)^{0.506} \left(1 + \frac{\sigma_L^2}{\mu^2}\right)^{ 0.116}\\z = \sqrt{\frac{Q}{\sigma_L} \frac{h}{p}}\\s = 0.973\mu_L + \sigma_L\left(\frac{0.183}{z} + 1.063 - 2.192z\right) \label{eq:sS_power_approx3}\\S = s + Q\end{aligned}\end{align} \]where \(\mu_L = \mu L\) and \(\sigma^2_L = \sigma^2L\) are the mean and standard deviation of the lead-time demand.
Example (Example 4.7):
>>> s_s_power_approximation(0.18, 0.70, 2.5, 50, 8) (40.19461695647407, 74.29017010980579)