Route Optimization Flexible Tutorials

Basic Route Optimization

In this example we will play around with basic constraints offered in’s Route Optimization Flexible API. The constraints covered here are time windows of jobs, vehicle shift timings, skills needed to complete the tasks and capacities involved to carry out pickup/delivery type tasks. We specifically demonstrate how the time windows are used to determine the job sequence & assignment and if the time windows are such that they could not be honored then the task would be left unassigned. We will also see how the starting and ending stops for the vehicle are configured when they are assigned to depots versus when they are not assigned to depots.

Constraints: Maximum Waiting Time

In this example, we learn about the hard constraint of maximum waiting time.’s Route Optimization Flexible API provides options to control how long the driver must wait after arriving at the task's location. It is worth noting that this is a hard constraint and applies to all the tasks given in the problem. This feature is helpful when users want to manage the wait times of their drivers or when achieving the lowest wait times is a crucial business goal (for example, consumer-facing services). Let's look at how to incorporate this functionality into an optimization request.

Custom Cost Matrix

In this example, we cover an interesting feature of assigning user-defined travel costs of traveling from one point to another.’s Route Optimization Flexible API would then use these custom costs to arrange the job fulfillment in a way such that the overall costs are minimum.

Custom Objective: Equal Task Distribution

Custom Objective is a valuable feature that empowers users to pursue unique objectives which are significantly different from the typical approach of minimizing travel costs. This feature allows users to tune the optimization algorithm to achieve following objectives:

Re-Optimization: New Tasks’s Route Optimization Flexible API offers a powerful re-optimization feature which allows the users to re-optimize a set of existing or new tasks by readjusting some variables, if needed.

Re-Optimization: Unassigned Tasks’s Route Optimization Flexible API offers a powerful re-optimization feature which allows the users to fulfill previously unassigned tasks by readjusting some variables. These variables can be the number of vehicles included in the optimization request, modifying the shift timings or capacities of the vehicles involved or changing the task time windows or any other strategy that would increase the chances of higher task assignments.

Task Sequencing

Relations are used to specify the association between different tasks that should be performed in a certain order.’s Route Optimization Flexible API offers three types of relations that the users can enforce:

Vehicle costs

In this example, we learn about the vehicle cost attributes.’s Route Optimization Flexible API currently provides two types of vehicle costs - fixed and per_hour costs. Fixed costs are the cost of using the vehicle irrespective of how long the vehicle remains in use. Driver fee, license fee, taxes etc can be thought of as fixed costs. If only the fixed cost of the vehicle is provided then it will be added to the travel_cost of the route.

Soft Constraints

The Soft Constraints feature enables users to complete more tasks by treating specific time-related limitations as flexible.’s Route Optimization Flexible API currently allows vehicle shift timings and task time windows to be made flexible up to a configurable degree. This functionality is useful in commercial scenarios where job completion ratio is the most crucial measure and time constraints are not strict. Let’s build an example to understand how these constraints work.

Vehicle: Max Travel Cost and Max Tasks

In this example we will learn about some useful vehicle constraints.’s Route Optimization Flexible API provides options to control the maximum number of tasks that a vehicle can serve and also the maximum travel cost that it can incur. These parameters can be used to limit the usage of vehicles and prevent them against unexpected high costs, potential breakdowns or just control the fuel consumptions.

Order Grouping’s Route Optimization Flexible API offers a simple but useful feature, called order grouping, that enhances the driver experience by conveniently planning a common stop for multiple tasks located closeby.


Depots are an important piece of any logistic operations and serve as a center for fulfilling customer orders.

Zone Based Allocations

Zone based allocations refers to the ability of’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.

Route Grouping

Route Grouping is a powerful feature which deals with how a route plan is actually executed and helps users in achieving highly efficient routes. When used, route grouping attributes tune the algorithm to avoid, as much as possible, overlapping of different routes as well as any back and forth movement of vehicles on a road segment.