Overlap with services

Hi, I am using the route optimization API and facing an issue with existing appointments occasionally being overlapped with new ones.

Minimal example one appointment 10-11, another time window 9-5:

{ "vehicles": [ { "vehicle_id": "71", "start_address": { "location_id": "vehicle_location-71", "lat": 45.5345814, "lon": -73.5434827 }, "type_id": "vehicle_type_1", "earliest_start": 1548666000, "latest_end": 1548694800, "return_to_depot": false } ], "vehicle_types": [ { "type_id": "vehicle_type_1", "profile": "car" } ], "services": [ { "id": "appointment-209", "name": null, "address": { "location_id": "appointment_location-209", "lat": 45.4877, "lon": -73.59721 }, "duration": 3600, "time_windows": [ { "earliest": 1548669600, "latest": 1548673200 } ], "allowed_vehicles": [ 71 ], "priority": 1 }, { "id": "appointment-190", "name": null, "address": { "location_id": "appointment_location-190", "lat": 45.4959, "lon": -73.59541 }, "duration": 3600, "time_windows": [ { "earliest": 1548666000, "latest": 1548676800 } ] } ] }

Returns arr_time of the new appointment before the end of the first (10am) sometimes.

I’d like to restrict the 9-10 interval completely, so it is not really a time window but a blocked off portion of time.

How to do this? Is there a way to specify instead of a time window that the time is inaccessible? Do I need to subtract from subsequent appointment windows instead? ie) 9-10, 11-5
"time_windows": [ { "earliest": 1548666000, "latest": 1548669600 }, { "earliest": 1548673200, "latest": 1548694800 } ]
And similar time window changes as appointments are blocked off? That too does not seem like it would work - as if I have three vehicles [A,B,C], then Vehicle A might be blocked off already from 10-11, but B and C would not be.

I also tried using relations of "type":"in_same_route" but received the error "code":21,"reason":"could not be assigned due to relation constraint"

Thank-you

Thanks. I think the root of the problem is a small misunderstanding: the time window specifies the time where a service can start, so if you want the service (with a duration of 1h) happening between 10-12 you specify the (start) time window from 10-11.

Does this clarify the “overlap”?

I’d like to restrict the 9-10 interval completely, so it is not really a time window but a blocked off portion of time.

You specify two time windows 0-9 and 10-24

Returns arr_time of the new appointment before the end of the first (10am) sometimes.

You should always get the same results (except maybe when we update the road network but those events are probably 2-3 times per week).

Thanks for the reply.

So if I want a service to start exactly at 10 and block off 1 hour, I specify a time window with earliest and latest both equal to the start time (10)?

"duration": 3600, "time_windows": [ { "earliest": 1548669600, "latest": 1548669600 } ]

1 Like

As a followup, everything is working good with this approach, just need to make sure to allow adequate driving time between appointments or they will be unassigned.

"cannot be visited within time window"

Same with first appointment of the day - driver needs to start before the appointment or that appointment needs an increased time window for driving time

1 Like