Time Limits for Perishable Loads

Product Used: Route Optimization API

Background

Consider a fresh food producer running two refrigerated vans from a central kitchen in Houston to cafes, grocery counters and a hospital cafeteria. To prevent food spoilage, all shipments must arrive at their destination within a pre-determined safe transit window after dispatch from the kitchen. Orders are small and frequent, and a delivery run usually serves several accounts. The complication is that the cheapest plan on a map, the one that minimises driving, can leave the last order on board longer than its window allows.

Problem Statements

Building a routing plan that delivers every load inside its window raises two challenges:

Chaining drops past the safe window

A van that leaves the kitchen with several orders serves them in one run, and every stop adds drive time to the orders still on board. Distance or duration based route planning minimises the drive across the run rather than the time any one load spends in the vehicle, so an account can receive stock after its window has closed when it is served last. The store refuses the delivery and a replacement trip is required.

Finding the orders that cannot make it

Windows differ by product and accounts are spread across the metro, so some mornings an order cannot reach its store in time on any route. The drive from the kitchen looks ordinary, so a plan built by hand or on distance schedules the order anyway, and the gap surfaces only when the driver is at the door with stock too old to hand over. Dispatchers need to know which orders are out of reach before the vans leave.

Solution

NextBillion.ai's Route Optimization API supports a time on board limit for each shipment, letting dispatchers cap how long a load stays in the vehicle.

Cap the time on board for each load

Model each order as one of the shipments, with the kitchen as the pickup and the account’s location as the delivery. Configure shipments.max_time_in_vehicle limits to decide how long, in seconds, that load may stay in the vehicle, so each product keeps its own window on the same van. The API counts drive time only, from the end of the pickup until the delivery, and service time at stops in between is not added. It is a hard filter, so the optimizer never plans a delivery beyond the cap. In our example scenario, sushi orders are capped at 25 minutes and the sandwich order at an hour:

1
{
2
"pickup": {
3
"id": "Pickup-Downtown Cafe",
4
"location_index": 0,
5
"service": 300
6
},
7
"delivery": {
8
"id": "Delivery-Downtown Cafe",
9
"location_index": 1,
10
"service": 600
11
},
12
"amount": [8],
13
"max_time_in_vehicle": 1500
14
}

Hold back the orders that cannot arrive in time

An order whose own drive from the kitchen exceeds its safe time limit cannot be served by any sequence. The API leaves it out of the plan rather than routing it late. Read the reasons for entries appearing in result.unassigned after each run, to find such orders and send those orders another way.

Sample Request and Response

Following is a JSON request that we built for this case and the corresponding response:

API Request

1
curl --location 'https://api.nextbillion.io/optimization/v2?key=<your_api_key>' --header 'Content-Type: application/json' --data '{...}'

API Response

1
{
2
"status": "Ok",
3
"result": {
4
"summary": "{...}",
5
"unassigned": "[...]",
6
"routes": "[...]"
7
}
8
}

We can verify from the solution that every load arrives inside its cap. Refrigerated Van 2 returns to the kitchen twice to reload, so each order with a 25 minute cap is the first drop after a load. The longest load, Medical Center Cafeteria, spends 1,788 seconds on board (delivery duration 3754 minus pickup duration 1966) against a cap of 3,600. Only West Suburb Grocery is unassigned, for the time in vehicle limit, so the dispatcher can arrange different plans for it.