# Automated Application of Inventory Optimization

Tomáš Martinovič, Kateřina Janurová, Kateřina Slaninová, Jan Martinovič

► To cite this version:

Tomáš Martinovič, Kateřina Janurová, Kateřina Slaninová, Jan Martinovič. Automated Application of Inventory Optimization. 15th IFIP International Conference on Computer Information Systems and Industrial Management (CISIM), Sep 2016, Vilnius, Lithuania. pp.230-239, 10.1007/978-3-319-45378-1_21. hal-01637495

HAL Id: hal-01637495

https://inria.hal.science/hal-01637495

Submitted on 17 Nov 2017

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Automated Application of Inventory
Optimization

Tomáš Martinovič, Kateřina Janurová, Kateřina Slaninová, and Jan Martinovič

IT4Innovations National Supercomputing Center,
VŠB – Technical University of Ostrava,
17. listopadu, 708 33 Ostrava, Czech Republic
{tomas.martinovic,katerina.janurova,katerina.slaninova,
jan.martinovic}@vsb.cz

**Abstract.** We present automated application of inventory optimization based on sales forecast. Inventory stock optimization is very required issue by companies recent years, however inventory models are based on the sales expectation. Therefore, the problem of optimizing inventory stock is divided into two parts, sales forecast and setting optimal inventory. We describe an automated solution to model selection for sales forecast and the inventory setting based on those predictions. In the end, we present our validation of the system through historical simulation. We compare simulations results against real inventory levels. Due to the large number of different length time series, this simulation was run in parallel on cluster and was parallelized in R. The algorithms were developed and tested on inventory time series from real data sets of the K2 atmitec company<fnref n="1" />.

**Keywords:** inventory optimization, sales forecasting, model selection, parallelization

# 1 Introduction

The goal of our work was the design and implementation of automated application of inventory control for optimization and simplification of the decision making process of sales managers. Models for inventory control are based on the products sales expectations. Therefore, as the first step of inventory control, the sales forecast needs to be estimated. In our application, the sales forecast can be determined by four different models applied on several modifications of sales history. The result of the model with the best prediction according to the selected measure of accuracy is used as the input for the inventory control model.

Because of the lack of information needed for the standard inventory control models like Economic Order Quantity model or newsvendor model, we had to base our approach for the second step of inventory control on a fixed time review period model with variable demand and modify it to better suit our needs. This

<footnote n="1">¹ Sales forecasting and inventory optimization are parts of ERP solution K2, which is provided by K2 atmitec s.r.o. company, http://www.k2.cz/en/.</footnote>
modification was verified by the simulation, which imitates behavior of sales manager on the assumption of complete trust in our application. The results of such simulation were compared with the real historical data of inventory time series.

The simulations were parallelized in R language and run in parallel on cluster because of the large number of products used for verification and repeated model estimations.

## 2 Inventory Stock Optimization

As described above, the inventory stock optimization consists of the two steps: sales forecasting and optimal inventory setting.

### 2.1 Sales Forecasting

Sales forecasting represents a typical application of time series analysis and prediction. Classical time series analysis is based on the assumption that the time series $y_t$ for $t = 1, 2, ..., n$ can be decomposed into four components: trend, cyclic, seasonal and irregular. The trend component characterizes a long-term tendency of the examined phenomenon that is influenced by factors operating in the same direction eg. production technology, demographic conditions, market conditions, etc. The first approach we used in time series modeling is based on the idea that if the long-term tendency of time series corresponds to a certain function of time eg. a linear, quadratic, exponential, S-curve etc., the trend component can be modeled using this function [1].

Assume that the time series $y_t$ can be written as the sum of trend and residual process

$$y_t = T_t + \varepsilon_t, \quad t = 1, 2, ..., n, \quad (1)$$

where $T_t$ can be described by the appropriate mathematical function of the time variable $t$, and $\varepsilon_t$ is the residual component with the character of white noise process.

We used three different mathematical functions for modeling the trend components in our simulation:

1. linear trend function in the form

$$T_t = \beta_0 + \beta_1 t, \quad t = 1, 2, ..., n, \quad (2)$$

2. quadratic trend function in the form

$$T_t = \beta_0 + \beta_1 t + \beta_2 t^2, \quad t = 1, 2, ..., n, \quad (3)$$

3. and cubic trend function in the form

$$T_t = \beta_0 + \beta_1 t + \beta_2 t^2 + \beta_3 t^3, \quad t = 1, 2, ..., n. \quad (4)$$
The regression parameters of the trend functions $\beta_0, \beta_1, \beta_2$ and $\beta_3$ were estimated by the least squares estimation method. Although this approach may appear to be too simple, in many practical cases the best solution is the simplest one.

