Link and test logistics models for demand forecasting, shift scheduling, and vehicle routing

Follow this step-by-step tutorial to go from a forecasted demand to optimized routes for delivery and similar use cases. Create and customize decision apps using OR-Tools, HiGHS, Pyomo, and more.

Are you working on multiple logistics models that use different modeling tools and solvers? Are you interested in linking them and understanding how these models impact each other? Do you want to run experiments on your models to confidently implement changes that improve your operations? 

In this post, we’ll walk through three logistics models (demand forecasting, shift scheduling, and vehicle routing) for a hypothetical farm share business that delivers produce boxes from local farms to customers’ homes. 

We’ll use the output of an OR-Tools-based demand forecasting app (forecasted order volume) plus targets as the input for the HiGHS shift scheduling app. Then we’ll use the output of the shift scheduling app (driver shift assignments) as the input for the Nextmv vehicle routing app. We’ll solve for route assignments that we’ll analyze using the experimentation tools in the Nextmv platform.

To get started, all you need to do is create a free Nextmv account and head to the Marketplace page

Run the OR-Tools Demand Forecasting app

The OR-Tools Demand Forecasting app uses least absolute deviation (LAD) regression with historical demand data to create a demand forecast for the farm share company’s produce boxes

  1. Click ‘Clone app’
  2. Give the app a name (e.g., ‘My demand forecasting app’)
  3. Click ‘Run app’
  4. Load sample input, ‘Demand (large)’
  5. Click ‘Start run’

The input data takes in timezone and demands (includes historical order volume).

The result is forecasted demand for the next 28 days.

Run the HiGHS Shift Scheduling app

The goal of the HiGHS Shift Scheduling app is to schedule workers (in this case, drivers for the farm share business) to shifts based on forecasted demand. 

  1. Click ‘Clone app’
  2. Give the app a name (e.g., ‘My shift scheduling app’)
  3. Click ‘Run app’
  4. Load sample input, ‘Large example’
  5. Click ‘Start run’

The input for the app is workers (available workers) and required workers (based on forecasted demand from the previous app).

The result gives us the schedule: an array of assigned shifts (worker ID and timeframe).

Run the Nextmv Vehicle Routing app

The goal of the Nextmv Routing app is to assign drivers (workers) to routes based on actual orders.

  1. Click ‘Clone app’
  2. Give the app a name (e.g., ‘My vehicle routing app’)
  3. Click ‘Run app’
  4. Load sample input, ‘Distribution Ex. Day 1’
  5. Click ‘Start run’
  6. Create two more runs using the sample inputs ‘Distribution Ex. Day 2’ and ‘Distribution Ex. Day 3’

Input is vehicles and stops (output from shift scheduling app).

The result is vehicle routes. We can see the workers (drivers) assigned and the routes on the map. 

Create an experiment

We’ve now run our three logistics modes and we’ve linked them by using the output of one for the input of the next. However, at the farm share company, our operators are telling us that our drivers are unhappy because we’re scheduling them to shifts and then only a few are actually being assigned to routes. The drivers would also prefer to have routes localized to smaller clusters so they aren’t driving across town. 

We think that by activating the cluster option (and penalizing routes that aren’t tightly clustered according to how big their radius is) we will create more desirable routes — and we will also add more drivers to the schedule to cover the additional routes. We want to test out this hypothesis using an acceptance test and historical run data. First, we’ll activate the cluster objective.

Create a new instance 

  1. Open the routing app you created
  2. Create a new instance
  3. Give it a name (‘cluster activated’)
  4. Set the configuration option to model.objectives.cluster: 1
  5. Click ‘Create instance’

Create an input set

Next, we’ll group our latest runs together to use in the test by creating an input set.

  1. Open the routing app you created
  2. Click on ‘Experiments’ on the left-hand side 
  3. Click on ‘Input sets’ and then ‘New input set’
  4. Give it a name (e.g., ‘April in Lancaster’)
  5. Select Date Range: ‘Past 24 hours’
  6. Click ‘Create input set’

Create an acceptance test

We’ll use an acceptance test to see if the new instance of the model delivers the expected results: more activated drivers. 

  1. Click on ‘Acceptance’ and then ‘New acceptance test’
  2. Give it a name (e.g., Test cluster objective)
  3. Baseline: Latest (default)
  4. Candidate: Cluster Activated
  5. Select the input set you just created
  6. Define metricssome text
    1. result.custom.activated_vehicles : should increase or be equal
    2. result.value : should increase or be equal
  7. Click ‘Create & run acceptance test’

The results of the acceptance test show the metric changes that we expected, and are indicated with a green checkmark. We can see that the ‘cluster-activated’ instance uses a mean of 34 vehicles (or drivers) compared to the original model that uses a mean of 4.3 vehicles.

We also saw that the solution value increases (which we expected) since we introduced clustered routes as the objective.

So far it seems our model changes are producing more favorable solutions given our business requirements. From here, we would continue to tune our model updates and test changes before promoting a new model to production. 

Try it with your data 

Create a free Nextmv account to run these logistics models with your own data and make updates with confidence. Start with prebuilt apps and then customize them using modeling tools and solvers such as OR-Tools, Gurobi, HiGHS, AMPL, and Pyomo.

Have questions? Let’s chat! Hop into our forum or reach out to us directly

Video by:
No items found.