Skip to content

Alternate stops

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.

Field name Required Data type SI Unit Defined on Example Configurable via defaults
alternate_stops No array of alternate_stop NA input {"alternate_stops": [{"id": "Inafuku","location": { "lon": 123, "lat": 456 }}]}
alternate_stops No array of string NA vehicle {"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.

Warning

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"]
    }
  ]
}
{
  "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",
        "objectives": [
          {
            "base": 925.145499687516,
            "factor": 1,
            "name": "vehicles_duration",
            "value": 925.145499687516
          },
          {
            "base": 4000000,
            "factor": 1,
            "name": "unplanned_penalty",
            "value": 4000000
          }
        ],
        "value": 4000925.1454996876
      },
      "unplanned": [],
      "vehicles": [
        {
          "alternate_stops": [
            "Inari"
          ],
          "id": "v1",
          "route": [
            {
              "cumulative_travel_duration": 0,
              "stop": {
                "id": "v1-start",
                "location": {
                  "lat": 35.017209,
                  "lon": 135.672009
                }
              },
              "travel_duration": 0
            },
            {
              "cumulative_travel_duration": 0,
              "stop": {
                "id": "Arashiyama Bamboo Forest",
                "location": {
                  "lat": 35.017209,
                  "lon": 135.672009
                }
              },
              "travel_duration": 0
            },
            {
              "cumulative_travel_distance": 5752,
              "cumulative_travel_duration": 287,
              "stop": {
                "id": "Kinkaku-ji",
                "location": {
                  "lat": 35.039705,
                  "lon": 135.728898
                }
              },
              "travel_distance": 5752,
              "travel_duration": 287
            },
            {
              "cumulative_travel_distance": 9081,
              "cumulative_travel_duration": 454,
              "stop": {
                "id": "Nijō Castle",
                "location": {
                  "lat": 35.014239,
                  "lon": 135.748134
                }
              },
              "travel_distance": 3329,
              "travel_duration": 166
            },
            {
              "cumulative_travel_distance": 10857,
              "cumulative_travel_duration": 542,
              "stop": {
                "id": "Kyoto Imperial Palace",
                "location": {
                  "lat": 35.025431,
                  "lon": 135.762057
                }
              },
              "travel_distance": 1776,
              "travel_duration": 88
            },
            {
              "cumulative_travel_distance": 13696,
              "cumulative_travel_duration": 684,
              "stop": {
                "id": "Gionmachi",
                "location": {
                  "lat": 35.002457,
                  "lon": 135.775682
                }
              },
              "travel_distance": 2839,
              "travel_duration": 141
            },
            {
              "cumulative_travel_distance": 14897,
              "cumulative_travel_duration": 745,
              "stop": {
                "id": "Kiyomizu-dera",
                "location": {
                  "lat": 34.994857,
                  "lon": 135.78506
                }
              },
              "travel_distance": 1201,
              "travel_duration": 60
            },
            {
              "cumulative_travel_distance": 18263,
              "cumulative_travel_duration": 913,
              "stop": {
                "id": "Inari",
                "location": {
                  "lat": 34.9686029,
                  "lon": 135.7666538
                }
              },
              "travel_distance": 3366,
              "travel_duration": 168
            }
          ],
          "route_duration": 913,
          "route_travel_distance": 18263,
          "route_travel_duration": 913
        },
        {
          "alternate_stops": [
            "Inafuku"
          ],
          "id": "v2",
          "route": [
            {
              "cumulative_travel_duration": 0,
              "stop": {
                "id": "v2-start",
                "location": {
                  "lat": 34.967146,
                  "lon": 135.772695
                }
              },
              "travel_duration": 0
            },
            {
              "cumulative_travel_duration": 0,
              "stop": {
                "id": "Fushimi Inari Taisha",
                "location": {
                  "lat": 34.967146,
                  "lon": 135.772695
                }
              },
              "travel_duration": 0
            },
            {
              "cumulative_travel_distance": 236,
              "cumulative_travel_duration": 11,
              "stop": {
                "id": "Inafuku",
                "location": {
                  "lat": 34.9671591,
                  "lon": 135.770104
                }
              },
              "travel_distance": 236,
              "travel_duration": 11
            }
          ],
          "route_duration": 11,
          "route_travel_distance": 236,
          "route_travel_duration": 11
        }
      ]
    }
  ],
  "statistics": {
    "result": {
      "custom": {
        "activated_vehicles": 2,
        "max_duration": 0.123,
        "max_stops_in_vehicle": 7,
        "max_travel_duration": 0.123,
        "min_duration": 0.123,
        "min_stops_in_vehicle": 2,
        "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"
  }
}