Penalty for service outside of the time window
By default, the order handover time doesn't have to fit in the order time window (it's okay if the driver arrives at the order location at 17:59, even though the order time window is until 18:00).
To minimize such cases, use the option options.penalize_late_service
= true
(the default value is false
).
This option determines whether the penalty for being late applies before the handover time starts (false
, the default value) or ends (true
). It means that if true
, the algorithm tries to complete the handling time within the time window.
For example:
The order time window is 8:00–9:00, the handling time is 30 minutes, and the courier arrives at the order location at 8:50.
If
penalize_late_service
=false
, no penalty for being late applies.If
penalize_late_service
=true
, the penalty for a 20-minute delay applies (because the courier is at the order location at 8:50 + 30 minutes = 9:20, they'll miss the time window by 20 minutes).
The order window is 8:00–9:00, the handling time is 30 minutes, and the courier arrives at the order location at 9:10.
If
penalize_late_service
=false
, the penalty for a 10-minute delay applies (it's calculated as the difference between the arrival time and the upper boundary of the time window: 9:10 – 9:00 = 10 minutes).If
penalize_late_service
=true
, the penalty for a 40-minute delay applies (it's calculated as the difference between the arrival time and the service completion time, 9:10 + 30 minutes = 9:40, that is, 40 minutes later than the time window).
By using this option, routes are built so that the handling time fits into the order time window as much as possible. This is especially relevant for multiple orders sharing the same location (for example, multiple stores located in the same shopping center or multiple recipients in the same business center).
This restriction is soft, meaning it needs to be adjusted using the penalty values for late arrival at order location.
Example 1
In this example, the time windows for the orders are 9:00 to 17:00, the handling time for the orders is 30 minutes, and the penalize_late_service
option is disabled. In the example, there is an order with an arrival at 16:52 (so the handling time is extended to 17:22).
API request (JSON) ⋅ API response ⋅ View on map
Example 2
The same data, but penalize_late_service
= true
. You can see that now there are no orders with a handling time outside the time window (after 17:00).