The articles addressed (full or partial coverage) are listed bellow, please refer to these for more information:
| [FedergruenZheng1992] | (1, 2) Awi Federgruen and Yu-Sheng Zheng. An efficient algorithm for computing an optimal (r, q) policy in continuous review stochastic inventory systems. Operations Research, 40(4):808-813, 1992. |
| [Zheng1992] | (1, 2, 3) Yu-Sheng Zheng. On properties of stochastic inventory systems. Management Science, 38:87-103, 1992. |
| [Gallego1998] | Guillermo Gallego. New bounds and heuristics for (q, r) policies. Management Science, 44(2):219-233, 1998. |
| [KleinauThonemann2004] | (1, 2) Peer Kleinau and Ulrich W Thonemann. Deriving inventory-control policies with genetic programming. OR Spectrum, 26(4):521-546, 2004. |
Modules¶
inventory.continuous¶
Provides the cost functions for the continuous model.
-
inventory.continuous.ecomStockoutP(dL1, dL2, s, Q)[source]¶ Calculate the stockout probability for the e-commerce model.
Parameters: - dL1 – distribution of the demand of type 1 (must be continuous)
- dL2 – distribution of the demand of type 2 (must be continuous)
- s – the reorder point
- Q – the reorder quantity
Returns: stockout probability
Return type:
-
inventory.continuous.alphaTCecom(s, Q, dL1, dL2, A, B1, D, r, v, *args, **kwargs)[source]¶ Calculate the total cost for the e-commerce model (alpha service level, B1 items).
Parameters: - dL1 – distribution of the demand of type 1 (must be continuous)
- dL2 – distribution of the demand of type 2 (must be continuous)
- s – the reorder point
- Q – the reorder quantity
- A – the setup cost
- B1 – the backorder penalty
- D – the total demand
- r – inventory carrying charge
- v – unit variable cost
Returns: total cost
Return type:
-
inventory.continuous.sfactorTCecom(k, Q, dL1, dL2, A, B1, D, r, v, *args, **kwargs)[source]¶ Calculate the total cost for the e-commerce model based on the service factor (alpha service level, B1 items).
Parameters: - dL1 – distribution of the demand of type 1 (must be continuous)
- dL2 – distribution of the demand of type 2 (must be continuous)
- k – the service factor
- Q – the reorder quantity
- A – the setup cost
- B1 – the backorder penalty
- D – the total demand
- r – inventory carrying charge
- v – unit variable cost
Returns: total cost
Return type:
-
inventory.continuous.vectorizeTCecom(xL1, sigma1, xL2, sigma2, tcOpt=0, **kwargs)[source]¶ Vectorize the cost function
alphaTCecom().Parameters: - xL1 – the mean demand of type 1.
- xL2 – the mean demand of type 2.
- sigma1 – the standard deviation for the demand of type 1.
- sigma2 – the standard deviation for the demand of type 2.
Returns: vectorized total cost function
Return type:
-
inventory.continuous.alphaTC(s, Q, dL, A, B1, D, h, **kwargs)[source]¶ Calculate the total cost for an (s, Q) inventory control policy (alpha service level, B1 items).
Parameters: - dL – distribution of the demand (must be continuous)
- s – reorder point
- Q – reorder quantity
- A – setup cost (K)
- B1 – backorder penalty (p)
- D – total demand (lambda)
- h – on-hold cost
Returns: total cost
Return type:
-
inventory.continuous.sfactorTC(k, Q, dL, A, B1, D, h, **kwargs)[source]¶ Calculate the total cost for an (s, Q) inventory control policy based on the service factor (alpha service level, B1 items).
Parameters: - dL – distribution of the demand (must be continuous)
- k – service factor
- Q – reorder quantity
- A – setup cost (K)
- B1 – backorder penalty (p)
- D – total demand (lambda)
- h – on-hold cost
Returns: total cost
Return type:
-
inventory.continuous.betaTC(s, Q, dL, A, B1, D, rv, *args, **kwargs)[source]¶ Calculate the total cost for an (s, Q) inventory control policy (beta service level, continuous approzimation of the discrete model).
Parameters: - dL – distribution of the demand (must be continuous)
- s – reorder point
- Q – reorder quantity
- A – setup cost (K)
- B1 – backorder penalty (p)
- D – total demand (lambda)
- rv – on-hold cost (h)
Returns: total cost
Return type:
inventory.discrete¶
Provides the cost functions for the discrete model.
-
inventory.discrete.G(y, lL, p, h, cdf)[source]¶ Aggregates the holding and backorder costs in the discrete model.
Parameters: - y – the function y parameter
- lL – demand distribution expected value
- p – backorder penalty
- h – on-hold cost
- cdf – function used to calculate the cumulative distribution of the demand
Returns: the aggregated on-hold and backordered inventory cost
Return type:
-
inventory.discrete.discreteTC(s, Q, lL, K, p, lbd, h, *args, **kwargs)[source]¶ Calculates the total cost using the discrete model. As described in [FedergruenZheng1992] and [Zheng1992].
Parameters: - s – reorder point
- Q – reorder quantity
- lL – demand distribution expected value
- K – order setup cost
- p – backorder penalty
- lbd – total demand
- h – holding cost
Returns: total cost
Return type: Example: >>> round(discreteTC(50, 7, 50, 1, 25, 50, 10), 2) 95.46 >>> round(discreteTC(56, 7, 50, 1, 100, 50, 10), 2) 142.81 >>> round(discreteTC(46, 6, 50, 1, 25, 50, 25), 2) 153.35
-
inventory.discrete.pdcdf(x, lbd)[source]¶ Returns the pre-calculated value for the cumulative distribution function of a Poisson distribution.
Parameters: - lbd – demand distribution expected value (lambda)
- x – point to calculate the cdf (integer)
Returns: P(X <= x)
Return type: Raises: Warning – if the pair (x, lbd) does not exist in the table, and the return value is calculated on-the-fly using
scipy.statsExamples: >>> round(pdcdf(1, 25),4) == round(poisson.cdf(1,25)) True >>> round(pdcdf(1e6, 25),4) == round(poisson.cdf(1e6,25)) True
inventory.solvers¶
Implements the heuristics and optimal algorithms.
-
inventory.solvers.alphaSolver(x, std, A, B1, D, rv, *args, **kwargs)[source]¶ Simultaneous (iterative) solver for alpha service level in traditional retail.
Parameters: - x – demand distribution expected value
- std – demand distribution standard deviation
- A – setup cost (K)
- B1 – backorder penalty (p)
- D – total demand (lambda)
- rv – on-hold cost (h)
Returns: service factor, reorder quantity
Return type:
-
inventory.solvers.betaSolver(lL, K, p, l, h)[source]¶ Calculates (r, Q) parameters from [Zheng1992] heuristic.
Parameters: - lL – demand distribution expected value
- K – order setup cost
- p – backorder penalty
- l – total demand
- h – holding cost
Returns: reorder point, reorder quantity
Return type: Examples: >>> import functools >>> map(functools.partial(round, ndigits = 1), betaSolver(50, 1, 25, 50, 10)) [48.9, 3.7] >>> map(functools.partial(round, ndigits = 1), betaSolver(50, 5, 25, 50, 10)) [47.6, 8.4] >>> map(functools.partial(round, ndigits = 1), betaSolver(50, 25, 25, 50, 10)) [44.7, 18.7] >>> map(functools.partial(round, ndigits = 1), betaSolver(50, 100, 25, 50, 10)) [39.3, 37.4] >>> map(functools.partial(round, ndigits = 1), betaSolver(50, 1000, 25, 50, 10)) [16.2, 118.3]
-
inventory.solvers.discreteSolver(lL, K, p, l, h, cdf=<function pdcdf>)[source]¶ Calculates the optimal reorder point and quantity parameters as presented by [FedergruenZheng1992].
Parameters: - lL – demand distribution expected value
- K – order setup cost
- p – backorder penalty
- l – total demand
- h – holding cost
- cdf – function used to calculate the cumulative distribution function of a Poisson
Returns: reorder point, reorder quantity
Return type: Example: >>> discreteSolver(50, 1, 25, 50, 10) (50, 7) >>> discreteSolver(50, 5, 25, 50, 10) (48, 12) >>> discreteSolver(50, 25, 25, 50, 10) (44, 23) >>> discreteSolver(50, 100, 25, 50, 10) (38, 40) >>> discreteSolver(50, 1000, 25, 50, 10) (15, 120)
-
inventory.solvers.eoq(K, lbd, h)[source]¶ Calculates the order quantity according to the Economic Order Quantity (EOQ) model, without planned backorders.
Parameters: - K – order setup cost
- lbd – total demand
- h – holding cost
Returns: reorder quantity
Return type:
-
inventory.solvers.gallego(lL, K, p, l, h, L, costfun=<function discreteTC>, minmethod='cobyla')[source]¶ Calculates the reorder quantity (Q) parameter from [Gallego1998] heuristic, and finds the corresponding reorder point (r) through numerical optimisation (using constrained optimization by linear approximation).
Parameters: - lL – demand distribution expected value
- K – order setup cost
- p – backorder penalty
- l – total demand
- h – holding cost
- L – lead time
- costfun – cost function to be minimised when calculating the reorder point
- minmethod – optimisation algorithm to use with
minimize() - roundmethod – function used to round the floating point reorder quantity
Returns: reorder point, reorder quantity
Return type:
-
inventory.solvers.kleinauGP(lL, K, p, l, h, L)[source]¶ Calculates the reorder point and quantity parameters from [KleinauThonemann2004] full Genetic Programming solution.
Parameters: - lL – demand distribution expected value
- K – order setup cost
- p – backorder penalty
- l – total demand
- h – holding cost
- L – lead time
Returns: reorder point, reorder quantity
Return type:
-
inventory.solvers.kleinauNum(lL, K, p, l, h, L, minmethod='cobyla')[source]¶ Calculates the reorder quantity (Q) parameter from [KleinauThonemann2004] hybrid GP approach, and finds the corresponding reorder point (r) through numerical optimisation (using constrained optimization by linear approximation).
Parameters: - lL – demand distribution expected value
- K – order setup cost
- p – backorder penalty
- l – total demand
- h – holding cost
- L – lead time
- costfun – cost function to be minimised when calculating the reorder point
- minmethod – optimisation algorithm to use with
minimize() - roundmethod – function used to round the floating point reorder quantity
Returns: reorder point, reorder quantity
Return type:
-
inventory.solvers.zhengNumeric(lL, K, p, l, h, L, costfun=<function discreteTC>, minmethod='cobyla', roundmethod=<built-in function round>)[source]¶ Calculates the reorder quantity (Q) parameter from [Zheng1992] heuristic, and finds the corresponding reorder point (r) through numerical optimisation (using constrained optimization by linear approximation).
Parameters: - lL – demand distribution expected value
- K – order setup cost
- p – backorder penalty
- l – total demand
- h – holding cost
- L – lead time
- costfun – cost function to be minimised when calculating the reorder point
- minmethod – optimisation algorithm to use with
minimize() - roundmethod – function used to round the floating point reorder quantity
Returns: reorder point, reorder quantity
Return type:
inventory.utils¶
Implements utilities for data generation and plotting, and helpers for the DEAP genetic programming algorithm.
-
inventory.utils.genSample(originData, lowerDev=20, upperDev=50)[source]¶ Generates random samples from the originData example, with each variable transformed between lowerDev and upperDev.
-
inventory.utils.getfitcases(vlist=None, costfun=None, solver=None, backorders=True)[source]¶ Returns a list of problem instances, based on the cartesian product of vlist
Parameters: - vlist – the base list to build the cartesian product
- costfun – function used to calculate the cost
- solver – heuristic used to calculate (r,Q) parameters for each instance
- backorders – if False and r < 0, then r = 0
Returns: list of instances
Return type:
-
inventory.utils.plotETRCsurface(t, show=True, colormap=None)[source]¶ Plots a surface for a data record.
-
inventory.utils.protectedDiv(left, right)[source]¶ Safe version of the operator
div()to use with GP.
-
inventory.utils.runCoEA(toolbox, stats, logbook, numGen=100, rnd=False, cxp=0.6, mutp=1.0, **kwargs)[source]¶ Initializes and runs the coevolutionary algorithm.
Returns: the best individual of the run.
-
inventory.utils.setupdeap(args, dataset, inputs, evalfun, discrete=True)[source]¶ Builds the evolutionary algorithm.
Returns: Toolbox,Statistics,LogbookReturn type: tuple
-
inventory.utils.statsfun(distr, statistic, toolbox, discrete=False)[source]¶ Wrapper (decorator) to use statistical functions in the GP function set.
Parameters: - distr – the name of the distribution variable
- statistic – the name of the statistical function (cdf, pdf, etc)
- toolbox – DEAP
Toolbox - discrete – used to force the casting of the input
Returns: paramterized function
Return type: