Hi James,
Thanks for the reply and sorry for not answering sooner. The project got slightly postponed until now.
Yes, it is a combination of scheduling and VRPTW, where there are scheduling constraints in some locations.
A location can have the following constraints:
Constraint 1: Minimum service days per week.
Constraint 2: Possible service days a week, for example, "any day of the week", or "any weekday". But 95% have "any weekday".
Constraint 3: Biweekly or weekly, but all biweeklies are 1-day "any weekday" visits. So it results in one location with a big-time window for all weekdays over 2 weeks where I have removed the intervals between which is working fine.
Constraint 4: Minimum time interval between visits. Ideally, I want to use it to set daily visits to be between the 23-25 hour range after the first is chosen. And then use the same for 2 day intervals where I just increase that time interval.
Constraint 6: Some locations also have
multiple service times a week. So it can become a constraint of "Come 30 minutes one day, come 90 minutes the second day, come 2 times a week 2 days minimum between". But this one is not that important and I will hardcode this if needed.
For most of these constraints, I do agree that it looks like a scheduling problem, but the scheduling day is dependent on the time between locations and the time windows of other locations.
Thus, for locations with
minimum service days per week above 1, I am trying for every
Possible service day a week, to create duplicates, with a time-window for that day.
Then using
Constraint 4, combined with service times at location,
the time matrix and time windows steer how the route is scheduled, if that is possible. I have been looking into some solutions but could not find a real good solution to
Constraint 4. There was something similar in
this discussion where you also commented, I am unsure if I understood him though. He did something like this:
for j in range((i+1), len(set)):
# A comes before B by at least N
A_then_B_constraint = time_dimension.CumulVar(set[i]) <= time_dimension.CumulVar(set[j]) - constants['MIN_BETWEEN_ORDERS']
# or B comes before A by at least N
B_then_A_constraint = time_dimension.CumulVar(set[j]) <= time_dimension.CumulVar(set[i]) - constants['MIN_BETWEEN_ORDERS']
gap_constraint = A_then_B_constraint + B_then_A_constraint == 1
routing.solver().Add(gap_constraint)
I also have time constraints on the vehicles that will affect scheduling and routing, but that I don't need guidance on.
Once again, sorry for the late reply. Thanks in advance!
Best regards,
Alexander