reinterpretcat / vrp

A Vehicle Routing Problem solver
https://reinterpretcat.github.io/vrp/
Apache License 2.0
331 stars 68 forks source link

Index out of Bounds in Fast Service Objective #144

Closed tklie closed 5 months ago

tklie commented 5 months ago

Hi, I'm trying to solve the below problem and matrix using the fast_service objective but am running into the following exception (v1.23.0):

thread '<unnamed>' panicked at /var/vrp/vrp-core/src/construction/features/fast_service.rs:174:39:
index out of bounds: the len is 7 but the index is 8
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at /var/vrp/vrp-core/src/construction/features/fast_service.rs:174:39:
index out of bounds: the len is 4 but the index is 8
thread '<unnamed>' panicked at /var/vrp/vrp-core/src/construction/features/fast_service.rs:174:39:
index out of bounds: the len is 6 but the index is 8

To me this seems to be a bug in the objective itself, but feel free to point out any misconfiguration in my input.

Problem ``` { "fleet": { "vehicles": [ { "typeId": "vehicle", "vehicleIds": [ "0" ], "profile": { "matrix": "normal_car" }, "capacity": [ 10000 ], "costs": { "fixed": 20, "distance": 0.0002, "time": 0.01 }, "shifts": [ { "start": { "earliest": "2024-01-29T11:00:00Z", "latest": "2024-01-29T11:00:00Z", "location": { "index": 0 } }, "end": { "latest": "2024-02-28T19:00:00Z", "location": { "index": 0 } } } ], "skills": [ "123274963+16803" ] } ], "profiles": [ { "name": "normal_car" } ] }, "plan": { "jobs": [ { "id": "123274963::0::120329018d-123274963::0::120329018p", "skills": { "allOf": [ "123274963+16803" ], "oneOf": [], "noneOf": [] }, "pickups": [ { "demand": [ 1 ], "places": [ { "tag": "123274963::0::120329018p", "location": { "index": 8 }, "duration": 180, "times": [ [ "2024-01-29T06:00:00Z", "2024-02-28T17:00:00Z" ] ] } ] } ], "deliveries": [ { "demand": [ 1 ], "places": [ { "tag": "123274963::0::120329018d", "location": { "index": 2 }, "duration": 180, "times": [ [ "2024-01-29T06:00:00Z", "2024-02-28T19:00:00Z" ] ] } ] } ] }, { "id": "123274963::0::120580518d", "skills": { "allOf": [ "123274963+16803" ], "oneOf": [], "noneOf": [] }, "deliveries": [ { "demand": [ 1 ], "places": [ { "tag": "123274963::0::120580518d", "location": { "index": 1 }, "duration": 180, "times": [ [ "2024-01-29T11:00:00Z", "2024-02-28T23:00:00Z" ] ] } ] } ] }, { "id": "123274963::0::120601713p", "skills": { "allOf": [ "123274963+16803" ], "oneOf": [], "noneOf": [] }, "deliveries": [ { "demand": [ 1 ], "places": [ { "tag": "123274963::0::120601713p", "location": { "index": 3 }, "duration": 180, "times": [ [ "2024-01-29T14:00:00Z", "2024-02-28T15:00:00Z" ] ] } ] } ] }, { "id": "123274963::0::120696166p", "skills": { "allOf": [ "123274963+16803" ], "oneOf": [], "noneOf": [] }, "deliveries": [ { "demand": [ 1 ], "places": [ { "tag": "123274963::0::120696166p", "location": { "index": 4 }, "duration": 180, "times": [ [ "2024-01-29T15:45:00Z", "2024-02-28T16:45:00Z" ] ] } ] } ] }, { "id": "123274963::0::120701065p", "skills": { "allOf": [ "123274963+16803" ], "oneOf": [], "noneOf": [] }, "deliveries": [ { "demand": [ 1 ], "places": [ { "tag": "123274963::0::120701065p", "location": { "index": 5 }, "duration": 180, "times": [ [ "2024-01-29T15:00:00Z", "2024-02-28T17:00:00Z" ] ] } ] } ] }, { "id": "123274963::0::120702970p", "skills": { "allOf": [ "123274963+16803" ], "oneOf": [], "noneOf": [] }, "deliveries": [ { "demand": [ 1 ], "places": [ { "tag": "123274963::0::120702970p", "location": { "index": 6 }, "duration": 180, "times": [ [ "2024-01-29T11:30:00Z", "2024-02-28T14:30:00Z" ] ] } ] } ] }, { "id": "123274963::0::120706485p", "skills": { "allOf": [ "123274963+16803" ], "oneOf": [], "noneOf": [] }, "deliveries": [ { "demand": [ 1 ], "places": [ { "tag": "123274963::0::120706485p", "location": { "index": 7 }, "duration": 180, "times": [ [ "2024-01-29T11:36:00Z", "2024-02-28T14:30:00Z" ] ] } ] } ] } ] }, "objectives": [ [ { "type": "minimize-unassigned" } ], [ { "type": "fast-service" } ], [ { "type": "minimize-cost" } ] ] } ```
Matrix ``` [ { "matrix": "normal_car", "distances": [ 0, 17253, 753556, 28454, 16292, 25551, 42538, 69240, 15997, 17212, 0, 767568, 12204, 282, 9188, 26175, 35714, 561, 749630, 764307, 0, 775507, 763346, 772605, 789592, 816146, 763746, 28443, 12212, 781331, 0, 12044, 8589, 24478, 29286, 12545, 16274, 276, 766630, 12019, 0, 9235, 26222, 35761, 608, 25568, 9199, 775924, 8446, 9532, 0, 14591, 30155, 9286, 38847, 22477, 789203, 24536, 22811, 15448, 0, 9598, 22565, 68299, 32016, 815343, 29430, 32350, 30366, 9612, 0, 32104, 16651, 561, 767007, 12536, 608, 9275, 26262, 35801, 0 ], "travelTimes": [ 0, 1107, 26381, 1734, 1099, 1559, 2477, 3123, 1134, 1096, 0, 27253, 793, 60, 630, 1549, 2249, 74, 26348, 27265, 0, 27892, 27256, 27716, 28635, 28758, 27194, 1731, 798, 27873, 0, 782, 572, 1505, 1743, 826, 1081, 40, 27238, 714, 0, 624, 1543, 2243, 68, 1547, 639, 27704, 669, 624, 0, 1004, 1714, 632, 2463, 1555, 28620, 1475, 1540, 1220, 0, 608, 1548, 3029, 2260, 28180, 1712, 2245, 1691, 717, 0, 2253, 1023, 88, 27180, 818, 64, 627, 1545, 2246, 0 ] } ] ```

Kind regards

reinterpretcat commented 5 months ago

Hi, thanks for reporting!

Fast Service objective is a bit experimental, added recently, so, most likely this is a bug (the code shouldn't panic here). Currently, I'm not working actively on bug fixing, maybe will find some time later. Feel free to investigate.

reinterpretcat commented 5 months ago

Actually, I've just pushed a fix (was a bit curios about the reason). Btw, how this objective works?

tklie commented 5 months ago

Thank you for the quick fix.

I haven't yet tested it enough or compared it to solutions without the objective to make an educated statement about the improvements. But at a first glance, it looks fine. I will report back though if I run into any issues or notice it not working as expected.