Existing visits on route, time windows, duration

I have the following problem, we have to plan multiple visits on a weekly day. Each visit has his own duration, but the week day (like monday) already has existing visits which we have te plan around.

So if we wan’t to solve this problem with time windows, we give each visit the available gaps between the existing visits. But the problem is that you don’t have to be between the time window to solve. If we specify the latest time window object this is what it does:

Specifies the closing time of the time window in seconds, i.e. the latest time the service can start.

So if we have an time window from 12:00 to 12:30 and our visit has an duration of 40 minutes it shouldn’t solve but it does because according to graphopper it can start from 12:00 till 12:30. I wan’t it only to solve if the gap is longer then the duration so the gap has to be from 12:00 till 12:40 or longer.

What is the correct way to solve this problem?

Thanks.

but it does because according to graphopper it can start from 12:00 till 12:30

See the documentation, where it is stated that you specify in both cases the start values:

earliest long - 0 Specifies the opening time of the time window in seconds, i.e. the earliest time the service can start.
latest long - Long.MAX_VALUE Specifies the closing time of the time window in seconds, i.e. the latest time the service can start.

Quote:

I wan’t it only to solve if the gap is longer then the duration so the gap has to be from 12:00 till 12:40 or longer.

Why don’t you remove the time window on the client side if the duration does not fit or do you mean the time window of the vehicle?

The only way I see is to redefine your time window as follows time_window.latest - activity.duration. If it results in time_window.latest < time_window.earliest the job cannot be scheduled.