HOS compliant Truck Routes

Products Used: Route Optimization Flexible API

NextBillion.ai’s Route Optimization API provides users with a high degree of customization by leveraging over 50+ parameters to closely emulate the real-world constraints of route planning. One such feature is drive_time_layover_config which is quite helpful in complying with Hours of Service regulations laid out for truck drivers. drive_time_layover_config allows users to specify the maximum driving time after which the drivers need to take a break.

Once the request with details of rest/break configurations is submitted, the optimization service suggests optimal routes, task assignments and the break sequences to best meet the configured objective

To configure a Route Optimization request we will need to set up the locations involved, the tasks to be performed, vehicles to be used and the hours of service configurations. Let’s address them one by one below.

Configure optimization request

Locations

First we define the locations object and add all the locations used in the problem along with a valid id. Following is the the locations object with all the coordinates to be used in this example:

1
"locations": "[...]"

Jobs & Shipments

Next, we define the delivery tasks that need to be performed in this example. We define the following properties for each task:

A unique “id” A “location_index” The “time_windows” within which the deliveries need to be performed. “delivery” amounts

Let’s take a look at the “jobs” JSON after the above properties are configured:

1
"jobs": "[...]"

Vehicles

Next, we define a delivery truck that is responsible for fulfilling the above tasks. We define the properties of the delivery truck by adding:

  • A unique ID
  • Truck’s or the driver’s shift timings using the “time_window” parameter
  • “capacity” of the load that the truck can accommodate
  • “end_index” to denote the point where the truck would end its trip.
  • The hours of service configurations that require the truck to take a break of 15 mins after driving for every 75 mins.
    • We add a “max_continous_driving” time of 4500 secs (~ 75 mins)
    • We add a layover_duration of 900 seconds (~15 mins)

Following is the vehicles JSON with all the above properties configured:

1
"vehicles": "[...]"

Route Optimization POST request

Next we combine all the above components and submit the below JSON to the Route Optimization endpoint:

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

Route Optimization POST response

Once the above POST request is successfully submitted, a response similar to the following is received:

1
{
2
"id": "0b396bfd18961a45e938153d646572cc",
3
"message": "Optimization job created",
4
"status": "Ok"
5
}

Retrieve optimization solution

Capture the task “id” from the POST response and use it in a subsequent GET request to retrieve the optimized solution asynchronously:

Route Optimization GET request

1
curl --location 'https://api.nextbillion.io/optimization/v2/result?id=0b396bfd18961a45e938153d646572cc&key=<your_api_key>'

Route Optimization GET response

On retrieving the optimized result we get a summary of all key parameters along with the suggested route that the delivery truck takes to perform all the tasks.

1
{
2
"description": "Drive Time Layover Config",
3
"result": {
4
"summary": "{...}"
5
}
6
}’

Visit Route Optimization API documentation to know more about the available features.

© 2024 NextBillion.ai all rights reserved.