Refactor worker scheduling constraints in load_workers and main functions for improved clarity and functionality

This commit is contained in:
Ross
2026-05-19 20:45:23 +01:00
parent 68b80ace23
commit ee263aade1
+11 -11
View File
@@ -458,11 +458,11 @@ def load_workers():
#w.add_force_assign_with("twilight", "oncall")
w.add_force_assign_with("weekend", "oncall")
#if w.name in ("DS",):
# w.add_hard_day_dependency({"Fri", "Sat", "Sun"}, ignore_dates=[datetime.date(2026, 5, 2)])
#else:
# w.add_hard_day_dependency({"Fri", "Sun"})
# w.add_hard_day_exclusion({"Sat", "Sun"})
if w.name in ("DS",):
w.add_hard_day_dependency({"Fri", "Sat", "Sun"}, ignore_dates=[datetime.date(2026, 5, 2)])
else:
w.add_hard_day_dependency({"Fri", "Sun"})
w.add_hard_day_exclusion({"Sat", "Sun"})
@@ -496,7 +496,7 @@ def main(
balance_weekends=True,
max_shifts_per_week=6,
max_weekend_frequency=3,
max_days_per_week_block=[(4, 2), (4, 4)],
max_days_per_week_block=[(3, 2), (4, 4)],
#balance_weekend_days=True,
balance_weekend_days_quadratic=True,
weekend_day_hard_max_deviation=2,
@@ -519,7 +519,7 @@ def main(
constraints=[
#PreShiftConstraint(days=2, start_date="2025-11-17", exclude_days=("Fri", "Sat", "Sun"), exclude_dates=["2026-04-06", "2026-05-04", "2026-05-25"]),
#PreShiftConstraint(days=1, start_date="2025-11-17", exclude_days=("Fri", "Sat", "Sun"), allow_self=False),
#MaxShiftsPerWeekConstraint(max_shifts=1, days=days[:5]),
MaxShiftsPerWeekConstraint(max_shifts=1, days=days[:5]),
],
),
SingleShift(
@@ -530,7 +530,7 @@ def main(
days=days[5:],
balance_offset=1,
constraints=[
#PostShiftConstraint(days=1, start_date="2025-11-17", ignore_shifts=["oncall"]),
PostShiftConstraint(days=1, start_date="2025-11-17", ignore_shifts=["oncall"]),
],
display_char="a",
#force_assign_with=["oncall"]
@@ -557,9 +557,9 @@ def main(
days=days[:5],
balance_offset=1,
constraints=[
#PreShiftConstraint(days=1, start_date="2025-11-17", ignore_shifts=["oncall"], exclude_days=("Sat", "Sun")),
#MaxShiftsPerWeekConstraint(max_shifts=1),
#MaxShiftsPerWeekBlockConstraint(week_block=3,max_shifts=1)
PreShiftConstraint(days=1, start_date="2025-11-17", ignore_shifts=["oncall"], exclude_days=("Sat", "Sun")),
MaxShiftsPerWeekConstraint(max_shifts=1),
MaxShiftsPerWeekBlockConstraint(week_block=3,max_shifts=1)
],
),
)