The second approach we used in time series modeling is provided by the ARIMA model [2]. ARIMA - Autoregressive integrated moving average - is part of the Box-Jenkins methodology, which was developed for the analysis of time series, where we assume that the residual component $\varepsilon_t$ does not have the character of white noise. Unlike the first approach, where the regression model is built only as the function of time, the Box-Jenkin's models are built as the function of linear combination of $p$ past values of the modeled variable itself, hence the term autoregressive, and regression-like model of $q+1$ past forecast errors. In such way the ARMA($p, q$) - autoregressive moving averages - model is obtained. ARIMA($p, d, q$) model is then essentially an ARMA model applied to the $d$th difference of the original series. Such approach is used in the cases when the studied series is not stationary (it's properties depend on the time at which the series is observed). The stationarity can be achieved by applying the difference of the first or the second order, difference of the higher order are usually not used in practice.

The final sales forecast is made in four steps. At first, all the models described above are fitted to the training part of the data, $y_t$ for $t = 1, 2, ..., m$, where $m < n$, then the sales forecasts $\hat{y}_t$ for $t = m+1, m+2, ..., n$ are made on the basis of fitted models. The different forecasts are compared with the test part of the data $y_t$ for $t = m+1, m+2, ..., n$ using appropriate measure of accuracy, and finally the best forecast is chosen as the input for inventory control model. Additionally, the models are fitted simultaneously on the original daily data and data with weekly and monthly aggregation.

For the best forecast selection, several measures of accuracy eg. RMSE, MAE, MAPE, etc. were considered [3]. However, because of the different time aggregation of the compared time series, the accuracy measure, that is independent of the scale of the data, seems to be the most convenient one. This kind of accuracy measure, Mean Absolute Scaled Error, was proposed by Hyndman and Koehler [4] as

$$MASE = \text{mean}(|q_t|), \qquad (5)$$

with the scaled error $q_t$ defined as

$$q_t = \frac{e_t}{\frac{1}{n-m-1} \sum_{i=m+2}^{n} |y_i - y_{i-1}|}, \qquad (6)$$

where $e_t$ is the forecast error defined as $e_t = y_t - \hat{y}_t, t = m+1, m+2, ..., n$.

## 2.2 Inventory Control

Numerous models for inventory control were developed such as Economic Order Quantity model (EOQ) or newsvendor model. Those are the basic deterministic
and stochastic models for the inventory control. Based on the stochastic nature of our problem and available data we used fixed time review period model with variable demand as a basis for our solution.

It was difficult to estimate ordering costs and holding costs due to the character of the available data. Therefore, we use just quantities and we focus on providing inventory level measures based on the user specified service level in our approach. To achieve that, three measures need to be computed. The first is the safety stock, which should cover most of the uncertain demand. This uncertainty means that it would be too costly, and often impossible, to hold enough inventory to cover all the variations in demand. Therefore, the user of the software may set requested level of service. Safety stock then depends on standard deviation of sales, lead time, service level and probability distribution of sales. Assuming standard normal distribution of sales, constant lead time and constant variation of sales, we can define the safety stock [5] as

$$S = \varphi(sl) \sqrt{t_l \sigma_d^2}, \qquad (7)$$

where $\varphi(sl)$ is the quantile function for normal distribution and its quantile is given by service level. Variable $t_l$ stands for lead time and $\sigma_d$ is standard deviation of demand. By leaving the assumption of constant lead time and adding uncertainty to lead time we get

$$S = \varphi(sl) \sqrt{t_l \sigma_s^2 + E(s) \sigma_l^2}, \qquad (8)$$

where $E(s)$ is expected mean sales and $\sigma_l$ is lead time standard deviation. Now we can define reorder point, which is the level of inventory needed to cover the demand until the arrival of the next batch of inventory plus safety stock. If we assume the constant demand and constant lead time we can define reorder point as follows

$$R = S + E(s)t_l. \qquad (9)$$

The last step is to compute the order quantity. This is defined as the quantity necessary to cover the demand for the user specified time. Hence, the order quantity is affected by mean expected sales, order time, incoming goods and goods reserved in advance. Additionally, the ordered quantity should be adjusted by the difference between actual stock and reorder point. We can write this as

$$Q = E(s)t_o - G_i + G_r + R - A, \qquad (10)$$

