.
This commit is contained in:
@@ -28,18 +28,19 @@ from rota.workers import (
|
||||
suspend_on_finish = True
|
||||
solve = True
|
||||
time_to_run = 258500
|
||||
time_to_run = 36000
|
||||
time_to_run = 166000
|
||||
# allow = 5000
|
||||
ratio = 0.05
|
||||
ratio = 0.01
|
||||
#ratio = 0.9
|
||||
|
||||
|
||||
start_date = datetime.date(2022, 9, 5)
|
||||
#start_date = datetime.date(2022, 10, 10)
|
||||
# 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"] = 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(
|
||||
@@ -48,22 +49,27 @@ Rota.add_shifts(
|
||||
name="exeter_twilight",
|
||||
length=12.5,
|
||||
days=days[:5],
|
||||
#balance_offset=3,
|
||||
constraint=[{"name": "max_shifts_per_week", "options": 2, }],
|
||||
balance_offset=2,
|
||||
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,
|
||||
balance_offset=2,
|
||||
),
|
||||
SingleShift(
|
||||
sites=("torbay", "torbay twilights"),
|
||||
name="torbay_twilight",
|
||||
length=12.5,
|
||||
days=days[:4],
|
||||
#balance_offset=4,
|
||||
balance_offset=2,
|
||||
assign_as_block=True,
|
||||
),
|
||||
SingleShift(
|
||||
@@ -71,7 +77,7 @@ Rota.add_shifts(
|
||||
name="plymouth_twilight",
|
||||
length=12.5,
|
||||
days=days[:5],
|
||||
#balance_offset=4,
|
||||
balance_offset=2,
|
||||
workers_required=1,
|
||||
constraint=[{"name": "max_shifts_per_week", "options": 2}],
|
||||
),
|
||||
@@ -80,18 +86,18 @@ Rota.add_shifts(
|
||||
name="weekend_exeter",
|
||||
length=12.5,
|
||||
days=days[5:],
|
||||
#balance_offset=4,
|
||||
balance_offset=2,
|
||||
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},],
|
||||
# constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2},],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("truro",),
|
||||
name="weekend_truro",
|
||||
length=12.5,
|
||||
days=days[4:],
|
||||
#balance_offset=4,
|
||||
balance_offset=3,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
|
||||
@@ -102,7 +108,7 @@ Rota.add_shifts(
|
||||
name="weekend_torbay",
|
||||
length=12.5,
|
||||
days=days[4:],
|
||||
#balance_offset=4,
|
||||
balance_offset=3,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
|
||||
@@ -113,7 +119,7 @@ Rota.add_shifts(
|
||||
name="weekend_plymouth1",
|
||||
length=8,
|
||||
days=days[5:],
|
||||
#balance_offset=4,
|
||||
balance_offset=2,
|
||||
workers_required=1,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
@@ -124,7 +130,7 @@ Rota.add_shifts(
|
||||
name="weekend_plymouth2",
|
||||
length=8,
|
||||
days=days[5:],
|
||||
#balance_offset=4,
|
||||
balance_offset=2,
|
||||
workers_required=1,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
@@ -135,7 +141,7 @@ Rota.add_shifts(
|
||||
name="plymouth_bank_holidays",
|
||||
length=8,
|
||||
days=days[5:],
|
||||
#balance_offset=2,
|
||||
balance_offset=2,
|
||||
workers_required=1,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=False,
|
||||
@@ -146,7 +152,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,
|
||||
@@ -157,6 +163,8 @@ Rota.add_shifts(
|
||||
{"name": "pre", "options": 5},
|
||||
{"name": "post", "options": 5},
|
||||
{"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
|
||||
{"name": "limit_grade_number", "options": {2: 1}},
|
||||
{"name": "minimum_grade_number", "options": (4, 1)},
|
||||
],
|
||||
),
|
||||
SingleShift(
|
||||
@@ -164,7 +172,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,
|
||||
@@ -175,6 +183,8 @@ Rota.add_shifts(
|
||||
{"name": "pre", "options": 5},
|
||||
{"name": "post", "options": 5},
|
||||
{"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
|
||||
{"name": "limit_grade_number", "options": {2: 1}},
|
||||
{"name": "minimum_grade_number", "options": (4, 1)},
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -283,15 +293,15 @@ if load_leave:
|
||||
)
|
||||
)
|
||||
|
||||
#Rota.build_workers()
|
||||
#Rota.build_model()
|
||||
# Rota.build_workers()
|
||||
# Rota.build_model()
|
||||
|
||||
solver_options = {"ratio": ratio, "seconds": time_to_run, "threads": 10}
|
||||
|
||||
start_time = time.time()
|
||||
Rota.build_and_solve(solver_options)
|
||||
#Rota.solve_shifts_individually(solver_options)
|
||||
#Rota.solve_model(options=solver_options)
|
||||
# Rota.solve_model(options=solver_options)
|
||||
end_time = time.time()
|
||||
|
||||
print(f"Time taken {end_time-start_time}")
|
||||
|
||||
Reference in New Issue
Block a user