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,
|
||||
}
|
||||
|
||||
self.model.constraints.add(
|
||||
inequality(
|
||||
min_shifts,
|
||||
sum(
|
||||
self.model.works[worker.id, week, day, shift.name]
|
||||
for week, day in self.get_week_day_combinations_for_shift(
|
||||
shift
|
||||
)
|
||||
),
|
||||
max_shifts,
|
||||
if self.get_week_day_combinations_for_shift(shift):
|
||||
self.model.constraints.add(
|
||||
inequality(
|
||||
min_shifts,
|
||||
sum(
|
||||
self.model.works[worker.id, week, day, shift.name]
|
||||
for week, day in self.get_week_day_combinations_for_shift(
|
||||
shift
|
||||
)
|
||||
),
|
||||
max_shifts,
|
||||
)
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Make sure shifts aren't assigned to those from other sites
|
||||
# Not needed if there are no shifts
|
||||
|
||||
Reference in New Issue
Block a user