where $t_o$ is the order time, $G_i$ is the incoming goods quantity, $G_r$ is reserved goods quantity and $A$ is actual level of inventory. This definition of order quantity covers the demand for the defined time with set service level for covering the stochastic behaviour of customers.

## 2.3 Automated Application of Inventory Optimization

The theory described in sections 2.1 and 2.2 was used for development of an approach for inventory optimization that was implemented as part of ERP software
by K2 atmitec company. This software can simplify the decision making process
of sales managers. It includes three main parts, which are "best model selection",
"sales prediction" and "inventory control".

3 Verification of Automated Application of Inventory Optimization

To evaluate our approach, we created a simulation which imitates behavior of
sales manager on the assumption of complete trust in our approach. The sim-
ulation includes all three parts mentioned in previous section, which are com-
plemented by an automatically controlled decision making process for running
specific parts. We used historical time series of sales and inventory stock levels
for verification of our simulation, the results are given in section 3.3.

**3.1 Data Description**

The real historical data for our software verification was provided by the K2
atmitec company. The dataset contained the information about approximately
33 000 products in several warehouses in Czech Republic. We were not able to
simulate the behavior for all of the provided products due to the small number of
observations in the followed history. The software was finally verified on about
950 and 750 products in two selected warehouses, what was sufficiently large
enough number.

**3.2 Simulations**

On the beginning of the simulation, some parameters must be set. The lead
time for the given goods, order interval and maximum level of inventory. The
lead time and maximum level of inventory are variable for every type of stock.
The review period was set to 30 days. In addition, we had to select the service
level, which was set to 95%.

The starting point for the simulation is a year and a half. That means we
take the first year and a half of sales time series and the inventory level at that
time. The "best model selection" part begins with running the model selection
algorithm, when the original time series is preprocessed in several steps. In order
to find the best model for given data, the time series with originally daily sales
is aggregated in weekly and monthly sales. There is a possibility of removing
outliers for each aggregation and also filtering by Kalman [6] or Baxter-King [7]
filter for weekly and monthly aggregation. At the end of preprocessing step, each
original time series leads to 10 final modifications on which the four models given
in section 2.1 are fitted and compared by the MASE accuracy measure. This
chooses a predictive model used for the next three months. Then, the simulation
runs the "sales prediction" part, that calculates the predicted sales quantity
on the basis of previously selected predictive model. The result of this step is
the predicted time series, that is used as the input for the "inventory control"
<figure><img src="image_2.png" /><figcaption>Fig. 1. Prediction of sales quantity of real inventory time series</figcaption></figure>

part, which sets the reorder point and safety stock. The visualization of such prediction is shown in Fig.1.

After the first day, the simulation iterates by day, reducing the inventory level by the same amount as it is reduced in the real inventory time series. When it reaches the reorder point, the "sales prediction" and "inventory control" parts are run again. The reorder point and safety stock are updated according to the new results and order for the new inventory is made. The ordered inventory is added to the simulated inventory after the lead time period. Every three months new predictive model is chosen based on the "best model selection" part. This process is repeated until the end of the time series.

The main output of this simulation is simulated inventory time series. This may be compared with the actual inventory time series, as is shown in Fig.2. In general, if the mean level of simulated inventory is less than the actual inventory and the stockout time is within boundaries of chosen service level, we can say, that the simulation is successful. In addition, to the simulated inventory time series, we have other outputs. Those are chosen predictive models, history of inventory control settings, orders history and graphical output. These outputs allow us to make a quick analysis of reasons for the success or failure of our simulation.
<figure><img src="image_3.png" /><figcaption>Fig. 2. Comparison of simulated inventory time series and real inventory time series</figcaption></figure>

Because of a large number of products at each warehouse and repeated model estimations, we had to parallelize this algorithm. Due to the independency of simulations for specific goods, the computation was easily parallelized through Rmpi<fnref n="2" /> package in R software. This package uses MPI for communications between nodes. Our algorithm uses distributed apply function, where a master node sends time series data to free slave nodes, which execute the simulation on given data. This method allows us to run this algorithm both single node or on the cluster and scales well, because there is minimal need for the communication. The computation was made on Salomon cluster equipped with Intel Xeon E5-2680v3 processors. We used 8 compute nodes, each with 24 cores and 128GB RAM.

In the future, we would like to make improvements in the computations of reorder point and safety stock, since they are very susceptible to sudden changes in demand as is shown in Fig.3. The most sensible seems to be the solution by moving averages since this will allow for changes to happen, but it would smooth them at the same time. However, this approach needs to be tested.

