Hey,
we make use of the relations-feature, where we sometimes tell the API in which sequence a route optimization result should be returned.
In this particular example, one shipment is not assigned with the message “could not be assigned due to relation constraint”. The thing is - we cannot find why. The given order is correct, also the other relations shouldn’t affect this shipment.
The example:
What is our mistake?
The request
{
"New item - 2": {
"configuration": {
"routing": {
"calc_points": false
}
},
"objectives": [
{
"type": "min",
"value": "completion_time"
}
],
"vehicles": [
{
"vehicle_id": "vehicle_Start_Endpunkt",
"start_address": {
"location_id": "location_start_Start_Endpunkt",
"lat": 48.03595,
"lon": 10.711760999999999,
"name": "Startpunkt </br>Betriebshof</br>Schule"
},
"end_address": {
"location_id": "location_end_Start_Endpunkt",
"lat": 48.045651999999997,
"lon": 10.787269,
"name": "Endpunkt </br>Schule</br>RW Holzhausen"
},
"type_id": "vehicletype_Start_Endpunkt_small_truck",
"return_to_depot": true
}
],
"vehicle_types": [
{
"type_id": "vehicletype_Start_Endpunkt_small_truck",
"profile": "small_truck",
"capacity": [
8
],
"speed_factor": 1.0,
"service_time_factor": 1.0
}
],
"shipments": [
{
"id": "halt_186469",
"name": "Einstieg | 06:17 Hauptstraße 11 D, 86922 Eresing Drifte, Till | 11150 Einstieg - 1 Minute(n)",
"pickup": {
"address": {
"location_id": "start_halt_186469",
"name": "Einstieg | 06:17 Hauptstraße 11 D, 86922 Eresing Drifte, Till | 11150 Einstieg - 1 Minute(n)",
"lat": 48.089858,
"lon": 11.024122999999999
},
"duration": 60
},
"delivery": {
"address": {
"location_id": "end_halt_186469",
"name": "Ausstieg | 07:44 Magnusstraße 3, 86859 Igling Drifte, Till | 11150 Ausstieg - 1 Minute(n)Pittrich, Sophie | 11094 Ausstieg - 1 Minute(n)Lützenburger, Henri Felix | 11138 Ausstieg - 1 Minute(n)Weiskopf, Ludwig | 11129 Ausstieg - 1 Minute(n)Gregori, Florian | 11195 Ausstieg - 0 Minute(n)",
"lat": 48.045651999999997,
"lon": 10.787269
},
"duration": 60
},
"size": [
1
],
"priority": 3,
"max_time_in_vehicle": 3600
},
{
"id": "halt_186470",
"name": "Einstieg | 06:51 Eresinger Str. 9, 86926 Pflaumdorf Pittrich, Sophie | 11094 Einstieg - 1 Minute(n)",
"pickup": {
"address": {
"location_id": "start_halt_186470",
"name": "Einstieg | 06:51 Eresinger Str. 9, 86926 Pflaumdorf Pittrich, Sophie | 11094 Einstieg - 1 Minute(n)",
"lat": 48.087826999999997,
"lon": 11.055637000000001
},
"duration": 60
},
"delivery": {
"address": {
"location_id": "end_halt_186470",
"name": "Ausstieg | 07:44 Magnusstraße 3, 86859 Igling Drifte, Till | 11150 Ausstieg - 1 Minute(n)Pittrich, Sophie | 11094 Ausstieg - 1 Minute(n)Lützenburger, Henri Felix | 11138 Ausstieg - 1 Minute(n)Weiskopf, Ludwig | 11129 Ausstieg - 1 Minute(n)Gregori, Florian | 11195 Ausstieg - 0 Minute(n)",
"lat": 48.045651999999997,
"lon": 10.787269
},
"duration": 60
},
"size": [
1
],
"priority": 3,
"max_time_in_vehicle": 3600
},
{
"id": "halt_186472",
"name": "Einstieg | 06:59 Beurerstraße 7, 86926 Greifenberg Weiskopf, Ludwig | 11129 Einstieg - 1 Minute(n)",
"pickup": {
"address": {
"location_id": "start_halt_186472",
"name": "Einstieg | 06:59 Beurerstraße 7, 86926 Greifenberg Weiskopf, Ludwig | 11129 Einstieg - 1 Minute(n)",
"lat": 48.071319000000003,
"lon": 11.083625
},
"duration": 60
},
"delivery": {
"address": {
"location_id": "end_halt_186472",
"name": "Ausstieg | 07:44 Magnusstraße 3, 86859 Igling Drifte, Till | 11150 Ausstieg - 1 Minute(n)Pittrich, Sophie | 11094 Ausstieg - 1 Minute(n)Lützenburger, Henri Felix | 11138 Ausstieg - 1 Minute(n)Weiskopf, Ludwig | 11129 Ausstieg - 1 Minute(n)Gregori, Florian | 11195 Ausstieg - 0 Minute(n)",
"lat": 48.045651999999997,
"lon": 10.787269
},
"duration": 60
},
"size": [
1
],
"priority": 3,
"max_time_in_vehicle": 3600
},
{
"id": "halt_186471",
"name": "Einstieg | 07:04 Kaagangerstr. 7, 82279 Eching am Ammersee Lützenburger, Henri Felix | 11138 Einstieg - 1 Minute(n)",
"pickup": {
"address": {
"location_id": "start_halt_186471",
"name": "Einstieg | 07:04 Kaagangerstr. 7, 82279 Eching am Ammersee Lützenburger, Henri Felix | 11138 Einstieg - 1 Minute(n)",
"lat": 48.076968999999998,
"lon": 11.115007
},
"duration": 60
},
"delivery": {
"address": {
"location_id": "end_halt_186471",
"name": "Ausstieg | 07:44 Magnusstraße 3, 86859 Igling Drifte, Till | 11150 Ausstieg - 1 Minute(n)Pittrich, Sophie | 11094 Ausstieg - 1 Minute(n)Lützenburger, Henri Felix | 11138 Ausstieg - 1 Minute(n)Weiskopf, Ludwig | 11129 Ausstieg - 1 Minute(n)Gregori, Florian | 11195 Ausstieg - 0 Minute(n)",
"lat": 48.045651999999997,
"lon": 10.787269
},
"duration": 60
},
"size": [
1
],
"priority": 3,
"max_time_in_vehicle": 3600
},
{
"id": "halt_186473",
"name": "Einstieg | 07:12 Hauptstr. 41, 82284 Grafrath Gregori, Florian | 11195 Einstieg - 0 Minute(n)",
"pickup": {
"address": {
"location_id": "start_halt_186473",
"name": "Einstieg | 07:12 Hauptstr. 41, 82284 Grafrath Gregori, Florian | 11195 Einstieg - 0 Minute(n)",
"lat": 48.124141999999999,
"lon": 11.164550999999999
},
"duration": 0
},
"delivery": {
"address": {
"location_id": "end_halt_186473",
"name": "Ausstieg | 07:44 Magnusstraße 3, 86859 Igling Drifte, Till | 11150 Ausstieg - 1 Minute(n)Pittrich, Sophie | 11094 Ausstieg - 1 Minute(n)Lützenburger, Henri Felix | 11138 Ausstieg - 1 Minute(n)Weiskopf, Ludwig | 11129 Ausstieg - 1 Minute(n)Gregori, Florian | 11195 Ausstieg - 0 Minute(n)",
"lat": 48.045651999999997,
"lon": 10.787269
},
"duration": 0
},
"size": [
1
],
"priority": 3,
"max_time_in_vehicle": 3600
},
{
"id": "191594",
"name": "bp_191594",
"pickup": {
"address": {
"location_id": "start_191594",
"name": "bp_191594",
"lat": 48.035173,
"lon": 10.715085999999999
},
"duration": 0
},
"delivery": {
"address": {
"location_id": "end_191594",
"name": "bp_191594",
"lat": 48.035173,
"lon": 10.715085999999999
},
"duration": 0
},
"size": [
1
],
"priority": 3
}
],
"services": [
{
"id": "192099",
"name": "Freier Wegpunkt Kapellenweg 0, 86947 Weil Manueller Wegpunkt Wartezeit: 0 Minute(n) ",
"address": {
"location_id": "start_192099",
"name": "Freier Wegpunkt Kapellenweg 0, 86947 Weil Manueller Wegpunkt Wartezeit: 0 Minute(n) ",
"lat": 48.143156584554141,
"lon": 10.909320227801802
},
"duration": 0,
"size": [
0
]
}
],
"relations": [
{
"type": "in_direct_sequence",
"ids": [
"halt_186469_pickup",
"192099",
"halt_186470_pickup",
"halt_186472_pickup",
"halt_186471_pickup",
"halt_186473_pickup",
"halt_186473_delivery",
"halt_186471_delivery",
"halt_186472_delivery",
"halt_186470_delivery"
]
},
{
"type": "in_direct_sequence",
"ids": [
"start",
"191594_pickup"
]
},
{
"type": "in_direct_sequence",
"ids": [
"191594_delivery",
"end"
]
}
]
}
}
The result
{
"New item - 2": {
"copyrights": [
"GraphHopper",
"OpenStreetMap contributors"
],
"job_id": "cc317f99-c6b0-40bd-abbd-a7aeba1b3319",
"status": "finished",
"waiting_time_in_queue": 0,
"processing_time": 417,
"solution": {
"costs": 291,
"distance": 109961,
"time": 7226,
"transport_time": 7226,
"completion_time": 7586,
"max_operation_time": 7586,
"waiting_time": 0,
"service_duration": 360,
"preparation_time": 0,
"no_vehicles": 1,
"no_unassigned": 1,
"routes": [
{
"vehicle_id": "vehicle_Start_Endpunkt",
"shift_id": "default-shift",
"distance": 109961,
"transport_time": 7226,
"completion_time": 7586,
"waiting_time": 0,
"service_duration": 360,
"preparation_time": 0,
"activities": [
{
"type": "start",
"location_id": "location_start_Start_Endpunkt",
"address": {
"location_id": "location_start_Start_Endpunkt",
"name": "Startpunkt Betriebshof Schule",
"lat": 48.03595,
"lon": 10.711760999999999
},
"end_time": 0,
"end_date_time": null,
"distance": 0,
"driving_time": 0,
"preparation_time": 0,
"waiting_time": 0,
"load_after": [
0
]
},
{
"type": "pickupShipment",
"id": "191594",
"location_id": "start_191594",
"address": {
"location_id": "start_191594",
"name": "bp_191594",
"lat": 48.035173,
"lon": 10.715085999999999
},
"arr_time": 130,
"arr_date_time": null,
"end_time": 130,
"end_date_time": null,
"waiting_time": 0,
"distance": 388,
"driving_time": 130,
"preparation_time": 0,
"load_before": [
0
],
"load_after": [
1
]
},
{
"type": "service",
"id": "192099",
"location_id": "start_192099",
"address": {
"location_id": "start_192099",
"name": "Freier Wegpunkt Kapellenweg 0, 86947 Weil Manueller Wegpunkt Wartezeit: 0 Minute(n) Entfernen ",
"lat": 48.143156584554141,
"lon": 10.909320227801802
},
"arr_time": 1506,
"arr_date_time": null,
"end_time": 1506,
"end_date_time": null,
"waiting_time": 0,
"distance": 29795,
"driving_time": 1506,
"preparation_time": 0,
"load_before": [
1
],
"load_after": [
1
]
},
{
"type": "pickupShipment",
"id": "halt_186470",
"location_id": "start_halt_186470",
"address": {
"location_id": "start_halt_186470",
"name": "Einstieg | 06:51 Eresinger Str. 9, 86926 Pflaumdorf Pittrich, Sophie | 11094 Einstieg - 1 Minute(n) ",
"lat": 48.087826999999997,
"lon": 11.055637000000001
},
"arr_time": 2685,
"arr_date_time": null,
"end_time": 2745,
"end_date_time": null,
"waiting_time": 0,
"distance": 46022,
"driving_time": 2685,
"preparation_time": 0,
"load_before": [
1
],
"load_after": [
2
]
},
{
"type": "pickupShipment",
"id": "halt_186472",
"location_id": "start_halt_186472",
"address": {
"location_id": "start_halt_186472",
"name": " Einstieg | 06:59 Beurerstraße 7, 86926 Greifenberg Weiskopf, Ludwig | 11129 Einstieg - 1 Minute(n) ",
"lat": 48.071319000000003,
"lon": 11.083625
},
"arr_time": 3191,
"arr_date_time": null,
"end_time": 3251,
"end_date_time": null,
"waiting_time": 0,
"distance": 49499,
"driving_time": 3131,
"preparation_time": 0,
"load_before": [
2
],
"load_after": [
3
]
},
{
"type": "pickupShipment",
"id": "halt_186471",
"location_id": "start_halt_186471",
"address": {
"location_id": "start_halt_186471",
"name": " Einstieg | 07:04 Kaagangerstr. 7, 82279 Eching am Ammersee Lützenburger, Henri Felix | 11138 Einstieg - 1 Minute(n) ",
"lat": 48.076968999999998,
"lon": 11.115007
},
"arr_time": 3472,
"arr_date_time": null,
"end_time": 3532,
"end_date_time": null,
"waiting_time": 0,
"distance": 52460,
"driving_time": 3352,
"preparation_time": 0,
"load_before": [
3
],
"load_after": [
4
]
},
{
"type": "pickupShipment",
"id": "halt_186473",
"location_id": "start_halt_186473",
"address": {
"location_id": "start_halt_186473",
"name": "Einstieg | 07:12 Hauptstr. 41, 82284 Grafrath Gregori, Florian | 11195 Einstieg - 0 Minute(n) ",
"lat": 48.124141999999999,
"lon": 11.164550999999999
},
"arr_time": 3980,
"arr_date_time": null,
"end_time": 3980,
"end_date_time": null,
"waiting_time": 0,
"distance": 60715,
"driving_time": 3800,
"preparation_time": 0,
"load_before": [
4
],
"load_after": [
5
]
},
{
"type": "deliverShipment",
"id": "halt_186473",
"location_id": "end_halt_186473",
"address": {
"location_id": "end_halt_186473",
"name": " Ausstieg | 07:44 Magnusstraße 3, 86859 Igling Drifte, Till | 11150 Ausstieg - 1 Minute(n) Pittrich, Sophie | 11094 Ausstieg - 1 Minute(n) Lützenburger, Henri Felix | 11138 Ausstieg - 1 Minute(n) Weiskopf, Ludwig | 11129 Ausstieg - 1 Minute(n) Gregori, Florian | 11195 Ausstieg - 0 Minute(n) ",
"lat": 48.045651999999997,
"lon": 10.787269
},
"arr_time": 5685,
"arr_date_time": null,
"end_time": 5685,
"end_date_time": null,
"waiting_time": 0,
"distance": 96588,
"driving_time": 5505,
"preparation_time": 0,
"load_before": [
5
],
"load_after": [
4
]
},
{
"type": "deliverShipment",
"id": "halt_186471",
"location_id": "end_halt_186471",
"address": {
"location_id": "end_halt_186471",
"name": " Ausstieg | 07:44 Magnusstraße 3, 86859 Igling Drifte, Till | 11150 Ausstieg - 1 Minute(n) Pittrich, Sophie | 11094 Ausstieg - 1 Minute(n) Lützenburger, Henri Felix | 11138 Ausstieg - 1 Minute(n) Weiskopf, Ludwig | 11129 Ausstieg - 1 Minute(n) Gregori, Florian | 11195 Ausstieg - 0 Minute(n) ",
"lat": 48.045651999999997,
"lon": 10.787269
},
"arr_time": 5685,
"arr_date_time": null,
"end_time": 5745,
"end_date_time": null,
"waiting_time": 0,
"distance": 96588,
"driving_time": 5505,
"preparation_time": 0,
"load_before": [
4
],
"load_after": [
3
]
},
{
"type": "deliverShipment",
"id": "halt_186472",
"location_id": "end_halt_186472",
"address": {
"location_id": "end_halt_186472",
"name": " Ausstieg | 07:44 Magnusstraße 3, 86859 Igling Drifte, Till | 11150 Ausstieg - 1 Minute(n) Pittrich, Sophie | 11094 Ausstieg - 1 Minute(n) Lützenburger, Henri Felix | 11138 Ausstieg - 1 Minute(n) Weiskopf, Ludwig | 11129 Ausstieg - 1 Minute(n) Gregori, Florian | 11195 Ausstieg - 0 Minute(n) ",
"lat": 48.045651999999997,
"lon": 10.787269
},
"arr_time": 5745,
"arr_date_time": null,
"end_time": 5805,
"end_date_time": null,
"waiting_time": 0,
"distance": 96588,
"driving_time": 5505,
"preparation_time": 0,
"load_before": [
3
],
"load_after": [
2
]
},
{
"type": "deliverShipment",
"id": "halt_186470",
"location_id": "end_halt_186470",
"address": {
"location_id": "end_halt_186470",
"name": " Ausstieg | 07:44 Magnusstraße 3, 86859 Igling Drifte, Till | 11150 Ausstieg - 1 Minute(n) Pittrich, Sophie | 11094 Ausstieg - 1 Minute(n) Lützenburger, Henri Felix | 11138 Ausstieg - 1 Minute(n) Weiskopf, Ludwig | 11129 Ausstieg - 1 Minute(n) Gregori, Florian | 11195 Ausstieg - 0 Minute(n) ",
"lat": 48.045651999999997,
"lon": 10.787269
},
"arr_time": 5805,
"arr_date_time": null,
"end_time": 5865,
"end_date_time": null,
"waiting_time": 0,
"distance": 96588,
"driving_time": 5505,
"preparation_time": 0,
"load_before": [
2
],
"load_after": [
1
]
},
{
"type": "deliverShipment",
"id": "191594",
"location_id": "end_191594",
"address": {
"location_id": "end_191594",
"name": "bp_191594",
"lat": 48.035173,
"lon": 10.715085999999999
},
"arr_time": 6727,
"arr_date_time": null,
"end_time": 6727,
"end_date_time": null,
"waiting_time": 0,
"distance": 103285,
"driving_time": 6367,
"preparation_time": 0,
"load_before": [
1
],
"load_after": [
0
]
},
{
"type": "end",
"location_id": "location_end_Start_Endpunkt",
"address": {
"location_id": "location_end_Start_Endpunkt",
"name": "Endpunkt Schule RW Holzhausen",
"lat": 48.045651999999997,
"lon": 10.787269
},
"arr_time": 7586,
"arr_date_time": null,
"distance": 109961,
"driving_time": 7226,
"preparation_time": 0,
"waiting_time": 0,
"load_before": [
0
]
}
]
}
],
"unassigned": {
"services": [
],
"shipments": [
"halt_186469"
],
"breaks": [
],
"details": [
{
"id": "halt_186469",
"code": 21,
"reason": "could not be assigned due to relation constraint"
}
]
}
}
}
}