From d741d7e23c80797c20fdafd1f79b73c19adeb227 Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 7 Jan 2026 22:28:58 +0000 Subject: [PATCH] Update shift configurations and parameters in RotaBuilder for enhanced scheduling --- gen_proc.py | 296 ++++++++++++++++++++++++++-------------------------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/gen_proc.py b/gen_proc.py index 514f845..81d6b58 100644 --- a/gen_proc.py +++ b/gen_proc.py @@ -46,8 +46,8 @@ from rota_generator.workers import ( def main( suspend: bool = False, solve: bool = True, - time_to_run: int = 60 * 60 * 8, - ratio: float = 0.001, + time_to_run: int = 60 * 60 * 10, + ratio: float = 0.0001, start_date: datetime.datetime = "2026-03-02", weeks: int = 27, bom: float = 1, @@ -59,7 +59,7 @@ def main( rota_start_date, weeks_to_rota=weeks, balance_offset_modifier=bom, - name="proc_rota2", + name="proc_rota3", ) # Rota = RotaBuilder(start_date, weeks_to_rota=20, balance_offset_modifier=1) Rota.constraint_options["balance_shifts"] = False @@ -84,149 +84,149 @@ def main( #] Rota.add_shifts( - #SingleShift( - # sites=( - # "exeter", - # "exeter twilights and weekends", - # "exeter no nights", - # "exeter twilights", - # ), - # name="exeter_twilight", - # length=12.5, - # days=days[:5], - # balance_offset=2, - # constraints=[MaxShiftsPerWeekConstraint(max_shifts=1)], - #), - #SingleShift( - # sites=( - # "truro", - # "truro no nights", - # "truro twilights", - # "truro twilights and weekends", - # "truro twilights and weekend nights", - # "truro twilights, weekends and weekend nights", - # ), - # name="truro_twilight", - # length=12.5, - # days=days[:4], - # balance_offset=4, - # constraints=[MaxShiftsPerWeekConstraint(max_shifts=1)], - #), - #SingleShift( - # sites=("torbay", "torbay twilights", "torbay twilights and weekends"), - # name="torbay_twilight", - # length=12.5, - # days=days[:4], - # balance_offset=2, - # assign_as_block=True, - #), - #SingleShift( - # sites=( - # "plymouth", - # "plymouth twilights", - # "plymouth twilights and weekends", - # "plymouth twilights, weekends and weekend nights", - # ), - # name="plymouth_twilight", - # length=12.5, - # days=days[:5], - # balance_offset=2, - # workers_required=1, - # constraints=[MaxShiftsPerWeekConstraint(max_shifts=2)], - #), - #SingleShift( - # sites=( - # "exeter", - # "exeter twilights and weekends", - # "exeter no nights", - # "exeter weekends", - # #"exeter twilights", - # ), - # name="weekend_exeter", - # length=12.5, - # days=days[5:], - # #balance_offset=2, - # rota_on_nwds=True, - # force_as_block=True, - # constraints=[PostShiftConstraint(days=2), PreShiftConstraint(days=2)], - # # constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2},], - #), - #SingleShift( - # sites=( - # "truro", - # "truro no nights", - # "truro twilights and weekends", - # "truro weekends", - # "truro twilights, weekends and weekend nights", - # ), - # name="weekend_truro", - # length=12.5, - # days=days[4:], - # #balance_offset=3, - # rota_on_nwds=True, - # force_as_block=True, - # #assign_as_block=True, - # constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], - # # force_as_block_unless_nwd=True - #), - #SingleShift( - # sites=("torbay", "torbay twilights and weekends"), - # name="weekend_torbay", - # length=12.5, - # days=days[4:], - # #balance_offset=2, - # rota_on_nwds=True, - # force_as_block=True, - # constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], - # # force_as_block_unless_nwd=True - #), - #SingleShift( - # sites=( - # "plymouth", - # "plymouth twilights and weekends", - # "plymouth first on weekends only", - # "plymouth twilights, weekends and weekend nights", - # ), - # name="weekend_plymouth1", - # length=8, - # days=days[5:], - # #balance_offset=2.9, - # workers_required=1, - # rota_on_nwds=True, - # force_as_block=True, - # constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], - #), - #SingleShift( - # sites=( - # "plymouth", - # "plymouth twilights and weekends", - # "plymouth twilights, weekends and weekend nights", - # ), - # name="weekend_plymouth2", - # length=8, - # days=days[5:], - # #balance_offset=2.9, - # workers_required=1, - # rota_on_nwds=True, - # force_as_block=True, - # constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], - #), - #SingleShift( - # sites=( - # "plymouth", - # "plymouth twilights", - # "plymouth twilights and weekends", - # "plymouth twilights, weekends and weekend nights", - # ), - # name="plymouth_bank_holidays", - # length=8, - # days=days[5:], - # balance_offset=1, - # workers_required=1, - # rota_on_nwds=True, - # force_as_block=False, - # bank_holidays_only=True, - #), + SingleShift( + sites=( + "exeter", + "exeter twilights and weekends", + "exeter no nights", + "exeter twilights", + ), + name="exeter_twilight", + length=12.5, + days=days[:5], + balance_offset=2, + constraints=[MaxShiftsPerWeekConstraint(max_shifts=1)], + ), + SingleShift( + sites=( + "truro", + "truro no nights", + "truro twilights", + "truro twilights and weekends", + "truro twilights and weekend nights", + "truro twilights, weekends and weekend nights", + ), + name="truro_twilight", + length=12.5, + days=days[:4], + balance_offset=4, + constraints=[MaxShiftsPerWeekConstraint(max_shifts=1)], + ), + SingleShift( + sites=("torbay", "torbay twilights", "torbay twilights and weekends"), + name="torbay_twilight", + length=12.5, + days=days[:4], + balance_offset=2, + assign_as_block=True, + ), + SingleShift( + sites=( + "plymouth", + "plymouth twilights", + "plymouth twilights and weekends", + "plymouth twilights, weekends and weekend nights", + ), + name="plymouth_twilight", + length=12.5, + days=days[:5], + balance_offset=2, + workers_required=1, + constraints=[MaxShiftsPerWeekConstraint(max_shifts=2)], + ), + SingleShift( + sites=( + "exeter", + "exeter twilights and weekends", + "exeter no nights", + "exeter weekends", + #"exeter twilights", + ), + name="weekend_exeter", + length=12.5, + days=days[5:], + #balance_offset=2, + rota_on_nwds=True, + force_as_block=True, + constraints=[PostShiftConstraint(days=2), PreShiftConstraint(days=2)], + # constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2},], + ), + SingleShift( + sites=( + "truro", + "truro no nights", + "truro twilights and weekends", + "truro weekends", + "truro twilights, weekends and weekend nights", + ), + name="weekend_truro", + length=12.5, + days=days[4:], + #balance_offset=3, + rota_on_nwds=True, + force_as_block=True, + #assign_as_block=True, + constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], + # force_as_block_unless_nwd=True + ), + SingleShift( + sites=("torbay", "torbay twilights and weekends"), + name="weekend_torbay", + length=12.5, + days=days[4:], + #balance_offset=2, + rota_on_nwds=True, + force_as_block=True, + constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], + # force_as_block_unless_nwd=True + ), + SingleShift( + sites=( + "plymouth", + "plymouth twilights and weekends", + "plymouth first on weekends only", + "plymouth twilights, weekends and weekend nights", + ), + name="weekend_plymouth1", + length=8, + days=days[5:], + #balance_offset=2.9, + workers_required=1, + rota_on_nwds=True, + force_as_block=True, + constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], + ), + SingleShift( + sites=( + "plymouth", + "plymouth twilights and weekends", + "plymouth twilights, weekends and weekend nights", + ), + name="weekend_plymouth2", + length=8, + days=days[5:], + #balance_offset=2.9, + workers_required=1, + rota_on_nwds=True, + force_as_block=True, + constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], + ), + SingleShift( + sites=( + "plymouth", + "plymouth twilights", + "plymouth twilights and weekends", + "plymouth twilights, weekends and weekend nights", + ), + name="plymouth_bank_holidays", + length=8, + days=days[5:], + balance_offset=1, + workers_required=1, + rota_on_nwds=True, + force_as_block=False, + bank_holidays_only=True, + ), SingleShift( sites=sites, name="night_weekday", @@ -280,8 +280,8 @@ def main( # Prevent shifts for ST2s for 2 weeks #Rota.add_grade_constraint_by_week([2], [1, 2], [shift.name for shift in Rota.shifts]) - #Rota.add_min_summed_grade_by_shifts_per_day_constraint(["weekend_plymouth1", "weekend_plymouth2"], 6) - #Rota.add_min_summed_grade_by_shifts_per_day_constraint(["plymouth_twilight", "plymouth_bank_holidays"], 6) + Rota.add_min_summed_grade_by_shifts_per_day_constraint(["weekend_plymouth1", "weekend_plymouth2"], 6) + Rota.add_min_summed_grade_by_shifts_per_day_constraint(["plymouth_twilight", "plymouth_bank_holidays"], 6) Rota.add_min_summed_grade_by_shifts_per_day_constraint(["night_weekday"], 12) Rota.add_min_summed_grade_by_shifts_per_day_constraint(["night_weekend"], 12)