Max Ride Time
In certain industries like car-pooling and emergency services, reducing the amount of time spent in vehicles is a critical factor in assessing the competitive advantage of a business. Optimizing pickups and drop-offs such that the total time in the vehicle for the passengers or field service agents does not exceed a given threshold can be quite complex for traditional softwares. NextBillion.ai’s Route Optimization Flexible API provides this capability as an out of the box feature for shipments. max_time_in_vehicle
allows users to configure the threshold for such tasks and the optimization engine then treats it as a hard filter while determining possible route plans.
Let’s take a look at the following example where we generate an optimized routing plan for a business which doesn’t want its shipments to stay in the vehicle for more than a specific amount of time.
Setup
We have 4 shipments to be made using 2 delivery vans which start from a fixed, common location. Each of the shipments are configured to stay in the vehicle for a specific amount of time. Let’s configure the shipments, vehicles and location attributes one by one below.
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:
Shipments
Next, we define the 4 shipments in our problem statement. For each shipment we add:
- Details of pickup leg along with a unique identifier
- Details of delivery leg using the same unique identifier as the corresponding pickup leg
amount
or the quantity of the items/goods to be shippedmax_time_in_vehicle
limiting the time for which the shipment can stay in the van. For one of the shipments, we will deliberately give a duration which is not enough to complete the delivery after starting from the corresponding pickup location.
Following is the JSON we use in this example:
Vehicles
Now we configure 2 delivery vans that will be responsible for fulfilling the shipments. We specify:
- A unique ID for each vehicle
start_index
to denote the common start location for both vehiclescapacity
to indicate the amount of load that can be carried
Once the vehicle and their properties are defined, the resulting vehicles
JSON is:
Optimization POST Request
When all the above components are put together we get 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 use the request ID and retrieve the result through the Optimization GET request. Following is the GET request:
Optimization GET Response
Following is the optimized route plan:
Following image shows a visual representation of the above route plan.
![documentation image](https://static.nextbillion.io/docs-next/docs/route-optimization/max-ride-time.webp)
Analyzing the Solution
Looking at the result we can observe that:
- 3 shipments (i.e. 6 tasks) were fulfilled and one shipment (i.e. 2 tasks) remained unassigned. The total cost of the solution is 1061.
- Only 1 vehicle was used to fulfill all shipments
- The Shipment 1 was delivered with 290 seconds, Shipment 2 with 294 seconds and Shipment 3 with 89 seconds of drive time. Hence, all shipments met the max ride time criteria specified for each of them.
- Shipment 4 could not be completed as the minimum drive time needed to go from its pickup location to delivery location is around 330 seconds and the max ride time configured for it was only 240 seconds.
- Under
unassigned
attribute, the response also shares the reason why the two legs of shipment 4 remained unfulfilled. It was because of “MaxTimeInVehicleConstraint”, indicating that the max ride time constraint was the culprit.
Above example exhibits how NextBillion.ai’s Route Optimization Flexible API uses the max ride time constraints to solve the problem and suggests the most optimized route plan. We encourage you to go ahead and try out different configurations of max_time_in_vehicle
, and multiple distribution of shipments to explore how the solution changes 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.