Zone Based Allocations

Zone based allocations refers to the ability of NextBillion.ai’s Route Optimization service to allow or prohibit certain vehicles from operating in a certain zone. The zones can be configured on the fly while building the input optimization request or can refer to geofence IDs created using Geofence API. Zone based allocations are a practical way to avoid overlapping coverage, longer traveling distance and other inefficiencies during route planning. On top of these benefits, it also helps in leveraging the knowledge and experience of drivers by making them operate in a familiar neighborhood, thereby improving the service delivery.

Setup

In this example we define 4 custom zones and 12 delivery tasks spread across these zones. We will use 4 vehicles to complete these tasks with each vehicle allowed to fulfill tasks in one zone only. We will start by configuring the locations and other entities one by one.

Locations

We start by adding all the locations used in the problem along with a valid id. The locations object with all the points used in this example:

1
{
2
"locations":"[...]"
3
}

Jobs

Next we define the 12 delivery tasks. For each task we:

  • add an unique identifier
  • add a location index
  • add a delivery quantity
  • add zone IDs to which the task belongs to. Although, service can auto-allocate the tasks to specific zones based on the task’s location and zone geometries.

Following is the “jobs” JSON that we use

1
{
2
"jobs":"[...]"
3
}

Zones

Next we would create custom boundaries to divide the serviceable area into 4 zones. Zones can be created on the fly by providing geoJSON attributes for each of the polygons or by using NextBillion.ai’s Geofence API and then using those geofence IDs as an input to zones.geofence_id.

For our example, we use the geoJSON details of each of the zones and provide them as input in the zones attribute.

1
{
2
"zones":"[...]"
3
}

Vehicles

Next, we add 4 vehicles that will be responsible for fulfilling the deliveries within the defined zones. To describe the vehicles and their properties we add:

  • A unique ID for each vehicle
  • start_index to denote the point from where the vehicle would start
  • allowed_zones to specify the zone where each of the vehicles is allowed to fulfill the deliveries
  • capacity for each vehicle

Once the vehicle and their properties are defined, the resulting vehicles JSON is:

1
{
2
"vehicles":"[...]"
3
}

Optimization POST Request

Now let’s put all these components together and create the final POST request that we will submit to the optimizer.

1
curl --location 'https://api.nextbillion.io/optimization/v2?key=<your_api_key>' --header 'Content-Type: application/json' --data '{
2
"description":"Zone Allocation Example",
3
"locations":" {....}",
4
"jobs": "{....}",
5
}'

Optimization POST Response

Once the request is made, we get a unique ID in the API response:

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

Optimization GET Request

We take the ID and use the Optimization GET request to retrieve the result. Here is the GET request:

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

Optimization GET Response

Following is the optimized route plan:

1
{
2
"description": "Zone Allocation Example",
3
"result": {
4
"summary": "{...}",
5
"routes": "[....]"
6
}
7
}

Following image shows a visual representation of the above route plan

documentation image

Analyzing the Solution

From the result we observe that:

  • All the tasks were assigned and the total cost of the route plan is 4247
  • Each of the vehicles fulfill tasks from its assigned zones only, without any overlapping regions. However, depending on the starting point of the vehicles they can travel through restricted zones, but will not fulfill tasks in such zones.

The above example exhibits how NextBillion.ai’s Route Optimization Flexible API allows users to create custom zones and then choose which vehicles can fulfill tasks in what zones, ensuring streamlined operations and better service delivery. We encourage you to go ahead and try out different ways of configuring zones, using Geofence API, and letting the service auto-allocate tasks to the zone as per their geolocation and 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.

© 2024 NextBillion.ai all rights reserved.