Group nearby orders
Product 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.
Order grouping feature creates clusters of tasks which are located within a given radius of each other and treats them as one stop. Delivery drivers can park the vans at a suitable place and complete the all grouped deliveries quickly. This saves the time that, otherwise, would have been spent on driving up to each nearby location and finding a parking spot for each of them.
In this example, we will set up a Route Optimization request to fulfill 5 delivery jobs while employing the order grouping feature to group nearby tasks, if they match a given criteria. The optimization service will then take into account all the variables specified in the input request and return optimal routes and task assignments to meet the configured objective. Let’s set up the problem statement in the following sections.
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 locations
object with all the coordinates to be used in this example:
Jobs & Shipments
We define a bunch of delivery jobs that need to be performed in this example. Following are the constraints that we set for these tasks:
- A unique “id” for each task
- “location_index” for each task
- “delivery” amounts for all tasks
- The actual time taken to complete the delivery once the driver/vehicle is at the task’s location i.e. the “service” time for each task.
Let’s take a look at the “jobs” JSON after the above properties are configured:
Vehicles
In this step we will configure the delviery van that will fulfilling the above delivery jobs. To configure the van and its properties, we add: A unique ID for the van “capacity” of the load that the van can take A “start_index” for the location from which the van starts
Following is the vehicles
JSON with all the above properties configured:
Options
Lastly we set the grouping criteria for the nearby tasks in the above optimization problem. We set the following constraints:
- Configure the “grouping_diameter” to group tasks together if they are within the given straight line distance.”.
Following is the “options” JSON:
Route Optimization POST request
All the above components are now combined and submitted as a single JSON to the Route Optimization endpoint host:
Route Optimization POST request
Once the above POST request is successfully submitted, a response similar to the following is received:
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
Route Optimization GET response
You would see the solution with all the suggested routes and the tasks that were assigned to each of the vans.
We can see that the 5 jobs are grouped in 2 groups. The location of the common stop for each group is returned in the “projected_location” field.
Visit Route Optimization Flexible API documentation to know more about the available features.