The precedence constraint is typically used for delivery problems and indicates that a specific stop must be visited before a different stop. For example, a vehicle may need to pick up an order at one stop (order-1-pickup
) before delivering it to another stop (order-1-dropoff
). You can use the precedes
and succeeds
fields at the stops
level of the input schema 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 stopid
defined in theprecedes
field.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
, can be used in combination to model more complex precedence relationships.
Multiple precedence relationships can be specified for a stop by passing an unordered list of IDs in the corresponding precedes
and succeeds
fields.
In the following input, there are four examples depicted:
order-1-pickup
uses theprecedes
field to specify that that the pickup should be serviced before the dropoff.order-2-dropoff
uses thesucceeds
field to specify that the dropoff should be serviced after the pickup.order-3-pickup
uses theprecedes
field to specify that the pickup should be serviced before multiple dropoffs.order-4-dropoff
uses thesucceeds
field to specify that the dropoff should be serviced after multiple pickups.