Accommodate last minute tasks
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 such powerful feature is the re-optimization feature which allows the users to tweak an existing solution in face of some last minute changes without changing the existing solution which was already under execution.
In this example, we will generate an original solution for an optimization problem with 2 operators and 5 tasks. Once we get the original solution we will emulate a situation where 2 new high priority orders are received at the very last minute. We, then, will use the re-optimization properties to share the original solution along with the 2 new tasks’ information to be accommodated into the existing route plan.
Configure original optimization request
To configure the original 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.
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 task- 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 2 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:
Original Route Optimization POST request
All the above components are now combined and submitted as a single JSON originally to the Route Optimization endpoint:
Route Optimization POST response
Once the above POST request is successfully submitted, a response similar to the following is received:
Retrieve original 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
We get the original response using the above request. Keep the original route plan suggested in this solution handy as it will be used in the next step.
Re-optimize the original solution
Once the original response is available the operations team starts executing the plan by assigning tasks and sharing route plans with the agents. However, while the plan is in motion, another set of high priority orders are received. In this case, we use the re-optimization features available with NextBillion.ai’s Route Optimization and tweak the original plan to accommodate new orders.
Add new tasks
We add the newly received tasks to the original “jobs” attribute. Following are the new tasks that we use for this job
Configure input with previous solution
Next we prepare the solution
attribute with details of original route plan from the previously generated GET response. This attribute will be added to the input request to generate a re-optimized plan.
Next, we add the solution and the new task details to the second request that we prepare to re-optimize. Following is the input request with re-optimization configured:
Re-optimized solution
Upon submitting the above request we get a new ID to retrieve the re-optimized solution using the GET request. Once we retrieve the response below, we can see the new tasks are also accommodated in the new route plan.
Visit Route Optimization Flexible API documentations to know more about the available optimization features.