.
This commit is contained in:
@@ -25,11 +25,10 @@ from rota.workers import (
|
||||
)
|
||||
|
||||
|
||||
suspend_on_finish = False
|
||||
suspend_on_finish = True
|
||||
solve = True
|
||||
time_to_run = 258500
|
||||
time_to_run = 36000
|
||||
time_to_run = 200
|
||||
# allow = 5000
|
||||
ratio = 0.05
|
||||
|
||||
@@ -39,145 +38,145 @@ start_date = datetime.date(2022, 9, 5)
|
||||
|
||||
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"] = 4
|
||||
Rota.constraint_options["max_weekend_frequency"] = 4
|
||||
# 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=4,
|
||||
assign_as_block=True,
|
||||
),
|
||||
SingleShift(
|
||||
sites=("plymouth", "plymouth twilights"),
|
||||
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}],
|
||||
),
|
||||
#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)},
|
||||
# ],
|
||||
#),
|
||||
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"])
|
||||
@@ -290,7 +289,8 @@ if load_leave:
|
||||
solver_options = {"ratio": ratio, "seconds": time_to_run, "threads": 10}
|
||||
|
||||
start_time = time.time()
|
||||
Rota.solve_shifts_individually(solver_options)
|
||||
Rota.build_and_solve(solver_options)
|
||||
#Rota.solve_shifts_individually(solver_options)
|
||||
#Rota.solve_model(options=solver_options)
|
||||
end_time = time.time()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user