Merge branch 'master' of git.xkjq.uk:30001]:ross/proc-rota

This commit is contained in:
Ross
2022-01-28 17:39:31 +00:00
3 changed files with 41 additions and 15 deletions
+36 -11
View File
@@ -181,6 +181,8 @@ class RotaBuilder(object):
"prevent_monday_and_tuesday_after_full_weekends": [],
"prevent_fridays_before_full_weekends": [],
"prevent_thursdays_before_full_weekends": [],
# This may be better defined on the shift?
"require_presence_at_site_overnight": [],
"avoid_st2_first_month": False,
"hard_constrain_pair_separation": False,
}
@@ -739,24 +741,47 @@ class RotaBuilder(object):
rule=nightShiftMinST4Rule,
)
def nightShiftDerrifordRule(model, week, shift):
derriford_workers = [w for w in self.workers if w.night_at_derriford >= 1]
# if not derriford_workers:
# return Constraint.Skip
# def nightShiftDerrifordRule(model, week, shift):
# derriford_workers = [w for w in self.workers if w.night_at_derriford >= 1]
# # if not derriford_workers:
# # return Constraint.Skip
# return (
# sum(
# model.shift_week_worker_assigned[shift, week, w.id]
# for w in derriford_workers
# )
# >= 1
# )
# if self.constraint_options["ensure_derriford_reg_for_nights"]:
# self.model.night_shifts_derriford_rule = Constraint(
# [week for week in self.weeks],
# [shift.name for shift in self.get_shifts_with_constraint("night")],
# rule=nightShiftDerrifordRule,
# )
def presenceAtSiteOvernight(model, week, shift, required_site):
required_site_workers = [
w for w in self.workers if required_site == w.night_site
]
return (
sum(
model.shift_week_worker_assigned[shift, week, w.id]
for w in derriford_workers
for w in required_site_workers
)
>= 1
)
if self.constraint_options["ensure_derriford_reg_for_nights"]:
self.model.night_shifts_derriford_rule = Constraint(
[week for week in self.weeks],
[shift.name for shift in self.get_shifts_with_constraint("night")],
rule=nightShiftDerrifordRule,
)
if self.constraint_options["require_presence_at_site_overnight"]:
for site in self.constraint_options["require_presence_at_site_overnight"]:
self.model.require_presence_at_site_overnight_rule = Constraint(
[week for week in self.weeks],
[shift.name for shift in self.get_shifts_with_constraint("night")],
[site],
rule=presenceAtSiteOvernight,
)
# # Count the number of workers from each site on each night shift
# # As 1 or 0 is optimum we can simply subtract 1 from the number