Extend agent shift timings
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. One of the features is “max_vehicle_lateness” which allows the agents to operate for a specified amount of additional time beyond their shift timings. Leverage this additional time to fulfill additional tasks at the cost of a known penalty.
In this example, we have 1 operator who is allowed to work for additional 30 mins beyond the usual shift timings if it makes him fulfill more tasks by utilizing the additional time.
Configure optimization request
To configure a Route Optimization request we will need to set up the locations, tasks, vehicles and the constraints involved in our use case. 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 5 tasks and the starting point of the agent. Following is the locations
object with all the coordinates to be used in this example:
Jobs
We define 5 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 tasktime_windows
to specify the duration within which the task has to be completed- Time taken to complete the task once the agent is at the task’s location i.e. the “service” time for each task.
Let’s take a look at the “jobs” after the above properties are configured:
Vehicles
Next, we add details about the agent that is responsible for fulfilling the above tasks. For the agent, we add:
- A unique ID
- “start_index” to denote the point from where the agent starts.
- “time_window” to indicate the usual shift timings of the agent
Following is the vehicles
JSON with all the above properties configured:
Options
Next, we add the configuration to allow the agent to extend his shift by 30 mins if needed to fulfill additional tasks. We use the max_vehicle_overtime
property under “options” to do so
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 optimizer has assigned all the tasks and there are no unassigned tasks. We also see that the “Job 5” which was scheduled outside the usual shift timings of the agent is also fulfilled as the agent was allowed to extend his shift time by 30 mins, if needed. In the response we can see that “vehicle_overtime” field returns the amount of additional duration that the agent worked for, to complete this task.
Visit Route Optimization Flexible API documentations to know more about the available optimization features.