Vehicle: Max Distance & Max Travel time
The total distance that a vehicle can drive or the total travel time that a vehicle can operate for, is an important business constraint for many logistics providers as well as fleet owners. NextBillion.ai’s Route Optimization Flexible API offers two independent parameters - max_distance
and max_travel_time
for each vehicle, to implement similar real-world business limitations easily. These parameters can be leveraged to optimize the usage of vehicles and prevent them against unexpectedly high operating costs, potential breakdowns or just control the fuel consumptions.
Get Started
Readers would need a valid NextBillion API key to try this example out. If you don’t have one, please contact us to get your API key now!
Setup
In this example, we will complete 8 deliveries using 3 vehicles and each of the vehicles will have either one or both distance and travel time limitations. We define the locations, delivery jobs, vehicles and their constraints one by one in the following sections.
Locations
First, we define the locations
object and add all the location coordinates used in the problem along with a valid id
. The locations
object used in this example:
Jobs
Next, we define 8 delivery jobs. For each delivery task we add:
- A unique identifier
- Location index
- Delivery quantity
- A service time to carry out the delivery
Let’s take a look at the
jobs
JSON after the above properties are configured:
Vehicles
Next, we add 3 vehicles that are going to fulfill the deliveries within the defined constraints of max_travel_time
and max_distance
. To describe the vehicles and their properties we add:
- A unique ID for each vehicle
capacity
indicating the amount of load that the vehicle can takestart_index
to denote the point from where the vehicle would start.max_distance
to limit the total distance that the vehicle can travelmax_travel_time
to limit the total drive time of the vehicle.
Once the vehicle and their properties are defined, the resulting vehicles
JSON is:
Optimization POST Request
Now let’s put all these components together and create the final POST request that we will submit to the optimizer.
Optimization POST Response
Once the request is made, we get a unique ID in the API response:
Optimization GET Request
We take the ID and use the Optimization GET request to retrieve the result. Here is the GET request:
Optimization GET Response
Following is the optimized route plan:
Following image shows a visual representation of the above route plan.
Analyzing the Solution
Looking at the result we can draw following insights:
- We can see that 6 deliveries were completed and 2 were left unassigned.
- Only 2 vehicles were used to complete the 6 deliveries.
- Vehicle 1 covered a total of ~6.8 kms with a total drive time of around 12 minutes. Both these metric are well under 15kms distance and 1 hr of drive time constraints specified.
- Similarly, Vehicle 3 covered a total distance of ~ 12.5 kms with a total drive time of around 26 minutes, which again is less than the allowed 15 kms of drive distance and 35 mins of drive time.
- The 2 deliveries which remain unassigned were due to these travel limit constraints as we can see from the “reason” field of
unassigned
attribute in the response. - The locations of these 2 deliveries are too far from the starting point of the unused vehicle 2 and the location of last deliveries that vehicle 1 & 3 make, such that they can not be fulfilled without violating the
max_distance
constraint.
Above example demonstrates how NextBillion.ai’s Route Optimization Flexible API works within the configured operational constraints of each vehicle and suggests the best solution while honoring those constraints. We encourage you to try out different configurations of vehicle or task locations, number of tasks, and different distance and travel time constraint values to explore how varying solutions are returned under different scenarios presented to Route Optimization Flexible API.
Learn more about the other powerful features and the related use cases that Route Optimization Flexible API can solve for you.