Update shift configurations and parameters in RotaBuilder for enhanced scheduling

This commit is contained in:
Ross
2026-01-07 22:28:58 +00:00
parent 64c4189d5f
commit d741d7e23c
+144 -144
View File
@@ -46,8 +46,8 @@ from rota_generator.workers import (
def main( def main(
suspend: bool = False, suspend: bool = False,
solve: bool = True, solve: bool = True,
time_to_run: int = 60 * 60 * 8, time_to_run: int = 60 * 60 * 10,
ratio: float = 0.001, ratio: float = 0.0001,
start_date: datetime.datetime = "2026-03-02", start_date: datetime.datetime = "2026-03-02",
weeks: int = 27, weeks: int = 27,
bom: float = 1, bom: float = 1,
@@ -59,7 +59,7 @@ def main(
rota_start_date, rota_start_date,
weeks_to_rota=weeks, weeks_to_rota=weeks,
balance_offset_modifier=bom, balance_offset_modifier=bom,
name="proc_rota2", name="proc_rota3",
) )
# Rota = RotaBuilder(start_date, weeks_to_rota=20, balance_offset_modifier=1) # Rota = RotaBuilder(start_date, weeks_to_rota=20, balance_offset_modifier=1)
Rota.constraint_options["balance_shifts"] = False Rota.constraint_options["balance_shifts"] = False
@@ -84,149 +84,149 @@ def main(
#] #]
Rota.add_shifts( Rota.add_shifts(
#SingleShift( SingleShift(
# sites=( sites=(
# "exeter", "exeter",
# "exeter twilights and weekends", "exeter twilights and weekends",
# "exeter no nights", "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", #"exeter twilights",
# ), ),
# name="exeter_twilight", name="weekend_exeter",
# length=12.5, length=12.5,
# days=days[: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, #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, #assign_as_block=True,
#), constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)],
#SingleShift( # force_as_block_unless_nwd=True
# sites=( ),
# "plymouth", SingleShift(
# "plymouth twilights", sites=("torbay", "torbay twilights and weekends"),
# "plymouth twilights and weekends", name="weekend_torbay",
# "plymouth twilights, weekends and weekend nights", length=12.5,
# ), days=days[4:],
# name="plymouth_twilight",
# length=12.5,
# days=days[:5],
#balance_offset=2, #balance_offset=2,
# workers_required=1, rota_on_nwds=True,
# constraints=[MaxShiftsPerWeekConstraint(max_shifts=2)], force_as_block=True,
#), constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)],
#SingleShift( # force_as_block_unless_nwd=True
# sites=( ),
# "exeter", SingleShift(
# "exeter twilights and weekends", sites=(
# "exeter no nights", "plymouth",
# "exeter weekends", "plymouth twilights and weekends",
# #"exeter twilights", "plymouth first on weekends only",
# ), "plymouth twilights, weekends and weekend nights",
# name="weekend_exeter", ),
# length=12.5, name="weekend_plymouth1",
# days=days[5:], length=8,
# #balance_offset=2, days=days[5:],
# rota_on_nwds=True, #balance_offset=2.9,
# force_as_block=True, workers_required=1,
# constraints=[PostShiftConstraint(days=2), PreShiftConstraint(days=2)], rota_on_nwds=True,
# # constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2},], force_as_block=True,
#), constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)],
#SingleShift( ),
# sites=( SingleShift(
# "truro", sites=(
# "truro no nights", "plymouth",
# "truro twilights and weekends", "plymouth twilights and weekends",
# "truro weekends", "plymouth twilights, weekends and weekend nights",
# "truro twilights, weekends and weekend nights", ),
# ), name="weekend_plymouth2",
# name="weekend_truro", length=8,
# length=12.5, days=days[5:],
# days=days[4:], #balance_offset=2.9,
# #balance_offset=3, workers_required=1,
# rota_on_nwds=True, rota_on_nwds=True,
# force_as_block=True, force_as_block=True,
# #assign_as_block=True, constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)],
# constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], ),
# # force_as_block_unless_nwd=True SingleShift(
#), sites=(
#SingleShift( "plymouth",
# sites=("torbay", "torbay twilights and weekends"), "plymouth twilights",
# name="weekend_torbay", "plymouth twilights and weekends",
# length=12.5, "plymouth twilights, weekends and weekend nights",
# days=days[4:], ),
# #balance_offset=2, name="plymouth_bank_holidays",
# rota_on_nwds=True, length=8,
# force_as_block=True, days=days[5:],
# constraints=[PreShiftConstraint(days=2), PostShiftConstraint(days=2)], balance_offset=1,
# # force_as_block_unless_nwd=True workers_required=1,
#), rota_on_nwds=True,
#SingleShift( force_as_block=False,
# sites=( bank_holidays_only=True,
# "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( SingleShift(
sites=sites, sites=sites,
name="night_weekday", name="night_weekday",
@@ -280,8 +280,8 @@ def main(
# Prevent shifts for ST2s for 2 weeks # 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_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(["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(["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_weekday"], 12)
Rota.add_min_summed_grade_by_shifts_per_day_constraint(["night_weekend"], 12) Rota.add_min_summed_grade_by_shifts_per_day_constraint(["night_weekend"], 12)