POST route optimization problem | Prevent retake the pickup

Let’s suppose that we have Order A, and the driver has completed the pickup of the order.

Order A:

  1. Pickup(completed).
  2. Delivery(pending).

And in middle of the path the driver takes a new order, Order B is closer to the driver than order A.

Although the order A is partially completed, order B is rescheduled as first stop, which it makes to the driver pasts again to the pickup A already completed.

  1. B pickup(pending).
  2. B delivery(pending).
  3. A pickup(completed).
  4. A delivery (pending).

I know that this is an expected behavior if a new order comes, but this is a common use of case. Is there a way to flag or mark a restriction on those stops. I used the priority params in the pickup stop, but it doesn’t work.

This is the example:

{
  "vehicles": [
    {
      "vehicle_id": "91",
      "start_address": {
        "location_id": "current_driver_location",
        "lat": 10.713273,
        "lon": -71.625449
      },
      "return_to_depot": false
    }
  ],
  "vehicle_types": [{ "type_id": "91", "profile": "car" }],
  "relations": [
    {
      "type": "in_same_route",
      "ids": ["6491", "6490", "6405", "6404"],
      "vehicle_id": "91"
    }
  ],
  "configuration": {
    "routing": { "calc_points": true, "return_snapped_waypoints": true }
  },
  "objectives": [{ "type": "min", "value": "completion_time" }],
  "services": [
    {
      "id": "6405",
      "type": "pickup",
      "address": {
        "location_id": "109",
        "lat": 10.6759282,
        "lon": -71.6030925
      },
      "size": [1]
    },
    {
      "id": "6404",
      "type": "delivery",
      "address": {
        "location_id": "168",
        "lat": 10.6703253,
        "lon": -71.6050455
      },
      "size": [1]
    },
    {
      "id": "6491",
      "type": "pickup",
      "address": {
        "location_id": "253",
        "lat": 10.6983333,
        "lon": -71.62527779999999
      },
      "size": [1]
    },
    {
      "id": "6490",
      "type": "delivery",
      "address": {
        "location_id": "254",
        "lat": 10.6775569,
        "lon": -71.60101449999999
      },
      "size": [1]
    }
  ],
  "shipments": [
    {
      "id": "A_pickup_completed",
      "name": "A",
      "pickup": {
        "address": {
          "location_id": "109",
          "lat": 10.6759282,
          "lon": -71.6030925
        }
      },
      "delivery": {
        "address": {
          "location_id": "168",
          "lat": 10.6703253,
          "lon": -71.6050455
        }
      }
    },
    {
      "id": "B_new_order",
      "name": "B",
      "pickup": {
        "address": {
          "location_id": "253",
          "lat": 10.6983333,
          "lon": -71.62527779999999
        }
      },
      "delivery": {
        "address": {
          "location_id": "254",
          "lat": 10.6775569,
          "lon": -71.60101449999999
        }
      }
    }
  ]
}

Any help it will be appreciated.

Thanks.

The “priority” feature is only to decide which jobs goes first into the unassigned list.

To prefer certain shipments over others you can have a look into the relations feature, which is explained in this blog post. Note, that besides the “normal” relation there is a second type of relations which is called “group relations”, which is likely what you want.

Note, that for shipments the handling needs to be done in the following way (cited from the documentation):

If you deal with services then you need to use the ‘id’ of your services in the field ‘ids’. To also consider sequences of the pickups and deliveries of your shipments, you need to use a special ID, i.e. use the shipment id plus the keyword _pickup or _delivery. For example, to ensure that the pickup and delivery of the shipment with the id ‘my_shipment’ are direct neighbors, you need the following specification:

{
   "type": "in_direct_sequence",
   "ids": ["my_ship_pickup","my_ship_delivery"]
}