This commit is contained in:
Ross
2022-07-27 07:49:34 +01:00
parent ecd81236a2
commit 7ef0c191d7
5 changed files with 411 additions and 51 deletions
+25 -21
View File
@@ -25,22 +25,26 @@ from rota.workers import (
)
suspend_on_finish = False
suspend_on_finish = True
solve = True
time_to_run = 258500
time_to_run = 26600000
#time_to_run = 2660000
#time_to_run = 458500
# allow = 5000
ratio = 0.01
ratio = 0.001
#ratio = 0.9
start_date = datetime.date(2022, 9, 5)
#start_date = start_date + datetime.timedelta(weeks=13)
# start_date = datetime.date(2022, 10, 10)
Rota = RotaBuilder(start_date, weeks_to_rota=26)
Rota.constraint_options["balance_weekends"] = True
Rota.constraint_options["max_night_frequency"] = 3
Rota.constraint_options["max_weekend_frequency"] = 3
Rota.constraint_options["max_night_frequency_week_exclusions"] = [1,2,3,4,5,6]
Rota.constraint_options["max_weekend_frequency"] = 2
Rota.constraint_options["hard_constrain_pair_separation"] = True
# Rota.constraint_options["avoid_st2_first_month"] = True
Rota.add_shifts(
@@ -49,7 +53,7 @@ Rota.add_shifts(
name="exeter_twilight",
length=12.5,
days=days[:5],
balance_offset=2,
balance_offset=4,
constraint=[
{
"name": "max_shifts_per_week",
@@ -62,14 +66,14 @@ Rota.add_shifts(
name="truro_twilight",
length=12.5,
days=days[:4],
balance_offset=2,
balance_offset=4,
),
SingleShift(
sites=("torbay", "torbay twilights"),
name="torbay_twilight",
length=12.5,
days=days[:4],
balance_offset=2,
balance_offset=4,
assign_as_block=True,
),
SingleShift(
@@ -77,7 +81,7 @@ Rota.add_shifts(
name="plymouth_twilight",
length=12.5,
days=days[:5],
balance_offset=2,
balance_offset=4,
workers_required=1,
constraint=[{"name": "max_shifts_per_week", "options": 2}],
),
@@ -86,7 +90,7 @@ Rota.add_shifts(
name="weekend_exeter",
length=12.5,
days=days[5:],
balance_offset=2,
balance_offset=3,
rota_on_nwds=True,
force_as_block=True,
constraint=[{"name": "post", "options": 2}, {"name": "pre", "options": 5}],
@@ -119,7 +123,7 @@ Rota.add_shifts(
name="weekend_plymouth1",
length=8,
days=days[5:],
balance_offset=2,
balance_offset=3,
workers_required=1,
rota_on_nwds=True,
force_as_block=True,
@@ -130,7 +134,7 @@ Rota.add_shifts(
name="weekend_plymouth2",
length=8,
days=days[5:],
balance_offset=2,
balance_offset=3,
workers_required=1,
rota_on_nwds=True,
force_as_block=True,
@@ -141,7 +145,7 @@ Rota.add_shifts(
name="plymouth_bank_holidays",
length=8,
days=days[5:],
balance_offset=2,
balance_offset=3,
workers_required=1,
rota_on_nwds=True,
force_as_block=False,
@@ -152,7 +156,7 @@ Rota.add_shifts(
name="night_weekday",
length=12.25,
days=days[:4],
# balance_offset=4.9,
balance_offset=4.9,
balance_weighting=1,
# hard_constrain_shift=False,
workers_required=3,
@@ -160,8 +164,8 @@ Rota.add_shifts(
rota_on_nwds=True,
constraint=[
{"name": "night"},
{"name": "pre", "options": 5},
{"name": "post", "options": 5},
{"name": "pre", "options": 2},
{"name": "post", "options": 2},
{"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
{"name": "limit_grade_number", "options": {2: 1}},
{"name": "minimum_grade_number", "options": (4, 1)},
@@ -172,7 +176,7 @@ Rota.add_shifts(
name="night_weekend",
length=12.25,
days=days[4:],
# balance_offset=3.9,
balance_offset=3.9,
balance_weighting=1,
# hard_constrain_shift=False,
workers_required=3,
@@ -180,8 +184,8 @@ Rota.add_shifts(
rota_on_nwds=True,
constraint=[
{"name": "night"},
{"name": "pre", "options": 5},
{"name": "post", "options": 5},
{"name": "pre", "options": 2},
{"name": "post", "options": 3},
{"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
{"name": "limit_grade_number", "options": {2: 1}},
{"name": "minimum_grade_number", "options": (4, 1)},
@@ -189,11 +193,11 @@ Rota.add_shifts(
),
)
Rota.add_grade_constraint_by_week([2], [1, 2, 3, 4], ["night_weekday", "night_weekend"])
Rota.add_grade_constraint_by_week([2], [1, 2], ["night_weekday", "night_weekend"])
load_leave = True
Rota.build_shifts()
Rota.add_grade_constraint_by_week([2], [1, 2], Rota.get_shift_names())
Rota.add_grade_constraint_by_week([2], [1], Rota.get_shift_names())
if load_leave:
import leave
@@ -296,7 +300,7 @@ if load_leave:
# Rota.build_workers()
# Rota.build_model()
solver_options = {"ratio": ratio, "seconds": time_to_run, "threads": 10}
solver_options = {"ratio": ratio, "seconds": time_to_run, "threads": 11}
start_time = time.time()
Rota.build_and_solve(solver_options)