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 name | Required | Data type | SI Unit | Defined on | Example | Configurable via defaults |
|---|---|---|---|---|---|---|
precedes | No | array of object or array of string or string | NA | stop | {"precedes": ["foo", "bar"]} | ➖ |
succeeds | No | array of object or array of string or string | NA | stop | {"succeeds": ["foo", "bar"]} | ➖ |
The precedence constraint is used to indicate that a specific stop must be visited (pickup) before a different one (dropoff). You can use the precedes and succeeds fields on the stops of the input to work with precedence constraints as follows.
precedes: ensures that the pickup is visited before the dropoff. It is applied to the individual stop that must be visited before the stopiddefined in theprecedesfield.succeeds: can be used to model the precedence relation the other way around. Using the same example as above, the opposite would be specified: on the dropoff stop we define that it needs to succeed its pickup counterpart.
Both precedes and succeeds may be specified as:
- a
stringvalue that specifies a relationship with a single stop given by itsid. - an
arrayofstringvalues that specifies a relationship with multiple stops given by theirids. This array is unordered meaning that the order of the stops in the array will not be enforced in the assigned route. - an
arrayofobjectvalues that specifies a relationship with multiple stops given by theirids and an optional fielddirect. Ifdirectis set to true, this means that there can be not stop between the two stops on which the precedence relationship is defined.
Here is an example defining both types of precedence relationships and their types. A sample output obtained after solving the problem is also shown.
Note that all stops that have a precedence relationship that groups them together will be assigned to the same vehicle in the final solution.
Both, precedes and succeeds, can be used in combination to model more complex precedence relationships.