Route optimization
By default, Timefold optimizes routes to minimize the amount of time drivers spend driving between stops. This lowers costs, reduces emissions, and makes drivers more productive as they spend less time driving.
1. Minimize travel time
The Minimize travel time soft constraint adds a soft score penalty to the dataset score for every second of travel in a route plan.
Timefold is incentivized to use the route plan with the best score.
|
Soft constraints compete with each other as the solver optimizes the final solution. That means this constraint may leave jobs unassigned in favor of jobs with different soft constraints. Every soft constraint has a weight that can be configured to change the relative importance of the constraint compared to other constraints. Learn about constraint weights. |
2. Required reachable itineraries and stops
Every driver shift itinerary needs to represent a route that is reachable on the map. For instance, a shift starting on the mainland cannot be assigned a job stop located on an island which is not connected by a route to the mainland.
In case a driver shift itinerary contains an unreachable route, it gets penalized with a hard score penalty by one or both of the following constraints:
-
Require reachable itineraries: Penalizes a driver shift itinerary that contains an unreachable route caused by an unreachable stop, break, or shift end location. -
Require reachable stops: Penalizes a stop which is unreachable from the location of the previous stop in the itinerary or the driver shift start location (in the case of the first stop in the itinerary).
The model output elements DriverShiftPlan, StopPlan and BreakPlan contain the unreachable boolean attribute indicating:
-
DriverShiftPlan.unreachable = true: The driver shift itinerary contains a route between two locations that is unreachable on the map, such a route can be:-
From the driver shift start location to the first stop or break with location.
-
From a break with location to the next break with location or the next stop.
-
From a stop to the next break with location or the next stop.
-
From the last stop or break with location to the driver shift end location.
-
-
StopPlan.unreachable = true: The previous itinerary item is unreachable or the route from the previous stop, location break, or driver shift start to the stop location is not reachable on the map. -
BreakPlan.unreachable = true: The previous itinerary item is unreachable or the route from the previous stop, location break, or driver shift start to the break location is not reachable on the map.
The unreachable attribute is omitted when false to avoid increasing payload size.
Example of model output containing an unreachable route to Stop A and Break B in a driver shift itinerary:
{
"shifts": [
{
"id": "Ann - Monday",
"itinerary": [
{
"id": "Stop A",
"kind": "STOP",
"unreachable": true
},
{
"id": "Break B",
"kind": "BREAK",
"startTime": "2026-01-12T14:00:00-04:00",
"endTime": "2026-01-12T15:00:00-04:00",
"unreachable": true
}
],
"unreachable": true
}
]
}
Next
-
See the full API spec or try the online API.