.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import datetime
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from rota.shifts import NoWorkers, RotaBuilder, SingleShift, days
|
||||
|
||||
|
||||
@@ -32,12 +33,13 @@ time_to_run = 258500
|
||||
ratio = 0.5
|
||||
|
||||
|
||||
start_date = datetime.date(2022, 9, 5)
|
||||
start_date = datetime.date(2022, 11, 7)
|
||||
#start_date = datetime.date(2022, 10, 10)
|
||||
|
||||
Rota = RotaBuilder(start_date, weeks_to_rota=12)
|
||||
Rota.constraint_options["balance_weekends"] = True
|
||||
Rota.constraint_options["max_night_frequency"] = 1
|
||||
Rota.constraint_options["max_weekend_frequency"] = 1
|
||||
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(
|
||||
@@ -47,7 +49,7 @@ Rota.add_shifts(
|
||||
length=12.5,
|
||||
days=days[:5],
|
||||
balance_offset=3,
|
||||
constraint=[{"name": "max_shifts_per_week", "options": 2}],
|
||||
constraint=[{"name": "max_shifts_per_week", "options": 2, }],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("truro", "truro twilights"),
|
||||
@@ -81,8 +83,8 @@ Rota.add_shifts(
|
||||
balance_offset=4,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "preclear2"}, {"name": "postclear2"}, {"name": "single_shift_block_per_week"}],
|
||||
#constraint=[{"name": "preclear2"}, {"name": "postclear2"},],
|
||||
constraint=[{"name": "post", "options": 2}, {"name": "pre", "options": 5}],
|
||||
#constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2},],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("truro",),
|
||||
@@ -92,7 +94,7 @@ Rota.add_shifts(
|
||||
balance_offset=4,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "preclear2"}, {"name": "postclear2"}],
|
||||
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
|
||||
# force_as_block_unless_nwd=True
|
||||
),
|
||||
SingleShift(
|
||||
@@ -103,7 +105,7 @@ Rota.add_shifts(
|
||||
balance_offset=4,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "preclear2"}, {"name": "postclear2"}],
|
||||
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
|
||||
# force_as_block_unless_nwd=True
|
||||
),
|
||||
SingleShift(
|
||||
@@ -115,7 +117,7 @@ Rota.add_shifts(
|
||||
workers_required=1,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "preclear2"}, {"name": "postclear2"}],
|
||||
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("plymouth",),
|
||||
@@ -126,7 +128,7 @@ Rota.add_shifts(
|
||||
workers_required=1,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "preclear2"}, {"name": "postclear2"}],
|
||||
constraint=[{"name": "pre", "options": 2}, {"name": "post", "options": 2}],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("plymouth", "plymouth twilights"),
|
||||
@@ -152,8 +154,8 @@ Rota.add_shifts(
|
||||
rota_on_nwds=True,
|
||||
constraint=[
|
||||
{"name": "night"},
|
||||
{"name": "preclear2"},
|
||||
{"name": "postclear2"},
|
||||
{"name": "pre", "options": 5},
|
||||
{"name": "post", "options": 5},
|
||||
{"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
|
||||
],
|
||||
),
|
||||
@@ -170,8 +172,8 @@ Rota.add_shifts(
|
||||
rota_on_nwds=True,
|
||||
constraint=[
|
||||
{"name": "night"},
|
||||
{"name": "preclear2"},
|
||||
{"name": "postclear2"},
|
||||
{"name": "pre", "options": 5},
|
||||
{"name": "post", "options": 5},
|
||||
{"name": "require_remote_site_presence_week", "options": ("plymouth", 1)},
|
||||
],
|
||||
),
|
||||
@@ -284,9 +286,13 @@ 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": 6}
|
||||
|
||||
start_time = time.time()
|
||||
Rota.solve_model(options=solver_options)
|
||||
end_time = time.time()
|
||||
|
||||
print(f"Time taken {end_time-start_time}")
|
||||
|
||||
# print(Rota.get_worker_details())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user