# Using Neural Network algorithms for inventory planning: An Experiment

## Solution Architecture

This post summarizes my attempt to mimic what a “real time” Supply Chain planning algorithm may look like, structurally, in the future. Let us start with briefly stating our objective:

To address the possibility that artificial neural networks can help predict the capacity of the simulated Supply Chain network to fulfill incoming orders for the next upcoming period.

### Approach

In my experiment, I combined a multi-echelon SC simulation model, with an artificial neural network architecture. The simulation software AnyLogic was used to model the hypothetical Supply Chain and set the parameters that were latter used to feed the artificial neural network. The artificial neural network was developed using Python programming (Tensor Flow). The illustration below is just a representation of the flow.

Illustrative flow of experiment architecture

## My hypothetical Supply Chain

To keep the experiment simple, our Supply Chain handles only one product and consists of four echelons: supplier, production, distribution and retailer. The time between order arrivals is fixed and set with a length of one-time unit.

I created a random demand data set where the order size is variable and follows a normal distribution with a mean of 40 units and standard deviation of 2 units. The values of these parameters were selected along with a set of other values related to the four nodes:

• Re-order points,
• Quantities to order upstream
• Transportation times between nodes
• Transportation capacities for the four nodes.

## Simulation Approach

In the AnyLogic model created for the Supply Chain described above, above mentioned parameters were adjusted using successive iterations until the service level in the retailer is around 90% and the service levels on the other nodes of the SC are also balanced around the same values.

### Model Architecture

The retailer is the entity in charge to fulfill the orders, and whenever the re-order point is reached, an order is placed towards the distribution center to refill the inventory. The replenishment sent from the distribution center is a fixed quantity. If a backorder occurs (the current inventory is not sufficient to satisfy the order), the available quantity is sent immediately and the rest is dispatched as soon as its inventory is loaded.

### Replenishment policy

The ordering policy used is the order point, order quantity so-called (s, Q) system, in which both re-order point, s, and order quantity, Q, are fixed.

It is a continuous review policy so that it could provide a stable service level, although it does not cope effectively with sudden large orders. The same policy is applied through all the nodes, i.e., the orders from the distribution, production and supplier are sent to their respective upstream node, induced by inventory levels lower than the corresponding re-order point.

The echelons are obviously connected through a transport mode which is set with a restricted capacity and fixed transportation time. Moreover, warehouses are assumed to have unlimited storage capacity, and at the beginning of the Supply Chain, there is an entity holding enough inventory capable to feed the supplier.

All these settings infer that the uncertainty in the SC comes from the orders size that the retailer must deliver.

Regarding the outputs, it was registered the time in system of each order and the inventory levels of each echelon whenever a new order entered in the system

## The Neural Network Model

For this experiment, I created a multi-layer perceptron set with one hidden layer. Multi-layer perceptron is the most common type of neural networks for networks with three layers or more (n ≥ 3):

• One input layer,
• One output layer and
• One or more hidden layers.

The weights connect neurons from consecutive layers, and these connections exhibit different values according to the importance perceived after the iteration process in the training phase.

As mentioned in one of the previous sections, the artificial neural network was fed with data generated in simulation runs. The number of neurons in the input and output layers are not fixed: they were both re-adjusted considering respectively, the past and future boundaries using Python programming. After training the network, the test phase was performed with untrained data and the recognition rates were calculated by comparing the outcomes (outputs) with the values that were returned from the simulation.

### Architecture of  both experiments

In experiment 1 the goal is to anticipate the capacity to dispatch instantaneously the upcoming orders. In other words, the time the order stays in system is zero if the inventory at the retailer is sufficient to fulfill that order, and greater than zero otherwise, which means that it was not satisfied immediately (retailer stock out). It is possible to identify with precision the expected time to fulfill the orders. The variable p represents the prediction time horizon. The output layer has different lengths depending on the number of periods, p, to predict.

In the experiment 2 the entities that reach their re-order point, place a new order upstream. The network can foresee when and in which nodes these situations will happen. As stated before, the inputs represent the inventory levels of each entity. To organize the targets, the values were set in groups of five neurons, in which the first four are activated when their respective entity reaches the re-order point. In this case, each neuron represents one different echelon, y1 will turn to 1 if the inventory level on the retailer is expected to be below the re-order point, and the same for the neurons y2, y3 and y4 regarding the distribution, production and supplier nodes, respectively. A fifth neuron, will act as a control neuron, and it is activated when none of the other neurons were activated in that period.

For both experiments, the inputs are the same. The neurons x1, x2, x3 and x4 represent the inventory levels of each SC node, retailer, distribution, production and supplier, respectively. The input layer can either be set considering only the inventory levels of the instant t when an order arrives in the system, or extending the time period considering historical data. In this case, the input layer is set with all inventory levels from the instant t to the instant t – q + 1, where q stands for the number of periods considered.

### Experiments and results

The sample used to train the artificial neural network comprised the information of 216000 different periods of time generated by the simulator. The tests were performed with a sample with data regarding 24000 periods generated with different runs, from untrained data.

## Conclusion

These predictions are relevant because the conditions that affect supply chains are dynamic and in this globalized world turns to be impossible to consider all relevant variables using traditional linear models.

Regarding the experiment 1, the outcomes were remarkable: the recognition rate was greater than 99.5% for predictions for the next period and over 98% for predictions for the three next periods. These results were compared with a new experiment, using as input only the information of the inventory level in the retailer. In that experiment, the recognition rate for larger time periods were smaller, which proved that visibility in supply chains is important and increases prediction accuracy. In experiment 2, the results were 97% for predictions for the next period and 75% for a time horizon of three periods. As the time period is enlarged the recognition rate decreases around 10-15% for each time period that is added.

Moreover, we can conclude that it is irrelevant to extend substantially the historical data, once the outcomes when using only two periods (the current and the previous periods) are practically the same compared with the results from larger periods.

Therefore, we can conclude that artificial neural networks can be used to effectively predict potential disruptions in supply chains and more accurately than conventional planning methods.

My next steps of modifying this algorithm are to (1) introduce complexity in the SC model by adding new nodes, types of products, additional sources of uncertainty like variability in transportation times, transportation capacities and the processing time in each entity, and (2) perform the same challenges but using a lower sample size to train the network and use recurrent neural networks to cover that complexity.

I will keep you posted via this site !