feat: add condition to check for week-day combinations before adding constraints in RotaBuilder
This commit is contained in:
+12
-11
@@ -2788,18 +2788,19 @@ class RotaBuilder(object):
|
|||||||
"target_shifts": target_shifts,
|
"target_shifts": target_shifts,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.model.constraints.add(
|
if self.get_week_day_combinations_for_shift(shift):
|
||||||
inequality(
|
self.model.constraints.add(
|
||||||
min_shifts,
|
inequality(
|
||||||
sum(
|
min_shifts,
|
||||||
self.model.works[worker.id, week, day, shift.name]
|
sum(
|
||||||
for week, day in self.get_week_day_combinations_for_shift(
|
self.model.works[worker.id, week, day, shift.name]
|
||||||
shift
|
for week, day in self.get_week_day_combinations_for_shift(
|
||||||
)
|
shift
|
||||||
),
|
)
|
||||||
max_shifts,
|
),
|
||||||
|
max_shifts,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
# Make sure shifts aren't assigned to those from other sites
|
# Make sure shifts aren't assigned to those from other sites
|
||||||
# Not needed if there are no shifts
|
# Not needed if there are no shifts
|
||||||
|
|||||||
Reference in New Issue
Block a user