Case study 5 of 5

Last-Mile Load OptimisationDeciding how much of each product a delivery van should carry to its retailers

Every carton put on a delivery van is loaded by hand, and every carton the retailers do not buy is unloaded by hand again. The model predicts how much of each product each retailer will buy, so vans carry what sells and far less stock is handled twice.

For
Japan Tobacco International (JTI), through Alumnus Software
When
2018 – 2020
My role
Built the van-loading models
Carton movements
18–26%fewer, across four sales regions

The problem

Each sales rep drives a van of stock along a planned route of shops. Every carton goes onto the van by hand. Load too much, and the stock rides round all day and comes off again, carton by carton, by hand. Load too little, and a shop goes without, which the client wanted to keep very rare.

So the question, for every rep, every product and every visit day, was how much to load. It covered four sales regions and 45 products in each.

What I built

It started as a proof of concept. The model became a multi-step method rather than a single model, with one structure shared by the four regions and its settings tuned for each region and product: 180 tuned sets in all.

How it works

What it readsvisit planspast shipmentsvan loading, unloadingstock collectionscredit requestsbank holidays, Easterweather historyfor each shop and product, each visit day1 · Will it buy?random forest2 · How much?year, month, week: averagedspecial-days modeltoo little history:a simpler modelper shop3 · Load per vanadd up the shops+ buffer from its historycapped by type of day(holiday, Easter, normal)The loading planper van, product, daytracked in Power BIWhat it readsvisit planspast shipmentsvan loading, unloadingstock collectionscredit requestsbank holidaysEasterweather historyfor each shop and product, each visit day1 · Will it buy?random forest2 · How much?year, month, week: averagedspecial-days modeltoo little history:a simpler modelforecast per shop3 · Load per vanadd up the shops+ buffer from its historycapped by type of day(holiday, Easter, normal)The loading planper van, product, daytracked in Power BI
Two questions per shop, then one decision per van. The safety margin is added once, at the van, not to every shop. Drawn from the project code.

Hard parts and decisions

Four choices shaped the model. For each: what I could have done, and what I chose.

  1. Two questions, not one

    A shop does not buy every product on every visit, so most of the answers are zero.

    Could have
    Trained one regression model to predict the quantity directly, zeros included.
    Chose
    First predict whether a shop will buy; then, only for the shops that will, predict how much.
  2. One structure, tuned 180 ways

    Four regions and 45 products, each selling in its own way.

    Could have
    One model with one set of settings for everything.
    Chose
    The same structure everywhere, with its settings tuned for each region and product.
    Cost
    180 sets of settings to tune and keep up to date.
  3. The safety margin goes on the van

    The client wanted shops to run out very rarely, so the plan needed a margin. The question was where to put it.

    Could have
    Padded every shop's forecast, which adds up to a lot of spare stock.
    Chose
    Add up the shop forecasts per van, then add one buffer based on that van's own history: larger on Double and Triple Deal Days, and capped by limits for the type of day.
    Cost
    More rules to tune: the buffer, and a cap for each type of day.
  4. Weather and holidays as inputs

    Holidays, Easter and the weather all change what a shop buys, and past sales alone do not show it coming.

    Could have
    Used dates and past sales alone.
    Chose
    Scrape historical weather, flag bad-weather spells, count the days to Easter and mark holidays, with a separate model for special days.
    Cost
    A web scraper to keep running, and a second model to train.

On JTI's Double and Triple Deal Days, registered trade partners and retailers earn two or three times the usual promotional incentives (loyalty points, bonus stock or cash rebates) on qualifying wholesale orders, for a short, limited window. That is why the van's buffer is larger on those days.

Making it reliable

Outcome

18–26%fewer carton movements, and 8 to 13 points less stock unloaded, across the four regions, with shops still very rarely out of stock.

It went into production on Dataiku, one of three products the team shipped for JTI.

My role and the team

I built the van-loading models, with random forests and XGBoost, as one of the first six members of Alumnus Software's data-science team, which grew to 39.

Stack