Features

Compatibility attributes

A how-to guide for using compatibility attributes 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.

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

Field nameRequiredData typeSI UnitDefined onExampleConfigurable via defaults
compatibility_attributesNoarray of stringNAvehicle{"compatibility_attributes": ["foo", "bar"]}
compatibility_attributesNoarray of stringNAstop{"compatibility_attributes": ["foo", "bar"]}

In vehicle routing problems stops can sometimes only be served by specific vehicles. E.g., some delivery items may need a cooling system to keep fresh or maybe larger items must be delivered on a truck and do not fit in a smaller vehicle.

The compatibility_attributes feature can be added to vehicles and stops to specify characteristics of the vehicle and requirements of the stop. This is done by specifying an array of string (list of attributes) for stops and vehicles.

  • Stops that have configured attributes are only compatible with vehicles that match at least one of them. The vehicle may have additional attributes that are not specified on the stop.
  • If you want all attributes to be considered when matching, you can concatenate them into a single string and specify that as the only element of the array. Instead of having ["A", "B", "C"] as the attributes, change them for ["A,B,C"].
  • Stops that do not have any specified attributes are compatible with any vehicle.
  • Vehicles that do not have any specified attributes are only compatible with stops without attributes.

compatibility_attributes determine whether a vehicle is eligible to service a stop and ultimately whether a given solution is feasible.

For each vehicle, add the relevant attributes to the compatibility_attributes array, as needed. The string must be an exact match for the relevant vehicles and stops; spelling or phrasing errors will prevent correct attribute matching.

Here is an example input defining an assortment of stops and vehicles with or without compatibility attributes. A sample output obtained after solving the problem is also shown.

{
  "defaults": {
    "vehicles": {
      "speed": 20
    }
  },
  "stops": [
    {
      "id": "Fushimi Inari Taisha",
      "location": { "lon": 135.772695, "lat": 34.967146 }
    },
    {
      "id": "Kiyomizu-dera",
      "location": { "lon": 135.78506, "lat": 34.994857 }
    },
    {
      "id": "Nijō Castle",
      "location": { "lon": 135.748134, "lat": 35.014239 },
      "compatibility_attributes": ["level_1"]
    },
    {
      "id": "Kyoto Imperial Palace",
      "location": { "lon": 135.762057, "lat": 35.025431 },
      "compatibility_attributes": ["level_1"]
    },
    {
      "id": "Gionmachi",
      "location": { "lon": 135.775682, "lat": 35.002457 },
      "compatibility_attributes": ["level_2"]
    },
    {
      "id": "Kinkaku-ji",
      "location": { "lon": 135.728898, "lat": 35.039705 },
      "compatibility_attributes": ["level_2"]
    },
    {
      "id": "Arashiyama Bamboo Forest",
      "location": { "lon": 135.672009, "lat": 35.017209 },
      "compatibility_attributes": ["level_3"]
    }
  ],
  "vehicles": [
    {
      "id": "v1",
      "start_location": { "lon": 135.772695, "lat": 34.967146 }
    },
    {
      "id": "v2",
      "compatibility_attributes": ["level_1"],
      "start_location": { "lon": 135.762057, "lat": 35.025431 }
    },
    {
      "id": "v3",
      "compatibility_attributes": ["level_1", "level_2"],
      "start_location": { "lon": 135.78506, "lat": 34.994857 }
    },
    {
      "id": "v4",
      "compatibility_attributes": ["level_3"]
    }
  ]
}
Copy

Page last updated