a few more fixes and improvements
This commit is contained in:
+50
-47
@@ -29,7 +29,7 @@ def main(
|
||||
time_to_run: int = 60 * 60,
|
||||
ratio: float = 0.001,
|
||||
start_date: datetime.datetime = "2025-09-01",
|
||||
weeks: int = 16,
|
||||
weeks: int = 12,
|
||||
bom: int = 1,
|
||||
):
|
||||
rota_start_date = start_date.date()
|
||||
@@ -42,61 +42,42 @@ def main(
|
||||
name="cons rota",
|
||||
)
|
||||
# Rota = RotaBuilder(start_date, weeks_to_rota=20, balance_offset_modifier=1)
|
||||
Rota.constraint_options["balance_shifts"] = False
|
||||
Rota.constraint_options["balance_shifts_quadratic"] = True
|
||||
Rota.constraint_options["balance_weekends"] = True
|
||||
Rota.constraint_options["max_night_frequency"] = 3 # 3
|
||||
Rota.constraint_options["max_night_frequency_week_exclusions"] = []
|
||||
Rota.constraint_options["max_weekend_frequency"] = 4
|
||||
Rota.constraint_options["hard_constrain_pair_separation"] = True
|
||||
Rota.constraint_options["max_shifts_per_week"] = 3
|
||||
Rota.constraint_options["max_shifts_per_week"] = 20
|
||||
# Rota.constraint_options["avoid_st2_first_month"] = True
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("rota a",),
|
||||
name="oncall weekday",
|
||||
name="oncall",
|
||||
length=12.5,
|
||||
days=days[:4],
|
||||
balance_offset=2,
|
||||
days=days,
|
||||
balance_offset=5,
|
||||
assign_as_block=False,
|
||||
constraint=[
|
||||
{
|
||||
"name": "max_shifts_per_week",
|
||||
"options": 3,
|
||||
}
|
||||
#{
|
||||
# "name": "max_shifts_per_week",
|
||||
# "options": 3,
|
||||
#}
|
||||
],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("rota a",),
|
||||
name="Oncall weekend",
|
||||
length=12.5,
|
||||
days=days[4:],
|
||||
balance_offset=2,
|
||||
assign_as_block=True,
|
||||
constraint=[
|
||||
{
|
||||
"name": "max_shifts_per_week",
|
||||
"options": 3,
|
||||
},
|
||||
{"name": "pre", "options": 2},
|
||||
{"name": "post", "options": 2},
|
||||
],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("rota a",),
|
||||
name="weekend a",
|
||||
name="weekend",
|
||||
workers_required=1,
|
||||
length=12.5,
|
||||
days=days[5:],
|
||||
balance_offset=2,
|
||||
constraint=[
|
||||
{"name": "pre", "options": 2},
|
||||
{"name": "post", "options": 2},
|
||||
#{"name": "pre", "options": 2},
|
||||
#{"name": "post", "options": 1},
|
||||
],
|
||||
display_char="a",
|
||||
#force_assign_with=["oncall"]
|
||||
),
|
||||
SingleShift(
|
||||
sites=("rota b", "rota c"),
|
||||
sites=("rota b",),
|
||||
name="weekend b",
|
||||
workers_required=1,
|
||||
length=12.5,
|
||||
@@ -113,22 +94,25 @@ def main(
|
||||
"rota a",
|
||||
"rota b",
|
||||
),
|
||||
name="evening",
|
||||
name="twilight",
|
||||
workers_required=1,
|
||||
length=12.5,
|
||||
days=days[:5],
|
||||
balance_offset=2,
|
||||
constraint=[],
|
||||
balance_offset=5,
|
||||
#constraint=[
|
||||
# {"name": "pre", "options": 1},
|
||||
# {"name": "post", "options": 1},
|
||||
#],
|
||||
),
|
||||
)
|
||||
Rota.allow_shifts_together(
|
||||
|
||||
"oncall weekday",
|
||||
"Oncall weekend",
|
||||
"weekend a",
|
||||
"evening",
|
||||
|
||||
)
|
||||
#Rota.allow_shifts_together_for_all_workers(
|
||||
# "oncall",
|
||||
# "twilight",
|
||||
#)
|
||||
#Rota.allow_shifts_together_for_all_workers(
|
||||
# "oncall",
|
||||
# "twilight",
|
||||
#)
|
||||
|
||||
# Rota.add_grade_constraint_by_week([2], [1, 2], ["night_weekday", "night_weekend"])
|
||||
|
||||
@@ -136,8 +120,24 @@ def main(
|
||||
Rota.build_shifts()
|
||||
# Rota.add_grade_constraint_by_week([2], [1], Rota.get_shift_names())
|
||||
|
||||
for w in range(1, 12):
|
||||
w = Worker(name=f"A{w:02d}", site="rota a", grade=1)
|
||||
for n in range(1, 12):
|
||||
w = Worker(name=f"A{n:02d}", site="rota a", grade=1)
|
||||
#w.prefer_multi_shift_together = 10
|
||||
#w.allow_shifts_together("oncall", "twilight")
|
||||
#w.allow_shifts_together("oncall", "weekend")
|
||||
|
||||
#w.add_hard_day_dependency("Fri", "Sat", "Sun")
|
||||
|
||||
w.add_force_assign_with("twilight", "oncall")
|
||||
w.add_force_assign_with("weekend", "oncall")
|
||||
w.set_max_shifts_per_week("twilight", 1)
|
||||
|
||||
if n <= 2:
|
||||
pass
|
||||
w.add_hard_day_dependency("Fri", "Sat", "Sun")
|
||||
else:
|
||||
w.add_hard_day_dependency("Fri", "Sun")
|
||||
## #w.add_hard_day_dependency("Sat", "Sun")
|
||||
|
||||
print(w)
|
||||
|
||||
@@ -154,6 +154,9 @@ def main(
|
||||
)
|
||||
],
|
||||
)
|
||||
#w.add_hard_day_exclusion("Sat", "Sun")
|
||||
w.set_max_shifts_per_week("twilight", 1)
|
||||
w.set_max_shifts_per_week("weekend b", 1)
|
||||
|
||||
print(w)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user