You are viewing Nextmv legacy docs. ⚡️ Go to latest docs ⚡️

Features

Precedence

You will learn the basics of a delivery use case on cloud.

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 stop id defined in the precedes 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:

  1. order-1-pickup uses the precedes field to specify that that the pickup should be serviced before the dropoff.
  2. order-2-dropoff uses the succeeds field to specify that the dropoff should be serviced after the pickup.
  3. order-3-pickup uses the precedes field to specify that the pickup should be serviced before multiple dropoffs.
  4. order-4-dropoff uses the succeeds field to specify that the dropoff should be serviced after multiple pickups.
{
  "defaults": {
    "vehicles": {
      "start": { "lon": -96.8281, "lat": 32.9983 },
      "end": { "lon": -96.8281, "lat": 32.9983 },
      "shift_start": "2021-08-24T09:00:00-06:00",
      "speed": 10
    }
  },
  "vehicles": [
    { "id": "vehicle-1", "capacity": 60 },
    { "id": "vehicle-2", "capacity": 30 }
  ],
  "stops": [
    {
      "id": "order-1-pickup",
      "position": { "lon": -96.8434, "lat": 32.9867 },
      // Make this pickup precede its dropoff counterpart
      "precedes": "order-1-dropoff",
      "quantity": -27
    },
    {
      "id": "order-1-dropoff",
      "position": { "lon": -96.8459, "lat": 33.0002 },
      "quantity": 27
    },
    {
      "id": "order-2-pickup",
      "position": { "lon": -96.7947, "lat": 33.0138 },
      "quantity": -15
    },
    {
      "id": "order-2-dropoff",
      "position": { "lon": -96.8093, "lat": 32.9959 },
      // Make this dropoff succeed its pickup counterpart
      "succeeds": "order-2-pickup",
      "quantity": 15
    },
    {
      "id": "order-3-pickup",
      "position": { "lon": -97.8434, "lat": 31.9867 },
      // Make this pickup precede its two dropoff counterparts
      "precedes": ["order-3-dropoff1", "order-3-dropoff2"],
      "quantity": -27
    },
    {
      "id": "order-3-dropoff1",
      "position": { "lon": -97.8459, "lat": 32.7842 },
      "quantity": 15
    },
    {
      "id": "order-3-dropoff2",
      "position": { "lon": -97.6259, "lat": 32.0002 },
      "quantity": 12
    },
    {
      "id": "order-4-pickup1",
      "position": { "lon": -97.8434, "lat": 31.9867 },
      // Make this pickup precede its two dropoff counterparts
      "precedes": ["order-3-dropoff1", "order-3-dropoff2"],
      "quantity": -27
    },
    {
      "id": "order-4-pickup2",
      "position": { "lon": -97.8459, "lat": 32.7842 },
      "quantity": 15
    },
    {
      "id": "order-4-dropoff",
      "position": { "lon": -97.6259, "lat": 32.0002 },
      "quantity": 12,
      // Make this dropoff succeed its two pickup counterparts
      "succeeds": ["order-4-pickup1", "order-4-pickup2"]
    },
  ]
}
Copy

Page last updated