Guides

# Anticipate Future Demand with Quantitative Inventory Optimization

This guide aims to be a gentle introduction to inventory optimization from a quantitative viewpoint. In particular, the focus is set on inventory sizing; that is, addressing the question: how much inventory should be stored at any point in time?

## About the author

Joannes Vermorel is the founder of Lokad, a software company that specializes in demand forecasting, inventory optimization and other statistical analysis, with a special interest in commerce. He is also teaching cloud computing and software engineering at the École Normale Supérieure in Paris, France.

All the webapps of Lokad come with an Express Plan that is free and does not expire, typically suitable for small and medium online merchants. We also have paid plans with support and more capacity for larger companies. Don’t hesitate to have a look at www.lokad.com to find out more.

## Foreword about quantitative inventory

Inventory is tradeoff between too much stock where costs skyrocket, and too little stock where nothing gets sold anymore.

While most practitioners do understand this principle as one of the cornerstones of inventory optimization; I observe that the whole practice becomes rather fuzzy when it comes to adopt a strict quantitative financial viewpoint, that is the quantification and the optimization of the costs involved with each inventory decision.

In this paper, I propose to shed some lights on this subject.

## Any inventory is an anticipation of the future demand

Each item stored by your company is an anticipation of a future demand. Each item has been purchased and stored for the sole purpose of being available when the market will finally express need for it.

As a practitioner, you might have heard or possibly work yourself with demand forecasts. Many companies considered as mature, typically all the large retail networks, rely on statistical demand forecasts to optimize their stock levels.

A forecast, in its classical form is a number that has, if done properly, 50% chance to be above or below the future demand – as typically observed through sales. The simplest way to compute the accuracy of the forecast is to compare the absolute difference between the original forecast and the counterpart demand observed later on. Obviously, as soon you start producing forecasts, it is natural to strive for a better accuracy, as it should improve the inventory – somehow.

Example: Let’s assume that aluminum chairs are being sold at an average rate of 1 unit per week with a lead time of 1 week. What is the best stock level for the aluminum chairs? Well, it depends. If chairs are sold 1 unit at a time, then having 3 chairs in stock is probably good enough to achieve a fairly high service level. However, if usually chairs are sold by 4, then it takes 8 and possibly 12 chairs in stock to achieve the same service level. Being able to refine the forecasts from 1 unit per week to 1.2 units per weeks, a closer estimate of the true average demand is just missing the point.

This viewpoint is so widespread that, at Lokad, it took us a couple of years to realize that we were not seeing the forest for the trees: each stock level is itself is a direct anticipation of the future. The stock levels are the true forecasts made by the business.

This simple idea leads to two key observations:

Even if nobody has a “forecasting” keyword in his/her job title, if your company holds inventory, then somebody is routinely doing forecasts.

Daily, weekly or monthly forecasts are not true inventory forecasts, but merely statistical artifacts that can be turned into inventory decisions.

In this document, we frequently use the term “anticipation” rather than “forecast”. This is done on purpose, as the notion of a forecast; especially the notion of “statistical forecast” has a very precise meaning which, unfortunately, is quite counter-intuitive. Well, statistics, as a whole, is a counter-intuitive science. By using the term “anticipation”, we emphasize the idea of making a business statement about the future, not just producing a number.

## You can’t optimize what you don’t measure

Conventional wisdom among engineers indicates that you can’t optimize what you don’t measure. It very much applies to inventory as well. Measuring the performance of your inventory is the first step toward bringing any improvement to your company.

As we have seen in the previous section, stock levels themselves represent the actual anticipation of our company toward the future market demand. Now, the question remains: what is the quality of this anticipation?

A tempting, but incorrect, answer consists of measuring the accuracy of daily/weekly/monthly forecasts when they exist. The answer is incorrect because the “classic” forecast is merely an intermediate numerical result within the inventory optimization process, and it does not reflect final reality of the inventory. Putting it another way, measuring the accuracy of a “classic” forecast does not capture all the errors that can be introduced when this intermediate numerical result is turned into a purchase decision.

Thus, this question should be addressed with an answer expressed in dollars not in percent’s, that is, the exact amount lost by your company because anticipations of the future were not perfect.

In practice, however applying a true cost function is complicated, and certainly goes beyond the scope of the present eBook. Thus we are to take alternative approach which vastly simplifies the analysis while remaining very effective.

## Measuring inventory performance though target service levels

