ShrinkAware: An Improved Grocery Ordering Policy

Mark Velednitsky
Afresh Engineering
Published in
8 min readJul 5, 2023

In the U.S., 38% of all food goes unsold or uneaten. For grocers, food waste means lost potential sales, lower profit margins, and less efficient store teams. At Afresh, we reduce food waste by helping grocery partners make more intelligent inventory management decisions.

Most grocery stores in the U.S. use a similar model for ordering fresh produce. Each store has a Produce Manager that takes inventory and places replenishment orders approximately five days a week. Most of their produce (~95%) comes from a centralized distribution center, with a smaller portion (~5%) coming from local suppliers.

Produce Managers need to strike a delicate balance. If they order too much, customers get produce that has already spent several days waiting on the shelf. If they order too little, customers see empty shelves and might leave to shop at a competitor. Afresh eliminates the guesswork in this process by utilizing Machine Learning and Operations Research. For customers, this means fresher tomatoes and avocados to take home and enjoy.

This post highlights recent improvements made to the Afresh decision-making system, also known as an ordering policy, shared at the 17th Learning and Intelligence OptimizatioN (LION17) Conference in June 2023. The industry term for items that spoil and get thrown out is shrink. Thus, we call our policy ShrinkAware.

What is an ordering policy?

A lot goes into making an order recommendation, but what a grocery fresh department manager sees in the Afresh iPad app is simple. For each item in each store, they see a single number: the number of cases Afresh recommends they order.

Afresh’s ordering policy is a decision-making system that takes in upstream information like forecast, shelf life, floor capacity, pack size, item type, number of days until the next order, and customer risk tolerance. The system then synthesizes these inputs into a single, cohesive recommendation.

The system can be described as a “predict, then optimize” pipeline. This post will mainly focus on two upstream predictions that feed the downstream decision-making system: forecast and shelf life.

Why is an ordering policy important?

Historically, stores relied on heuristics to generate order quantities. This might mean generating a point forecast based on the sales from the previous day, week, and month — and then multiplying that forecast by a safety factor of 20% to arrive at an order.

Here are some cases where that heuristic breaks down:

  • For a slow-moving shelf-stable item like almonds or dried cranberries, where the store only sells 1 or 2 on a typical day but the display size is 12, stores would end up with a very empty display.
  • For a fast-moving, high-variance item like bananas, a 20% safety factor might not be enough. For example, consider a store with daily banana sales resembling a normal distribution with mean 100 and standard deviation 20. If the Produce Manager orders 120 bananas, the system would expect to go out-of-stock approximately 15% of the time. This is an unacceptably high number for the grocery industry, where out-of-stock rates are expected to be at most 5%.

What makes ordering perishable food so challenging?

To understand the Afresh ordering policy, it’s helpful to know what makes ordering fresh food so difficult in comparison to shelf-stable items like cereal.

Challenge #1: Shelf Life

In the discipline of Operations Research, there are two classic models on opposite sides of the spectrum: zero shelf life and infinite shelf life. There is a lot less research published about items with short, non-zero shelf lives — like perishable food.

First is the Newsvendor model, which models items that have essentially zero shelf life: once ordered, they must sell immediately, or they perish. One example is the eponymous newspaper. In the Newsvendor model, there is tension between the lost sales cost, which encourages larger orders, and the spoilage cost, which encourages smaller orders.

Next is the Economic Order Quantity (EOQ) model, which models items that have essentially infinite shelf life, like paper clips. In the EOQ model, there is a tension between a fixed order cost, which encourages large orders, and an ongoing holding cost, which encourages smaller orders.

Some research considers items with long but non-infinite shelf lives, such as technology and fashion, but even less research considers the kind of items Afresh cares about, with short but non-zero shelf lives.

Challenge #2: Keeping Shelves Full

A widely held belief in the grocery industry is that the appearance of abundance drives sales. More avocados on the shelf should mean more customers will buy avocados. On the other hand, if only one avocado is left on the shelf, nobody wants to be the last one to buy it. This is an unusual constraint that exists to some extent in other types of retail but is particularly true in the sales of fresh produce.

