This commit is contained in:
Ross
2021-06-24 21:02:18 +01:00
parent 01005176a5
commit ab73ead7c1
8 changed files with 689 additions and 545 deletions
+44 -20
View File
@@ -11,24 +11,25 @@ import datetime
import sys
use_neos = True
use_cplex = False
use_cplex = True
solve = True
weeks_to_rota = 6
weeks_to_rota = 26
time_to_run = 28500
time_to_run = 208500
#allow = 5000
ratio = 0.5
ratio = 0.4
use_live_rota = False
sites = ("truro", "exeter", "torbay", "barnstaple", "plymouth")
sites = ("truro", "exeter", "torbay", "barnstaple", "plymouth", "proc", "truro no proc")
#Rota = RotaBuilder(datetime.date(2021, 9, 6),
Rota = RotaBuilder(datetime.date(2021, 12, 6),
Rota = RotaBuilder(datetime.date(2021, 9, 6),
#Rota = RotaBuilder(datetime.date(2021, 12, 6),
#Rota = RotaBuilder(datetime.date(2021, 11, 8),
weeks_to_rota=weeks_to_rota,
balance_offset_modifier=2,
balance_offset_modifier=1,
max_weekend_frequency=2,
max_night_frequency=2)
@@ -41,24 +42,26 @@ Rota.constraint_options["balance_blocks"] = True
Rota.constraint_options["balance_weekends"] = True
Rota.constraint_options["balance_bank_holidays"] = True
Rota.constraint_options["avoid_st2_first_month"] = True
Rota.constraint_options["hard_constrain_pair_separation"] = True
Rota.constraint_options["max_weekends"] = 20
Rota.constraint_options["prevent_monday_and_tuesday_after_full_weekends"] = [
"truro", "torbay", "exeter"
"truro", "torbay", "exeter", "plymouth", "truro no proc"
]
Rota.constraint_options["prevent_monday_after_full_weekends"] = ["plymouth"]
Rota.constraint_options["prevent_fridays_before_full_weekends"] = ["plymouth"]
Rota.constraint_options["prevent_thursdays_before_full_weekends"] = [
"truro", "torbay", "exeter"
"truro", "torbay", "exeter", "truro no proc"
]
Rota.add_shifts(
SingleShift(("exeter", ), "exeter_twilight", 12.5, days[:4]),
SingleShift(("truro", ), "truro_twilight", 12.5, days[:4]),
SingleShift(("exeter", ), "exeter_twilight", 12.5, days[:4],
constraints=["max_2_shifts_per_week"]),
SingleShift(("truro", "truro no proc" ), "truro_twilight", 12.5, days[:4]),
SingleShift(("torbay", ),
"torbay_twilight",
12.5,
days[:4],
balance_offset=3,
balance_offset=4,
assign_as_block=True),
SingleShift(("plymouth", "plymouth_twilights"),
"plymouth_twilight",
@@ -66,7 +69,7 @@ Rota.add_shifts(
days[:5],
balance_offset=3,
workers_required=1,
constraints=["max_2_consecutive_shifts_per_week"]),
constraints=["max_2_shifts_per_week"]),
SingleShift(("exeter", ),
"weekend_exeter",
12.5,
@@ -74,7 +77,7 @@ Rota.add_shifts(
balance_offset=3,
rota_on_nwds=True,
force_as_block=True),
SingleShift(("truro", ),
SingleShift(("truro", "truro no proc"),
"weekend_truro",
12.5,
days[4:],
@@ -114,11 +117,11 @@ Rota.add_shifts(
force_as_block=False,
bank_holidays_only=True),
SingleShift(
(sites),
(sites[:-1]),
"night_weekday",
12.25,
days[:4],
balance_offset=3,
balance_offset=4,
balance_weighting=1,
#hard_constrain_shift=False,
workers_required=3,
@@ -126,7 +129,7 @@ Rota.add_shifts(
rota_on_nwds=True,
constraints=["night"]),
SingleShift(
(sites),
(sites[:-1]),
"night_weekend",
12.25,
days[4:],
@@ -214,13 +217,31 @@ else:
end_date = w["end_date"]
oop = w["oop"]
grade = w["grade"]
pair = w["pair"]
#name, site, grade, fte, nwd, end_date, oop, twi, twi_we, night, night_we, pw1, pw2, extra = row
# Ignore trainees if fte == 0 (what are they doing here anyway)
if fte == 0 or fte == "0" or fte == "":
continue
nwds = [i.strip()[:3].capitalize() for i in nwd.split("/")] if nwd else None
nwds = None
if nwd:
nwds = []
for i in nwd.split(","):
nwd_start_date = Rota.start_date
nwd_end_date = Rota.rota_end_date
if "[" in i:
print(i, i.split("[")[1][:-1])
a, b = i.split("[")[1][:-1].split("-")
nwd_start_date = datetime.datetime.strptime(a,
"%d/%m/%y").date()
nwd_end_date = datetime.datetime.strptime(b,
"%d/%m/%y").date()
nwds.append((i.split("[")[0].strip()[:3].capitalize(), nwd_start_date, nwd_end_date))
#nwds = [i.strip()[:3].capitalize() for i in nwd.split("/")] if nwd else None
print(name, nwds)
end_date = end_date if end_date else None
oop = oop.split("-") if oop else None
@@ -268,11 +289,14 @@ else:
not_available_to_work=leave_requests,
work_requests=work_requests,
proc_site=site_pref,
previous_shifts=previous_shifts))
previous_shifts=previous_shifts,
pair=pair))
print("Building model")
Rota.build_shifts_and_workers()
print("PAIRS", Rota.worker_pairs)
Rota.sites.add("plymouth_twilights")
Rota.build_model()