Determining the optimal size for your inventory is an asymmetric problem: the marginal cost of one unit lost through a stock-out typically vastly exceeds the cost of storing one extra unit of inventory. This asymmetry is the reason why most businesses seek high service levels where the service level is defined as the probability of not having a stock-out for a given item.

**Anecdote**: One day, the head of marketing realizes that close to 10% of incoming orders are not fulfilled, and it’s damaging the business, and immediately reports the problem to the CEO. The CEO calls the head of supply chain to get the problem fixed. The head of the supply chain immediately increase all stock levels, and service levels improves. Three months later, the CFO realizes that inventory levels are above 60 days, and it’s damaging the business, and immediately reports the problem to the CEO. The CEO calls the head of the supply chain to get the problem fixed. The head of supply chain immediately postpones all further reorders to lower stock, and the stock level drops. And 3 months later, the head of marketing realizes that again 10% of the incoming orders are not fulfilled.

Those service levels implicitly represent the financial tradeoff between the cost of inventory and the cost of stock-outs. Thus, instead of focusing on writing the actual cost function of the inventory, we are going to measure the **adequacy of the stock levels against the target service levels**. From this perspective, the goal becomes the minimization of the inventory levels under the constraint that service levels are met.

This approach assumes that the target service levels correctly reflect the asymmetry that exists between stock and stock-outs. At Lokad, we have closely worked with hundreds of retail companies of all sizes from 1-man merchants to very large retail networks. While we have frequently faced situations where stock levels were dysfunctional, we have very rarely met companies who did not have a relatively precise idea of what should be their service levels. Then, when seeking to optimize those service levels further, we frequently realize that the initial estimates given by the retailer were typically fairly good from the start with respect to the financial costs involved.

Thus, we believe making sure that the inventory is just enough to cover the target level is an excellent way to approximate the inventory cost function while preserving the essence of the optimization.

In practice, in commerce, service levels ranges from 98.5% for high volume products stored in warehouses of nationwide distributors down to 85% for perishable items in stores. Most smaller ecommerce targets 95% service level while bigger one go for 97% for their top sellers.

## Reorder points are quantile forecasts

The reorder point represents the level of inventory that triggers a replenishment order. Those reorder points represent the current anticipation of your company for future demand.

*Previously, you said that inventory itself – i.e. stocks on hand – was the true anticipation of the future demand, isn’t that conflicting with your statement about reorder points? No, the stock on hand is the anticipation of your company as it was in the past. The present anticipation can significantly diverge from the past anticipation, as new demand has been observed to revise the anticipation. *

Typically in many inventory software this reorder point is known as the “Min” as in “Min/Max” inventory. However, even if your software does not have such a parameter, the reorder point value always exists possibly only in the mind of the person in charge of the replenishment.

In order to optimize inventory, those reorder points need to be made explicit - ideally via your inventory software; or through a Microsoft Excel sheet otherwise. Without those numbers, there is simply no record of your company’s anticipations; and, as stated previously, you can’t optimize what you don’t measure.

The quantity reflected by the reorder point should be just enough to cover the demand for the duration of the lead time. Indeed, the lead time is the amount of time between the placing of an order and the renewed availability, after the receipt of the goods ordered. Thus, the reorder point must cover the lead time, because no replenishment will arrive sooner than the lead time. The total demand over the duration of the lead time is known as the lead demand.

Then, the lead demand is uncertain (yet to be observed), so the reorder point should only cover the lead demand but only with a certain probability as defined by the service level. If the service level is set at 95%, then reorder point should be as low as possible while maintaining 95% chance of being strictly larger than the lead demand.

Reorder points are in fact a sort of biased forecasts: instead of being a “classic” forecast that has 50% chance of being above or below the future demand, the reorder point should have, say, 95% chances to be just above the future demand.

The bias might seem a bit surprising at first, but thinking from a commerce perspective, it’s actually a very natural behavior: most of the products should be available most of the time. We can’t just cover the average case, we need to cover the infrequent demand spikes as well, but within reason.

Actually, this notion of “forecasts with a bias” has been known in statistics for several decades already under the name of quantile forecasts.

A quantile forecast, in the context of inventory optimization, is just a forecast that takes two extra variables, the service level and the lead time, and that returns a single value, the reorder point.

## The pinball loss function