<footnote n="2">² Yu, H. (2002). Rmpi: Parallel Statistical Computing in R. R News 2/2:10-14.</footnote>
<figure><img src="image_4.png" /><figcaption>**Fig. 3.** Inventory quantity, safety stock, reorder point and order quantity history for inventory control simulation</figcaption></figure>

## 3.3 Comparison of Simulation Results and Real Inventory Data

Simulations were completed on two warehouses, one with 950 products and the second with 761 products. For each simulation, the mean level of real inventory and the mean level of simulated inventory were determined, and the relative percentage difference with respect to mean level of real inventory was calculated. The higher relative percentage difference, the more successful simulation was. Stockout was calculated for the sake of real information as the number of days for which the product was unavailable. The mean and median values for the relative percentage difference as well as the mean values of stockout days for both warehouses are given in Tab.1

<table><caption>**Table 1.** Summary statistics for the comparisons of the mean level of real inventory and the mean level of simulated inventory.</caption><thead><tr><th></th><th>Warehouse 1</th><th>Warehouse 2</th></tr></thead><tbody><tr><td>number of products</td><td>950</td><td>761</td></tr><tr><td>mean stockout [%]</td><td>2.7</td><td>3.1</td></tr><tr><td>mean relative percentage difference [%]</td><td>17.4</td><td>20.0</td></tr><tr><td>median relative percentage difference [%]</td><td>34.8</td><td>35.2</td></tr></tbody></table>
As can be seen from the summary statistics, the mean stouckout is within the required level of 5 % for both warehouses. The mean level of relative percentage difference was 17.4 % and 20.0 %, with the meaning that if the sales manager trusted completely in our software, the mean inventory level would be lower by 17.4 % and 20.0 %

<figure><img src="image_5.png" /><figcaption>**Fig. 4.** Distribution of relative percentage difference with respect to real inventory in Warehouse 1</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>**Fig. 5.** Distribution of relative percentage difference with respect to real inventory in Warehouse 2</figcaption></figure>

The values of median relative percentage difference suggest, that the decrease could be even more significant, and that the mean relative percentage difference value is influenced by several unsuccessful simulations, as can be seen from the distribution of relative percentage difference with removed outliers in Fig.4 and
Fig.5. Those were mainly simulations on products with the lead time greater than 40 days. Improvement of the simulation on such products is one of the tasks for our future research.

## 4 Conclusion

Our paper describes design, implementation and verification of the automated application of inventory control that is based on predictions of real historical sales data. The sales prediction is estimated by several approaches of time series modeling of which the best is chosen by the selected measure of accuracy. Modification of fixed time review period model with variable demand was proposed for inventory control model and verified by the described simulation process which compares inventory time series simulated by our application with the real inventory time series. The results of the simulation showed, that if the sales manager acted completely in accord with our application recommendation, the mean inventory level would decrease by 17.4 % in one tested warehouse and by 20.0 % in the second tested warehouse.

The future work in this area involves, besides the tasks mentioned in previous section, the research and the implementation of other suitable models for sales forecasting and their ensembles, an improved model selection, and alternative inventory control models.

## Acknowledgment

This work was supported by The Ministry of Education, Youth and Sports from the National Programme of Sustainability (NPU II) project 'IT4Innovations excellence in science – LQ1602' and from the Large Infrastructures for Research, Experimental Development and Innovations project 'IT4Innovations National Supercomputing Center – LM2015070'.

## References

1. Hyndman, R.J. and Athanasopoulos, G.: Forecasting: principles and practice. OTexts: Melbourne, Australia (2013) http://otexts.org/fpp/. Accessed on 26.4.2016.

2. Asteriou, D. and Hall, S.G.: Applied Econometrics (Second ed.). Palgrave MacMillan (2011)

3. Palit, A.K. and Popovic, D.: Computational Intelligence in Time Series Forecasting: Theory and Engineering Applications. Springer-Verlag, London (2005)

4. Hyndman, R.J. and Koehler, A.B.: Another look at measures of forecast accuracy. Int. J. Forecasting. 22, 679–688 (2006)

5. Russell, R.S. and Taylor, B.W.: Operations Management. Wiley (2011)

6. Durbin, J. and Koopman, S.J.: Time Series Analysis by State Space Methods. Oxford Statistical Science Series, Clarendon Press (2001)

7. Baxter, M. and King, R.G.: Measuring Business Cycles Approximate Band-Pass Filters for Economic Time Series. Technical report, National Bureau of Economic Research (1995)