Update rota configuration for February 2026 and refine shift constraints handling
This commit is contained in:
+4
-2
@@ -482,7 +482,7 @@ def main(
|
|||||||
weeks_to_rota=weeks,
|
weeks_to_rota=weeks,
|
||||||
balance_offset_modifier=bom,
|
balance_offset_modifier=bom,
|
||||||
use_previous_shifts=True,
|
use_previous_shifts=True,
|
||||||
name="cons rota feb 2026 run 1",
|
name="cons rota feb 2026 run 2",
|
||||||
allow_force_assignment_with_leave_conflict=True,
|
allow_force_assignment_with_leave_conflict=True,
|
||||||
constraint_options=RotaConstraintOptions(
|
constraint_options=RotaConstraintOptions(
|
||||||
balance_weekends=True,
|
balance_weekends=True,
|
||||||
@@ -510,7 +510,8 @@ def main(
|
|||||||
assign_as_block=False,
|
assign_as_block=False,
|
||||||
constraints=[
|
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=2, start_date="2025-11-17", exclude_days=("Fri", "Sat", "Sun"), exclude_dates=["2026-04-06", "2026-05-04", "2026-05-25"]),
|
||||||
PostShiftConstraint(days=1, start_date="2025-11-17", exclude_days=("Fri", "Sat", "Sun"), allow_self=True),
|
PreShiftConstraint(days=1, start_date="2025-11-17", exclude_days=("Fri", "Sat", "Sun"), allow_self=False),
|
||||||
|
MaxShiftsPerWeekConstraint(max_shifts=1, days=days[:5]),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SingleShift(
|
SingleShift(
|
||||||
@@ -529,6 +530,7 @@ def main(
|
|||||||
SingleShift(
|
SingleShift(
|
||||||
sites=("rota b", "rota c"),
|
sites=("rota b", "rota c"),
|
||||||
name="weekend b",
|
name="weekend b",
|
||||||
|
end_date="2026-07-20",
|
||||||
workers_required=1,
|
workers_required=1,
|
||||||
length=12.5,
|
length=12.5,
|
||||||
days=days[5:],
|
days=days[5:],
|
||||||
|
|||||||
+10
-10
@@ -126,6 +126,7 @@ class RequireRemoteSitePresenceConstraint(BaseShiftConstraint):
|
|||||||
|
|
||||||
class MaxShiftsPerWeekConstraint(BaseShiftConstraint):
|
class MaxShiftsPerWeekConstraint(BaseShiftConstraint):
|
||||||
max_shifts: int | None = None
|
max_shifts: int | None = None
|
||||||
|
days: Optional[List[str]] = None
|
||||||
|
|
||||||
class MaxShiftsPerWeekBlockConstraint(BaseShiftConstraint):
|
class MaxShiftsPerWeekBlockConstraint(BaseShiftConstraint):
|
||||||
week_block : int
|
week_block : int
|
||||||
@@ -2788,20 +2789,19 @@ class RotaBuilder(object):
|
|||||||
shift_number = constraint.max_shifts
|
shift_number = constraint.max_shifts
|
||||||
else:
|
else:
|
||||||
shift_number = constraint_shift.get_shift_number()
|
shift_number = constraint_shift.get_shift_number()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# If the constraint specifies particular days, only count those days,
|
||||||
|
# otherwise count the shift's own days.
|
||||||
|
constraint_days = (
|
||||||
|
constraint.days if constraint.days is not None else self.days
|
||||||
|
)
|
||||||
|
|
||||||
self.model.constraints.add(
|
self.model.constraints.add(
|
||||||
shift_number
|
shift_number
|
||||||
>= sum(
|
>= sum(
|
||||||
self.model.works[
|
self.model.works[worker.id, w, day, constraint_shift.name]
|
||||||
worker.id, w, day, constraint_shift.name
|
for w, day in self.get_week_day_combinations_for_shift(constraint_shift)
|
||||||
]
|
if w == week and day in constraint_days
|
||||||
# for shiftname in self.get_shift_names_by_week_day(week, day)
|
|
||||||
# for day in self.days
|
|
||||||
for w, day in self.get_week_day_combinations_for_shift(
|
|
||||||
constraint_shift
|
|
||||||
)
|
|
||||||
if w == week
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
Reference in New Issue
Block a user