more updates

This commit is contained in:
Ross
2022-07-14 12:12:50 +01:00
parent f79e32ba1d
commit 8f8e5a2a28
6 changed files with 338 additions and 195 deletions
+137 -135
View File
@@ -13,7 +13,6 @@ sites = (
"plymouth",
"taunton",
"proc",
"truro no proc",
)
from rota.workers import (
@@ -29,154 +28,156 @@ from rota.workers import (
suspend_on_finish = False
solve = True
time_to_run = 258500
time_to_run = 36000
time_to_run = 200
# allow = 5000
ratio = 0.5
ratio = 0.05
start_date = datetime.date(2022, 9, 5)
#start_date = datetime.date(2022, 10, 10)
Rota = RotaBuilder(start_date, weeks_to_rota=12)
Rota = RotaBuilder(start_date, weeks_to_rota=26)
Rota.constraint_options["balance_weekends"] = True
Rota.constraint_options["max_night_frequency"] = 4
Rota.constraint_options["max_weekend_frequency"] = 4
Rota.constraint_options["max_night_frequency"] = 3
Rota.constraint_options["max_weekend_frequency"] = 3
# Rota.constraint_options["avoid_st2_first_month"] = True
Rota.add_shifts(
SingleShift(
sites=("exeter", "exeter twilights and weekends"),
name="exeter_twilight",
length=12.5,
days=days[:5],
balance_offset=3,
constraint=[{"name": "max_shifts_per_week", "options": 2, }],
),
SingleShift(
sites=("truro", "truro twilights"),
name="truro_twilight",
length=12.5,
days=days[:4],
balance_offset=3,
),
SingleShift(
sites=("torbay", "torbay twilights"),
name="torbay_twilight",
length=12.5,
days=days[:4],
balance_offset=5,
assign_as_block=True,
),
#SingleShift(
# sites=("exeter", "exeter twilights and weekends"),
# name="exeter_twilight",
# length=12.5,
# days=days[:5],
# balance_offset=3,
# constraint=[{"name": "max_shifts_per_week", "options": 2, }],
#),
#SingleShift(
# sites=("truro", "truro twilights"),
# name="truro_twilight",
# length=12.5,
# days=days[:4],
# balance_offset=3,
#),
#SingleShift(
# sites=("torbay", "torbay twilights"),
# name="torbay_twilight",
# length=12.5,
# days=days[:4],
# balance_offset=5,
# assign_as_block=True,
#),
SingleShift(
sites=("plymouth", "plymouth twilights"),
name="plymouth_twilight",
length=12.5,
days=days[:5],
balance_offset=3,
balance_offset=2,
workers_required=1,
constraint=[{"name": "max_shifts_per_week", "options": 2}],
),
SingleShift(
sites=("exeter", "exeter twilights and weekends"),
name="weekend_exeter",
length=12.5,
days=days[5:],
balance_offset=4,
rota_on_nwds=True,
force_as_block=True,
constraint=[{"name": "post", "options": 2}, {"name": "pre", "options": 5}],
#constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2},],
),
SingleShift(
sites=("truro",),
name="weekend_truro",
length=12.5,
days=days[4:],
balance_offset=4,
rota_on_nwds=True,
force_as_block=True,
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
# force_as_block_unless_nwd=True
),
SingleShift(
sites=("torbay",),
name="weekend_torbay",
length=12.5,
days=days[4:],
balance_offset=4,
rota_on_nwds=True,
force_as_block=True,
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
# force_as_block_unless_nwd=True
),
SingleShift(
sites=("plymouth",),
name="weekend_plymouth1",
length=8,
days=days[5:],
balance_offset=4,
workers_required=1,
rota_on_nwds=True,
force_as_block=True,
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
),
SingleShift(
sites=("plymouth",),
name="weekend_plymouth2",
length=8,
days=days[5:],
balance_offset=4,
workers_required=1,
rota_on_nwds=True,
force_as_block=True,
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
),
SingleShift(
sites=("plymouth", "plymouth twilights"),
name="plymouth_bank_holidays",
length=8,
days=days[5:],
balance_offset=2,
workers_required=1,
rota_on_nwds=True,
force_as_block=False,
bank_holidays_only=True,
),
SingleShift(
sites=(sites[:-1]),
name="night_weekday",
length=12.25,
days=days[:4],
balance_offset=4.9,
balance_weighting=1,
# hard_constrain_shift=False,
workers_required=3,
force_as_block=True,
rota_on_nwds=True,
constraint=[
{"name": "night"},
{"name": "pre", "options": 5},
{"name": "post", "options": 5},
{"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
],
),
SingleShift(
sites=(sites[:-1]),
name="night_weekend",
length=12.25,
days=days[4:],
balance_offset=3.9,
balance_weighting=1,
# hard_constrain_shift=False,
workers_required=3,
force_as_block=True,
rota_on_nwds=True,
constraint=[
{"name": "night"},
{"name": "pre", "options": 5},
{"name": "post", "options": 5},
{"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
],
),
#SingleShift(
# sites=("exeter", "exeter twilights and weekends"),
# name="weekend_exeter",
# length=12.5,
# days=days[5:],
# balance_offset=4,
# rota_on_nwds=True,
# force_as_block=True,
# constraint=[{"name": "post", "options": 2}, {"name": "pre", "options": 5}],
# #constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2},],
#),
#SingleShift(
# sites=("truro",),
# name="weekend_truro",
# length=12.5,
# days=days[4:],
# balance_offset=4,
# rota_on_nwds=True,
# force_as_block=True,
# constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
# # force_as_block_unless_nwd=True
#),
#SingleShift(
# sites=("torbay",),
# name="weekend_torbay",
# length=12.5,
# days=days[4:],
# balance_offset=4,
# rota_on_nwds=True,
# force_as_block=True,
# constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
# # force_as_block_unless_nwd=True
#),
#SingleShift(
# sites=("plymouth",),
# name="weekend_plymouth1",
# length=8,
# days=days[5:],
# balance_offset=4,
# workers_required=1,
# rota_on_nwds=True,
# force_as_block=True,
# constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
#),
#SingleShift(
# sites=("plymouth",),
# name="weekend_plymouth2",
# length=8,
# days=days[5:],
# balance_offset=4,
# workers_required=1,
# rota_on_nwds=True,
# force_as_block=True,
# constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
#),
#SingleShift(
# sites=("plymouth", "plymouth twilights"),
# name="plymouth_bank_holidays",
# length=8,
# days=days[5:],
# balance_offset=2,
# workers_required=1,
# rota_on_nwds=True,
# force_as_block=False,
# bank_holidays_only=True,
#),
#SingleShift(
# sites=(sites),
# name="night_weekday",
# length=12.25,
# days=days[:4],
# balance_offset=4.9,
# balance_weighting=1,
# # hard_constrain_shift=False,
# workers_required=3,
# force_as_block=True,
# rota_on_nwds=True,
# constraint=[
# {"name": "night"},
# {"name": "pre", "options": 5},
# {"name": "post", "options": 5},
# {"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
# ],
#),
#SingleShift(
# sites=(sites),
# name="night_weekend",
# length=12.25,
# days=days[4:],
# balance_offset=3.9,
# balance_weighting=1,
# # hard_constrain_shift=False,
# workers_required=3,
# force_as_block=True,
# rota_on_nwds=True,
# constraint=[
# {"name": "night"},
# {"name": "pre", "options": 5},
# {"name": "post", "options": 5},
# {"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
# ],
#),
)
Rota.add_grade_constraint_by_week([2], [1, 2, 3, 4], ["night_weekday", "night_weekend"])
@@ -283,13 +284,14 @@ if load_leave:
)
)
Rota.build_workers()
Rota.build_model()
#Rota.build_workers()
#Rota.build_model()
solver_options = {"ratio": ratio, "seconds": time_to_run, "threads": 6}
solver_options = {"ratio": ratio, "seconds": time_to_run, "threads": 10}
start_time = time.time()
Rota.solve_model(options=solver_options)
Rota.solve_shifts_individually(solver_options)
#Rota.solve_model(options=solver_options)
end_time = time.time()
print(f"Time taken {end_time-start_time}")