Features

Alternate stops

A how-to guide for using alternate stops 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
alternate_stopsNoarray of alternate_stopNAinput{"alternate_stops": [{"id": "Inafuku","location": { "lon": 123, "lat": 456 }}]}
alternate_stopsNoarray of stringNAvehicle{"alternate_stops": ["foo", "bar"]}
  • alternate_stop: An alternate stop has all the same fields as a stop excluding the following:
    • precedes
    • succeeds
    • compatibility_attributes

If your vehicles need to stop at one of several optional stop locations (e.g. to recharge a battery, refuel, or take a break), you can use the alternate stops feature. The vehicle will be assigned exactly one stop from the list of alternate stops and, in addition, may be assigned normal stops.

As opposed to using initial stops (where one stop can only be serviced by one vehicle), one alternate stop can be serviced by many different vehicles.

To use this feature, define an array of alternate_stops in your input. Then, you can set alternate stops on each vehicle by referencing the id of the alternate stop as part of the alternate_stops field in the vehicle.

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

{
  "alternate_stops": [
    {
      "id": "Inafuku",
      "location": { "lon": 135.770104, "lat": 34.9671591 }
    },
    {
      "id": "Inari",
      "location": { "lon": 135.7666538, "lat": 34.9686029 }
    }
  ],
  "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 }
    },
    {
      "id": "Kyoto Imperial Palace",
      "location": { "lon": 135.762057, "lat": 35.025431 }
    },
    {
      "id": "Gionmachi",
      "location": { "lon": 135.775682, "lat": 35.002457 }
    },
    {
      "id": "Kinkaku-ji",
      "location": { "lon": 135.728898, "lat": 35.039705 }
    },
    {
      "id": "Arashiyama Bamboo Forest",
      "location": { "lon": 135.672009, "lat": 35.017209 }
    }
  ],
  "vehicles": [
    {
      "id": "v1",
      "start_location": { "lon": 135.672009, "lat": 35.017209 },
      "speed": 20,
      "alternate_stops": ["Inari", "Inafuku"]
    },
    {
      "id": "v2",
      "start_location": { "lon": 135.772695, "lat": 34.967146 },
      "speed": 20,
      "alternate_stops": ["Inafuku", "Inari"]
    }
  ]
}
Copy

Page last updated