To solve this challenge, the ordering policy must arrive at a decision that strikes the perfect balance between keeping shelves full enough to not appear anemic, but not too full that food is wasted.

The Afresh Approach

To create the Afresh ordering policy, we considered the terms used in the objective functions of the Newsvendor model and the EOQ model. We then modified their mathematical formulation to fit the particular needs of the grocery industry. What emerges is a three-term model with a spoilage cost, lost sales cost, and holding cost.

The Afresh ordering policy modifies the holding cost to account for the difference between holding items on the floor and in the backroom. It also modifies the lost sales cost to kick in when items are low in stock but before they are completely out of stock.

The resulting equation looks like this:

Smart “Predict, then Optimize”

The topic of LION17 was ML (Machine Learning) to OR (Operations Research) pipelines. This encompassed systems like Afresh, where a machine learning system forecasts the future and an operations research model consumes that forecast to optimize a decision.

A new development in this field is Smart “Predict, then Optimize.” The concept is this: when building a machine learning system that serves a downstream decision-making system, you should consider your decision-making system when training the machine learning model.

For example, to help truck drivers plan their routes, ideally, there would be a model that perfectly predicted traffic on every road at every time of day. Realistically, that’s wishful thinking.

Rather than measuring the accuracy of the model on every road equally, it’s more effective to bias the training to get the prediction right on roads that are more heavily utilized. The end goal: focus ML training where it matters most.

While Afresh is not a fully end-to-end, Smart “Predict, then Optimize” system, a careful examination of the objective function of ShrinkAware can inform the focus of upstream systems, particularly for shelf life estimation and forecasting.

Insight #1: Shelf Life Decision Boundary

In examining how the objective function behaves for items with different shelf lives, a useful pattern emerges.

When the shelf life is short, the objective function behaves like the Newsvendor model: the holding cost becomes negligible and the objective function is a tradeoff between spoilage cost and lost sales cost.

When shelf life is long, spoilage becomes negligible and the tension is between the lost sales cost and the holding cost.

In items with an intermediate shelf life, all three terms matter equally.

Afresh’s ML to OR pipeline is very sensitive to the accuracy of shelf lives in the intermediate category, such as cherries, avocados, and apples. The model cares a lot more about the difference between a 7-day shelf life and a 9-day shelf life for an item like limes than the difference between a 15-day shelf life and a 20-day shelf life for an item like potatoes.

Insight #2: High Forecast Quantiles

Out-of-stocks are highly undesirable in grocery retail, which means that the Afresh ordering policy typically orders to a very high quantile of the demand forecast.

With distributional forecasts, the policy cares not just about accuracy, but also about calibration. If the policy predicts demand for avocados will be less than a given value 95% of the time, is it actually right 95% of the time?

Afresh’s decision-making system intentionally focuses on ensuring the calibration of the upper quantiles of our forecast to avoid out-of-stocks, which means lost potential sales. As seen in the chart below, the upper quantiles of the forecast are very well calibrated.

Experimental Results, Lessons Learned, and Future Work

ShrinkAware debuted earlier this year with impressive results — reducing shrink by 5-10% more than our legacy policy. This translates to transformational bottom-line savings for grocers.

There were also several learnings from the launch, including necessary adjustments to the decision-making system for different partners. We discovered that given different grocers have different business strategies, a one-size-fits-all approach is not necessarily the best strategy. This has been especially true in the past year when inflation has altered customer behavior. While some grocers are focused on keeping their costs down in a new labor market, others see it as an opportunity to aggressively attract new business.

Ultimately, ShrinkAware better quantifies the trade-offs between various key metrics in an explicit objective function. ShrinkAware has helped reduce food waste on the magnitude of millions of pounds of food waste, which is a significant win for people, profits, and the planet. We look forward to continuing to iterate and improve upon it.

Mark Velednitsky is a Staff Applied Scientist at Afresh, where he designs algorithms to reduce food waste. His research, “Managing Perishable Inventory with Distributional Forecasts,” was presented at LION17.

--

--