Free_insertion not working as expected with shipments

Hi,

We have the following request where the driver needs to pick up some deliveries at a pickup location, and they also have a service which they want to deliver quickly (marked as first) via:

  "relations": [
    {
      "type": "in_direct_sequence",
      "groups": [
        "start",
        "first"
      ]
    }
  ]

The pickup addresses do not have a “group” assigned, and as free_insertion is set to true we expect that the optimization can pick up those shipments before completing the first delivery. However that doesn’t appear to happen:

{
  "configuration": {
    "routing": {
      "calc_points": false,
      "consider_traffic": false,
      "return_snapped_waypoints": true,
      "network_data_provider": "openstreetmap",
      "snap_preventions": [
        "motorway",
        "tunnel",
        "ferry"
      ],
      "fail_fast": true
    },
    "optimization": {
      "free_insertion": true
    }
  },
  "vehicle_types": [
    {
      "type_id": "vhc_Lj96QaNMepfZifpCK0Ig87WruWD3",
      "profile": "car_avoid_toll",
      "capacity": [
        350000
      ],
      "speed_factor": 1.1764705882352942,
      "service_time_factor": 1
    }
  ],
  "vehicles": [
    {
      "type_id": "vhc_Lj96QaNMepfZifpCK0Ig87WruWD3",
      "vehicle_id": "Lj96QaNMepfZifpCK0Ig87WruWD3",
      "start_address": {
        "location_id": "q95xTAzq",
        "lat": 53.4780705,
        "lon": -1.4189344,
        "curbside": "any"
      },
      "return_to_depot": false,
      "earliest_start": 1778849425
    }
  ],
  "objectives": [
    {
      "type": "min",
      "value": "completion_time"
    }
  ],
  "services": [],
  "shipments": [
    {
      "id": "9Wuyy7zEYlEegsG06FQA",
      "name": "23 Carnaby St",
      "size": [
        0
      ],
      "priority": 2,
      "pickup": {
        "address": {
          "location_id": "OZnOGLPy0LrACRvlBHHa_depot",
          "lat": 51.5072178,
          "lon": -0.1275862,
          "curbside": "any",
          "name": "London, Greater London"
        },
        "preparation_time": 3600,
        "duration": 0,
        "time_windows": []
      },
      "delivery": {
        "address": {
          "location_id": "9Wuyy7zEYlEegsG06FQA",
          "lat": 51.5131498,
          "lon": -0.138561,
          "street_hint": "Carnaby Street",
          "curbside": "any",
          "name": "23 Carnaby St"
        },
        "duration": 60,
        "time_windows": [],
        "group": "middle"
      }
    },
    {
      "id": "DsTFzvXR9fpm9WTnH3Pu",
      "name": "St George's House, 14-17 Wells Street",
      "size": [
        0
      ],
      "priority": 2,
      "pickup": {
        "address": {
          "location_id": "OZnOGLPy0LrACRvlBHHa_depot",
          "lat": 51.5072178,
          "lon": -0.1275862,
          "curbside": "any",
          "name": "London, Greater London"
        },
        "preparation_time": 3600,
        "duration": 0,
        "time_windows": []
      },
      "delivery": {
        "address": {
          "location_id": "DsTFzvXR9fpm9WTnH3Pu",
          "lat": 51.5170127,
          "lon": -0.1373703,
          "street_hint": "St George's House",
          "curbside": "any",
          "name": "St George's House, 14-17 Wells Street"
        },
        "duration": 60,
        "time_windows": [],
        "group": "middle"
      }
    },
    {
      "id": "WMsgciX1i7YEi2b267N3",
      "name": "2nd Floor, 74 Margaret Street",
      "size": [
        0
      ],
      "priority": 2,
      "pickup": {
        "address": {
          "location_id": "OZnOGLPy0LrACRvlBHHa_depot",
          "lat": 51.5072178,
          "lon": -0.1275862,
          "curbside": "any",
          "name": "London, Greater London"
        },
        "preparation_time": 3600,
        "duration": 0,
        "time_windows": []
      },
      "delivery": {
        "address": {
          "location_id": "WMsgciX1i7YEi2b267N3",
          "lat": 51.5169656,
          "lon": -0.1391707,
          "street_hint": "Margaret Street",
          "curbside": "any",
          "name": "2nd Floor, 74 Margaret Street"
        },
        "duration": 60,
        "time_windows": [],
        "group": "middle"
      }
    },
    {
      "id": "8OVn70B2yKDXbzkCqubo",
      "name": "1-5 Maple Pl",
      "size": [
        0
      ],
      "priority": 2,
      "pickup": {
        "address": {
          "location_id": "OZnOGLPy0LrACRvlBHHa_depot",
          "lat": 51.5072178,
          "lon": -0.1275862,
          "curbside": "any",
          "name": "London, Greater London"
        },
        "preparation_time": 3600,
        "duration": 0,
        "time_windows": []
      },
      "delivery": {
        "address": {
          "location_id": "8OVn70B2yKDXbzkCqubo",
          "lat": 51.5222583,
          "lon": -0.137858,
          "street_hint": "1-5 Maple Place",
          "curbside": "any",
          "name": "1-5 Maple Pl"
        },
        "duration": 60,
        "time_windows": [],
        "group": "middle"
      }
    },
    {
      "id": "7nYH3cnpcnlUhqUxHGHz",
      "name": "A52, Donington",
      "size": [
        0
      ],
      "priority": 1,
      "pickup": {
        "address": {
          "location_id": "OZnOGLPy0LrACRvlBHHa_depot",
          "lat": 51.5072178,
          "lon": -0.1275862,
          "curbside": "any",
          "name": "London, Greater London"
        },
        "preparation_time": 3600,
        "duration": 0,
        "time_windows": []
      },
      "delivery": {
        "address": {
          "location_id": "7nYH3cnpcnlUhqUxHGHz",
          "lat": 52.89936809232614,
          "lon": -0.228007547557354,
          "curbside": "any",
          "name": "A52, Donington"
        },
        "duration": 60,
        "time_windows": [],
        "group": "first"
      }
    }
  ],
  "relations": [
    {
      "type": "in_direct_sequence",
      "groups": [
        "start",
        "first"
      ]
    }
  ]
}

Instead the first shipment is actually delivered last, and the optimization delivers other shipments before it even though they have a group assigned (middle). From what I understand this appears to be a bug as I expect free_insertion would only let shipment activities without a group be inserted anywhere.

1 Like

This is fixed now. Thanks a lot :folded_hands:!

PS: If you still see an issue with shipments and groups, please let me know.

1 Like