Skip to content

Late arrival time penalty

Info

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.

Info

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

Field name Required Data type SI Unit Defined on Example Configurable via defaults
target_arrival_time No timestamp NA stop {"target_arrival_time": "2023-01-01T00:00:00Z"}
late_arrival_time_penalty No float NA stop {"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)

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"
    }
  ]
}
{
  "options": {
    "check": {
      "duration": 30000000000,
      "verbosity": "off"
    },
    "format": {
      "disable": {
        "progression": true
      }
    },
    "model": {
      "constraints": {
        "disable": {
          "attributes": false,
          "capacities": null,
          "capacity": false,
          "distance_limit": false,
          "groups": false,
          "maximum_duration": false,
          "maximum_stops": false,
          "maximum_wait_stop": false,
          "maximum_wait_vehicle": false,
          "mixing_items": false,
          "precedence": false,
          "start_time_windows": false,
          "vehicle_end_time": false,
          "vehicle_start_time": false
        },
        "enable": {
          "cluster": false
        }
      },
      "objectives": {
        "capacities": "",
        "cluster": 0,
        "distance": 0,
        "early_arrival_penalty": 1,
        "late_arrival_penalty": 1,
        "min_stops": 1,
        "stop_balance": 0,
        "travel_duration": 0,
        "unplanned_penalty": 1,
        "vehicle_activation_penalty": 1,
        "vehicles_duration": 1
      },
      "properties": {
        "disable": {
          "duration_groups": false,
          "durations": false,
          "initial_solution": false,
          "stop_duration_multipliers": false
        },
        "maximum_time_horizon": 15552000
      },
      "validate": {
        "disable": {
          "resources": false,
          "start_time": false
        },
        "enable": {
          "matrix": false,
          "matrix_asymmetry_tolerance": 20
        }
      }
    },
    "solve": {
      "duration": 10000000000,
      "iterations": 50,
      "parallel_runs": 1,
      "plateau": {
        "absolute_threshold": -1,
        "delay": 0,
        "duration": 0,
        "iterations": 0,
        "relative_threshold": 0
      },
      "run_deterministically": true,
      "solver": {
        "plan_group_size": {
          "delta": 0,
          "delta_after_iterations": 1000000000,
          "max_value": 2,
          "min_value": 2,
          "snap_back_after_improvement": true,
          "start_value": 2,
          "zigzag": true
        },
        "unplan_units": {
          "delta": 2,
          "delta_after_iterations": 125,
          "max_value": -1,
          "min_value": 2,
          "snap_back_after_improvement": true,
          "start_value": 2,
          "zigzag": true
        },
        "unplan_weights": "Vehicle:3,Island:1,Location:293"
      },
      "start_solutions": 1
    }
  },
  "solutions": [
    {
      "objective": {
        "name": "1 * vehicles_duration + 1 * unplanned_penalty + 1 * late_arrival_penalty",
        "objectives": [
          {
            "base": 4273.474940299988,
            "factor": 1,
            "name": "vehicles_duration",
            "value": 4273.474940299988
          },
          {
            "factor": 1,
            "name": "unplanned_penalty",
            "value": 0
          },
          {
            "base": 634.8012353181839,
            "factor": 1,
            "name": "late_arrival_penalty",
            "value": 634.8012353181839
          }
        ],
        "value": 4908.276175618172
      },
      "unplanned": [],
      "vehicles": [
        {
          "id": "v1",
          "route": [
            {
              "arrival_time": "2023-01-01T12:00:00Z",
              "cumulative_travel_duration": 0,
              "duration": 450,
              "end_time": "2023-01-01T12:07:30Z",
              "start_time": "2023-01-01T12:00:00Z",
              "stop": {
                "id": "Fushimi Inari Taisha",
                "location": {
                  "lat": 34.967146,
                  "lon": 135.772695
                }
              },
              "target_arrival_time": "2023-01-01T12:00:00Z",
              "travel_duration": 0
            },
            {
              "arrival_time": "2023-01-01T12:12:57Z",
              "cumulative_travel_distance": 6553,
              "cumulative_travel_duration": 327,
              "duration": 450,
              "end_time": "2023-01-01T12:20:27Z",
              "start_time": "2023-01-01T12:12:57Z",
              "stop": {
                "id": "Kyoto Imperial Palace",
                "location": {
                  "lat": 35.025431,
                  "lon": 135.762057
                }
              },
              "target_arrival_time": "2023-01-01T12:15:00Z",
              "travel_distance": 6553,
              "travel_duration": 327
            },
            {
              "arrival_time": "2023-01-01T12:22:49Z",
              "cumulative_travel_distance": 9392,
              "cumulative_travel_duration": 469,
              "duration": 450,
              "end_time": "2023-01-01T12:30:19Z",
              "late_arrival_duration": 169,
              "start_time": "2023-01-01T12:22:49Z",
              "stop": {
                "id": "Gionmachi",
                "location": {
                  "lat": 35.002457,
                  "lon": 135.775682
                }
              },
              "target_arrival_time": "2023-01-01T12:20:00Z",
              "travel_distance": 2839,
              "travel_duration": 141
            }
          ],
          "route_duration": 1819,
          "route_stops_duration": 1350,
          "route_travel_distance": 9392,
          "route_travel_duration": 469
        },
        {
          "id": "v2",
          "route": [
            {
              "arrival_time": "2023-01-01T12:00:00Z",
              "cumulative_travel_duration": 0,
              "duration": 450,
              "end_time": "2023-01-01T12:07:30Z",
              "start_time": "2023-01-01T12:00:00Z",
              "stop": {
                "id": "Kiyomizu-dera",
                "location": {
                  "lat": 34.994857,
                  "lon": 135.78506
                }
              },
              "target_arrival_time": "2023-01-01T12:05:00Z",
              "travel_duration": 0
            },
            {
              "arrival_time": "2023-01-01T12:10:49Z",
              "cumulative_travel_distance": 3994,
              "cumulative_travel_duration": 199,
              "duration": 450,
              "end_time": "2023-01-01T12:18:19Z",
              "late_arrival_duration": 49,
              "start_time": "2023-01-01T12:10:49Z",
              "stop": {
                "id": "Nijō Castle",
                "location": {
                  "lat": 35.014239,
                  "lon": 135.748134
                }
              },
              "target_arrival_time": "2023-01-01T12:10:00Z",
              "travel_distance": 3994,
              "travel_duration": 199
            },
            {
              "arrival_time": "2023-01-01T12:21:06Z",
              "cumulative_travel_distance": 7323,
              "cumulative_travel_duration": 366,
              "duration": 450,
              "end_time": "2023-01-01T12:28:36Z",
              "start_time": "2023-01-01T12:21:06Z",
              "stop": {
                "id": "Kinkaku-ji",
                "location": {
                  "lat": 35.039705,
                  "lon": 135.728898
                }
              },
              "target_arrival_time": "2023-01-01T12:25:00Z",
              "travel_distance": 3329,
              "travel_duration": 166
            },
            {
              "arrival_time": "2023-01-01T12:33:23Z",
              "cumulative_travel_distance": 13075,
              "cumulative_travel_duration": 653,
              "duration": 450,
              "end_time": "2023-01-01T12:40:53Z",
              "late_arrival_duration": 203,
              "start_time": "2023-01-01T12:33:23Z",
              "stop": {
                "id": "Arashiyama Bamboo Forest",
                "location": {
                  "lat": 35.017209,
                  "lon": 135.672009
                }
              },
              "target_arrival_time": "2023-01-01T12:30:00Z",
              "travel_distance": 5752,
              "travel_duration": 287
            }
          ],
          "route_duration": 2453,
          "route_stops_duration": 1800,
          "route_travel_distance": 13075,
          "route_travel_duration": 653
        }
      ]
    }
  ],
  "statistics": {
    "result": {
      "custom": {
        "activated_vehicles": 2,
        "max_duration": 0.123,
        "max_stops_in_vehicle": 4,
        "max_travel_duration": 0.123,
        "min_duration": 0.123,
        "min_stops_in_vehicle": 3,
        "min_travel_duration": 0.123,
        "unplanned_stops": 0
      },
      "duration": 0.123,
      "value": 0.123
    },
    "run": {
      "duration": 0.123,
      "iterations": 50
    },
    "schema": "v1"
  },
  "version": {
    "sdk": "VERSION"
  }
}