Free insertion not working for shipment groups

We are using free_insertion along with shipments and would expect that a shipment pickup without a group, when combined with free_insertion: true, would be able to placed before its delivery in the route, but this seems to not be the case.

{
  "configuration": {
    "routing": {
      "calc_points": true,
      "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_1wj5mKgaVhUtXGVYvT5QgtiM0ct2",
      "profile": "car_delivery",
      "capacity": [
        2147483647
      ],
      "speed_factor": 1,
      "service_time_factor": 1
    }
  ],
  "vehicles": [
    {
      "type_id": "vhc_1wj5mKgaVhUtXGVYvT5QgtiM0ct2",
      "vehicle_id": "1wj5mKgaVhUtXGVYvT5QgtiM0ct2",
      "start_address": {
        "location_id": "tAGTH7qQ",
        "lat": 38.75884427355347,
        "lon": -9.137125627154768,
        "curbside": "any"
      },
      "end_address": {
        "location_id": "XNz9tC0sNDCe6w0khD8U",
        "lat": 38.7568556,
        "lon": -9.1389352
      },
      "return_to_depot": true,
      "earliest_start": 1773759346
    }
  ],
  "objectives": [
    {
      "type": "min",
      "value": "completion_time"
    }
  ],
  "services": [],
  "shipments": [
    {
      "id": "0XZCTAlkgbBm8MEXzgnz",
      "name": "Av. do Brasil 14",
      "size": [
        1
      ],
      "priority": 2,
      "pickup": {
        "address": {
          "location_id": "lwic72gZ7QK4V2gd6mEY",
          "lat": 38.7537876,
          "lon": -9.1425309
        },
        "preparation_time": 60,
        "duration": 0,
        "time_windows": []
      },
      "delivery": {
        "address": {
          "location_id": "0XZCTAlkgbBm8MEXzgnz",
          "lat": 38.7550102,
          "lon": -9.2267606
        },
        "duration": 60,
        "time_windows": [],
        "group": "first"
      }
    }
  ],
  "relations": [
    {
      "type": "in_direct_sequence",
      "groups": [
        "start",
        "first"
      ]
    }
  ]
}

This request causes the shipment to be unassigned, rather than placing the pickup before the delivery as expected.

1 Like

Thanks for reporting this - you’re right, this was a bug.

When free_insertion: true is set, ungrouped activities (like your pickup) should be “transparent” in direct sequence relations. We weren’t handling this correctly, causing the shipment
to be unassigned.

This is now fixed and deployed.

Let us know if you have any further issues.