At this point, we have established that reorder points can be interpreted as a non-classic form of forecasts known as quantile forecasts; however, we are still lacking the tools to measure the accuracy of those forecasts. Indeed, the classic accuracy formulas do not apply to quantile forecasts. When it comes to quantile forecasts, the pinball loss function has to be used.

Let’s focus on a single SKU and let’s introduce the variables that we need to model the situation:

Let z be its current reorder point that is the threshold that should trigger an inventory reorder. This value is an integer reflecting a count of items.

Let τ be the service level that is expected for the SKU. This value is a percentage.

Let λ be the lead time expressed in days, that is, the total delay to renew the inventory

Let y be the lead demand, that is, the total demand that will be observed for the duration of the lead time. This is an integer reflecting a count of items, homogeneous to z.

In practice, the lead demand y cannot be measured starting from the present. Indeed, it reflects demand that has not happened yet. However, whenever looking at the past, it becomes possible to compute the lead demand as long it does not overlap with the future.

Ex: if your lead time is of 2 weeks, you should position your analysis at least 2 weeks in the past; otherwise there is a segment of the lead demand that has not been observed yet which prevent the actual measurement of the lead demand.

Intuitively, the reorder point should be as close as possible to the lead demand. Indeed, you need to have just enough stock to last until the stock is replenished. Any additional stock is a waste of money because it represents idle stock that won’t serve any demand. The other way around, having less stock than the lead demand causes a stock-out – because precisely the stock cannot be renewed before a delay as long as the lead time.

As stated at the beginning of the section, inventory sizing is an asymmetric problem, hence, we can’t just use a naïve symmetric error measure such as the mean absolute error (MAE) where MAE(y,z)=|y-z| to compute the adequacy between stock levels and service levels.

*We need to resort to an asymmetric criterion.*

The **pinball loss function** is a simple yet powerful function to measure the performance of your stock levels compared to the company business goals. The pinball loss function can be written as:

** Lτ(y,z)={if z≥y then (y-z)τ else (z-y)(1-τ) **

Where the variables follow the definition just introduced previously.

In practice, computing the pinball loss function is very straightforward even with only Microsoft Excel. The screenshot below illustrates how to implement this function with y the “Real Value” and z the “Forecast”.

In order to make this function a bit more visual, let’s plot it with a varying reorder point z while we assume the lead demand to be constant. As you can see, it’s an asymmetric function with distinct slopes on the right and left sides.

**The forecasting model that minimizes the pinball loss value for a service level τ happens to be the best ***quantile ***forecasting model that fulfills the constraint of over-estimating the demand with a probability of exactly τ.**

This result is a relatively well-known theorem in statistics. While the demonstration is beyond the scope of this document, let’s see what we obtain when τ=50%. In this case, we have τ=1-τ=50%, and the formula given here above becomes L0.5(y,z)=|y-z|, that is, just the main mean absolute error (MAE). Indeed, a forecast that minimizes the MAE is a forecast that has 50% of being above or below the future demand.

In practice, the value returned by the pinball loss cannot be directly interpreted in terms of costs for the company (it’s not an economic cost function). The values returned by the pinball loss function can only be compared with other values also computed by the pinball loss function, for example, obtained when considering an alternative inventory.

**Anecdote: **The head of marketing and the CFO had been battling over “too much stock” vs. “too many stock-outs” for years with little progress overall. The company was alternating between periods of excess stocks and periods of excess stock-outs. Then, the pinball loss, averaged over all products was introduced among the company KPIs. Suddenly, it was possible to judge whether an inventory adjustment was bringing a *quantitative* improvement over the last month, compared to the month before or the year before of the same period.

## Benchmarking your inventory sizing performance

The quantile forecasting viewpoint (i.e. reorder points are special types of statistical forecasts) associated with the pinball loss function provides a simple way to quantify the performance of an inventory sizing strategy.

This viewpoint can be used to measure the performance of the present inventory sizing strategy used by your company (it does not matter whether the strategy is explicit or not); but, more interestingly, this viewpoint can be used to benchmark *alternative inventory strategies*.

The capacity to benchmark an alternative inventory strategy *in silico*, that is without the need to actually put in production any of the potential inventory strategy being considered, is one of the most critical steps toward a true *quantitative *optimization of inventory.

Indeed, based on the results obtained by such a benchmark, it becomes possible to prove whether a revised inventory strategy is better than *status quo* or not. Then, it becomes actually possible to iterate toward *quantitatively *better strategies.