Features

Late arrival time penalty

A how-to guide for using late arrival time penalties with vehicle routing.

This feature is configurable via .json input, without the need for code customization and is available for both the Marketplace app and Platform. You can find a list of all available features here.

The format for timestamps should be RFC3339, e.g.: "2023-01-01T00:00:00Z".

This how-to guide assumes you already completed the get started with vehicle routing tutorial.

Field nameRequiredData typeSI UnitDefined onExampleConfigurable via defaults
target_arrival_timeNotimestampNAstop{"target_arrival_time": "2023-01-01T00:00:00Z"}
late_arrival_time_penaltyNofloatNAstop{"late_arrival_time_penalty": 1.23}

The late_arrival_time_penalty is a cost applied to the objective (value function) when a vehicle arrives at a stop after the given target_arrival_time. These fields are defined on stops, and are useful for discouraging behavior such as hot food being delivered too late.

The value added to the objective is calculated as follows:

late_arrival_time_penalty * max(arrival_time - target_arrival_time, 0)
Copy

For example, if a vehicle arrives at a stop 60 seconds after a target arrival time and the penalty is set to 10, 600 seconds are added to the value function.

Please note that:

  • The time duration given by arrival_time - target_arrival_time is in seconds.
  • When defining a late_arrival_time_penalty on a stop, you must also define a target_arrival_time for that stop.
  • Specifying late_arrival_time_penalty and target_arrival_time on a stop late_arrival_duration of the stop defines the time duration given by brings additional information on the output. For example, the arrival_time - target_arrival_time in seconds, when greater than zero.

Here is an example defining penalties for all stops. A sample output obtained after solving the problem is also shown.

{
  "defaults": {
    "vehicles": {
      "speed": 20,
      "start_time": "2023-01-01T12:00:00Z"
    },
    "stops": {
      "late_arrival_time_penalty": 1.5,
      "duration": 450,
      "unplanned_penalty": 2000000
    }
  },
  "stops": [
    {
      "id": "Fushimi Inari Taisha",
      "location": { "lon": 135.772695, "lat": 34.967146 },
      "target_arrival_time": "2023-01-01T12:00:00Z"
    },
    {
      "id": "Kiyomizu-dera",
      "location": { "lon": 135.78506, "lat": 34.994857 },
      "target_arrival_time": "2023-01-01T12:05:00Z"
    },
    {
      "id": "Nijō Castle",
      "location": { "lon": 135.748134, "lat": 35.014239 },
      "target_arrival_time": "2023-01-01T12:10:00Z"
    },
    {
      "id": "Kyoto Imperial Palace",
      "location": { "lon": 135.762057, "lat": 35.025431 },
      "target_arrival_time": "2023-01-01T12:15:00Z"
    },
    {
      "id": "Gionmachi",
      "location": { "lon": 135.775682, "lat": 35.002457 },
      "target_arrival_time": "2023-01-01T12:20:00Z"
    },
    {
      "id": "Kinkaku-ji",
      "location": { "lon": 135.728898, "lat": 35.039705 },
      "target_arrival_time": "2023-01-01T12:25:00Z"
    },
    {
      "id": "Arashiyama Bamboo Forest",
      "location": { "lon": 135.672009, "lat": 35.017209 },
      "target_arrival_time": "2023-01-01T12:30:00Z"
    }
  ],
  "vehicles": [
    {
      "id": "v1"
    },
    {
      "id": "v2"
    }
  ]
}
Copy

Page last updated