Each driver (vehicle) needs a 30 min break after 8 hours on-duty. Referencing a previous issue, here is my code:
# Add breaks
node_visit_transit = {}
for n in range(routing.Size()):
if n >= len(data['node_name']):
node_visit_transit[n] = 0
else:
if n in data['pickups']:
node_visit_transit[n] = int(data['load_time'][n])
else:
node_visit_transit[n] = int(data['unload_time'][n])
break_intervals = {}
for v in range(data['num_vehicles']):
break_intervals[v] = [
routing.solver().FixedDurationIntervalVar(
MAX_TIME_BETWEEN_BREAKS, MAX_TIME_BETWEEN_BREAKS, BREAK_DURATION, False, 'Break for vehicle {}'.format(v))
]
time_dimension.SetBreakIntervalsOfVehicle(
break_intervals[v], v, node_visit_transit)
However, no solution is found when this snippet is added, whereas a solution existed previously. A few questions:
- What is
node_visit_transitused for? From the Github code it seems to account for some form of loading time (based on load demand), so I adapted it for load/unload time here. - Am I using
FixedDurationIntervalVarcorrectly? I would like drivers to have aBREAK_DURATIONbreak after they've been on duty forMAX_TIME_BETWEEN_BREAKShours, regardless of start time. I'm concerned this is forcing them to take a break at the absolute timeMAX_TIME_BETWEEN_BREAKS, i.e. ifMAX_TIME_BETWEEN_BREAKS = 8then they all take a break at 08:00.
It seems like someone has figured this out here, but there is no solution example.