Distribute tasks equally
Product Used: Route Optimization 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. Users can leverage the custom settings for tuning the algorithm to achieve their business objectives. One of the custom settings is to distribute the tasks equally among all the operators as much as possible.
In this example, we have 4 agents who need to fulfill 12 tasks which are randomly distributed across a region. To highlight the impact of the custom algorithm settings we will keep the starting points of all 4 vehicles the same. The optimization service will take into account all the constraints and return the best feasible solution with tasks equally distributed.
To configure this Route Optimization request we will need to set up the locations, vehicles involved and the tasks to be performed. Let’s address them one by one below.
Configure optimization request
To configure a Route Optimization request we will need to set up the locations, tasks, vehicles involved along with the custom objective. Let’s address them one by one below.
Locations
We configure the locations
attribute and add all the locations used in the problem along with a valid id
. We add locations for all 12 tasks and the starting point of the agents. Following is the locations
object with all the coordinates to be used in this example:
Jobs
We define 12 tasks 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- Time taken to complete the task once the agent is at the task’s location i.e. the “service” time for each task.
Following is the “jobs” attribute after the above properties are configured:
Vehicles
Next, we add details about the 4 agents that are responsible for fulfilling the above tasks. For each agent, we add:
- A unique ID
- “start_index” to denote the point from where the agent starts.
Following is the vehicles
JSON with all the above properties configured:
Options
Next, we define our objective of equally distributing the tasks among all available agents. We use the custom
objective options to configure it
Route Optimization POST request
All the above components are now combined and submitted as a single JSON to the Route Optimization endpoint:
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
In the response, we see that the service has distributed the tasks equally among all the available agents with each of them getting 3 tasks to complete.
Visit Route Optimization Flexible API documentations to know more about the available optimization features.