update for current rota

This commit is contained in:
Ross
2024-01-01 14:56:48 +00:00
parent 8c28e7155a
commit 5d55ed77a8
2 changed files with 38 additions and 22 deletions
+27 -17
View File
@@ -30,8 +30,9 @@ solve = True
# time_to_run = 508500
# time_to_run = 2660000
time_to_run = 60 * 60 * 85
time_to_run = 5000
# allow = 5000
ratio = 0.001
ratio = 0.5
# ratio = 0.9
@@ -41,7 +42,7 @@ start_date = datetime.date(2024, 3, 4)
# start_date = datetime.date(2022, 10, 10)
Rota = RotaBuilder(
start_date, weeks_to_rota=26, balance_offset_modifier=1, name="proc rota"
start_date, weeks_to_rota=13, balance_offset_modifier=1, name="proc rota"
)
# Rota = RotaBuilder(start_date, weeks_to_rota=20, balance_offset_modifier=1)
Rota.constraint_options["balance_weekends"] = True
@@ -66,14 +67,14 @@ Rota.add_shifts(
],
),
SingleShift(
sites=("truro", "truro twilights"),
sites=("truro", "truro twilights", "truro twilights and weekends"),
name="truro_twilight",
length=12.5,
days=days[:4],
balance_offset=4,
),
SingleShift(
sites=("torbay", "torbay twilights"),
sites=("torbay", "torbay twilights", "torbay twilights and weekends"),
name="torbay_twilight",
length=12.5,
days=days[:4],
@@ -101,7 +102,7 @@ Rota.add_shifts(
# constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2},],
),
SingleShift(
sites=("truro",),
sites=("truro", "truro twilights and weekends"),
name="weekend_truro",
length=12.5,
days=days[4:],
@@ -112,7 +113,7 @@ Rota.add_shifts(
# force_as_block_unless_nwd=True
),
SingleShift(
sites=("torbay",),
sites=("torbay", "torbay twilights and weekends"),
name="weekend_torbay",
length=12.5,
days=days[4:],
@@ -259,17 +260,25 @@ if load_leave:
if oop:
formatted_oops = []
for dates in oop.split(","):
print(dates)
s, e = dates.split("-")
formatted_oops.append(
{
"start_date": datetime.datetime.strptime(
s.strip(), "%d/%m/%y"
).date(),
"end_date": datetime.datetime.strptime(
e.strip(), "%d/%m/%y"
).date(),
}
)
try:
formatted_oops.append(
{
"start_date": datetime.datetime.strptime(
s.strip(), "%d/%m/%y"
).date(),
"end_date": datetime.datetime.strptime(
e.strip(), "%d/%m/%y"
).date(),
}
)
except ValueError as e:
print(e)
print("WORKER", worker)
print("DATES", s, e)
raise
oop = formatted_oops
else:
@@ -337,7 +346,8 @@ if load_leave:
solver_options = {"ratio": ratio, "seconds": time_to_run, "threads": 10}
#start_time = time.time()
Rota.build_and_solve(solver_options, export=True)
Rota.build_and_solve(solver_options, export=True, solve=True)
# Rota.solve_shifts_by_block(solver_options, block_length=13)
# Rota.solve_shifts_individually(solver_options)
# Rota.solve_model(options=solver_options)
+11 -5
View File
@@ -21,11 +21,14 @@ def load_leave(Rota):
"Pragma": "no-cache"
}
download = s.get("https://docs.google.com/spreadsheets/d/e/2PACX-1vTQBxt0mHoVS1D5EkQcrekqGveWyTG2MCMyV1NnrSWkptqWbdI6_myaeLT1vpbkbujXJqU6Z5nrzTh9/pub?gid=0&single=true&output=csv", headers=headers)
download = s.get("https://docs.google.com/spreadsheets/d/e/2PACX-1vRYqSKq-OYW1tNnGJtx9LIMo_FXVfcHBRPF4HEMcBxWPfmXimWtr5oEDR_rIUSXrOndb9YjP3iC_4bS/pub?gid=0&single=true&output=csv", headers=headers)
decoded_content = download.content.decode('utf-8')
reader = csv.reader(decoded_content.splitlines(), delimiter=',')
#with open("/home/ross/Downloads/Draft PROC Rota March 24 - Sept 24 - Sheet1.csv") as f:
# reader = csv.reader(f.read().splitlines(), delimiter=',')
leave = {}
requests = {}
site_prefs = {}
@@ -48,6 +51,9 @@ def load_leave(Rota):
workers[name]["site_pref"] = []
workers[name]["shift_balance_extra"] = {}
workers[name]["bank_holiday_extra"] = 0
workers[name]["end_date"] = None
workers[name]["start_date"] = None
workers[name]["pair"] = None
for i in range(len(r)):
try:
@@ -64,10 +70,10 @@ def load_leave(Rota):
if lower_item == "derriford twilights":
lower_item = "plymouth_twilights"
if row_title == "PROC site":
if "PROC site" in row_title:
worker["site_pref"] = lower_item
if row_title == "Rotation":
if row_title in ("Rotation", "Site"):
worker["site"] = lower_item
elif row_title == "Grade":
@@ -76,7 +82,7 @@ def load_leave(Rota):
elif row_title == "%FTE":
worker["fte"] = lower_item
elif row_title == "NWD":
elif "NWD" in row_title:
worker["nwd"] = lower_item
elif row_title == "Flexible NWD":
@@ -97,7 +103,7 @@ def load_leave(Rota):
else:
worker["start_date"] = None
elif row_title == "OOP":
elif "OOP" in row_title:
worker["oop"] = lower_item
elif row_title == "Group":