Merge branch 'master' of git.xkjq.uk:30001]:ross/proc-rota
This commit is contained in:
@@ -15,26 +15,29 @@ use_neos = False
|
||||
use_cplex = False
|
||||
solve = True
|
||||
|
||||
weeks_to_rota = 8
|
||||
weeks_to_rota = 26
|
||||
|
||||
time_to_run = 158500
|
||||
time_to_run = 258500
|
||||
# allow = 5000
|
||||
ratio = 0.05
|
||||
ratio = 0.01
|
||||
|
||||
use_live_rota = False
|
||||
suspend_on_finish = False
|
||||
suspend_on_finish = True
|
||||
|
||||
|
||||
sites = ("truro", "exeter", "torbay", "barnstaple", "plymouth", "proc", "truro no proc")
|
||||
|
||||
Rota = RotaBuilder(
|
||||
datetime.date(2021, 9, 6),
|
||||
# datetime.date(2022, 6, 6),
|
||||
datetime.date(2022, 3, 7),
|
||||
# Rota = RotaBuilder(datetime.date(2021, 12, 6),
|
||||
# Rota = RotaBuilder(datetime.date(2021, 11, 8),
|
||||
weeks_to_rota=weeks_to_rota,
|
||||
balance_offset_modifier=1,
|
||||
max_weekend_frequency=2,
|
||||
max_night_frequency=2,
|
||||
use_shift_balance_extra=True,
|
||||
use_bank_holiday_extra=True,
|
||||
)
|
||||
|
||||
Rota.constraint_options["limit_to_1_st2_on_nights"] = True
|
||||
@@ -44,19 +47,27 @@ Rota.constraint_options["constrain_time_off_after_nights"] = True
|
||||
Rota.constraint_options["balance_nights_across_sites"] = True
|
||||
Rota.constraint_options["balance_blocks"] = True
|
||||
Rota.constraint_options["balance_weekends"] = True
|
||||
Rota.constraint_options["balance_shifts"] = True
|
||||
Rota.constraint_options["balance_bank_holidays"] = True
|
||||
Rota.constraint_options["avoid_st2_first_month"] = True
|
||||
Rota.constraint_options["avoid_st2_first_month"] = False
|
||||
Rota.constraint_options["hard_constrain_pair_separation"] = True
|
||||
Rota.constraint_options["max_weekends"] = 20
|
||||
Rota.constraint_options["max_weekends"] = 7
|
||||
Rota.constraint_options["prevent_monday_and_tuesday_after_full_weekends"] = [
|
||||
"truro",
|
||||
"torbay",
|
||||
"exeter",
|
||||
"plymouth",
|
||||
"plymouth no proc",
|
||||
"truro no proc",
|
||||
]
|
||||
Rota.constraint_options["prevent_monday_after_full_weekends"] = ["plymouth"]
|
||||
Rota.constraint_options["prevent_fridays_before_full_weekends"] = ["plymouth"]
|
||||
Rota.constraint_options["prevent_monday_after_full_weekends"] = [
|
||||
"plymouth",
|
||||
"plymouth no proc",
|
||||
]
|
||||
Rota.constraint_options["prevent_fridays_before_full_weekends"] = [
|
||||
"plymouth",
|
||||
"plymouth no proc",
|
||||
]
|
||||
Rota.constraint_options["prevent_thursdays_before_full_weekends"] = [
|
||||
"truro",
|
||||
"torbay",
|
||||
@@ -71,11 +82,12 @@ Rota.add_shifts(
|
||||
"exeter_twilight",
|
||||
12.5,
|
||||
days[:4],
|
||||
balance_offset=1.5,
|
||||
constraints=["max_2_shifts_per_week"],
|
||||
),
|
||||
SingleShift(("truro", "truro no proc"), "truro_twilight", 12.5, days[:4]),
|
||||
SingleShift(
|
||||
("torbay",),
|
||||
("torbay", "torbay twilights"),
|
||||
"torbay_twilight",
|
||||
12.5,
|
||||
days[:4],
|
||||
@@ -87,7 +99,7 @@ Rota.add_shifts(
|
||||
"plymouth_twilight",
|
||||
12.5,
|
||||
days[:5],
|
||||
balance_offset=3,
|
||||
balance_offset=1.5,
|
||||
workers_required=1,
|
||||
constraints=["max_2_shifts_per_week"],
|
||||
),
|
||||
@@ -96,7 +108,7 @@ Rota.add_shifts(
|
||||
"weekend_exeter",
|
||||
12.5,
|
||||
days[4:],
|
||||
balance_offset=3,
|
||||
balance_offset=3.5,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
),
|
||||
@@ -105,7 +117,7 @@ Rota.add_shifts(
|
||||
"weekend_truro",
|
||||
12.5,
|
||||
days[4:],
|
||||
balance_offset=3,
|
||||
balance_offset=3.5,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
# force_as_block_unless_nwd=True
|
||||
@@ -115,7 +127,7 @@ Rota.add_shifts(
|
||||
"weekend_torbay",
|
||||
12.5,
|
||||
days[4:],
|
||||
balance_offset=3,
|
||||
balance_offset=3.5,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
# force_as_block_unless_nwd=True
|
||||
@@ -125,7 +137,7 @@ Rota.add_shifts(
|
||||
"weekend_plymouth1",
|
||||
8,
|
||||
days[5:],
|
||||
balance_offset=3,
|
||||
balance_offset=2.5,
|
||||
workers_required=1,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
@@ -135,7 +147,7 @@ Rota.add_shifts(
|
||||
"weekend_plymouth2",
|
||||
8,
|
||||
days[5:],
|
||||
balance_offset=3,
|
||||
balance_offset=2.5,
|
||||
workers_required=1,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=True,
|
||||
@@ -145,7 +157,7 @@ Rota.add_shifts(
|
||||
"plymouth_bank_holidays",
|
||||
8,
|
||||
days[5:],
|
||||
balance_offset=3,
|
||||
balance_offset=1.5,
|
||||
workers_required=1,
|
||||
rota_on_nwds=True,
|
||||
force_as_block=False,
|
||||
@@ -156,7 +168,7 @@ Rota.add_shifts(
|
||||
"night_weekday",
|
||||
12.25,
|
||||
days[:4],
|
||||
balance_offset=4,
|
||||
balance_offset=5,
|
||||
balance_weighting=1,
|
||||
# hard_constrain_shift=False,
|
||||
workers_required=3,
|
||||
@@ -169,7 +181,7 @@ Rota.add_shifts(
|
||||
"night_weekend",
|
||||
12.25,
|
||||
days[4:],
|
||||
balance_offset=3,
|
||||
balance_offset=4,
|
||||
balance_weighting=1,
|
||||
# hard_constrain_shift=False,
|
||||
workers_required=3,
|
||||
@@ -204,10 +216,10 @@ if use_test_workers:
|
||||
[
|
||||
Worker(
|
||||
Rota,
|
||||
i,
|
||||
"Truro {}".format(i),
|
||||
"truro",
|
||||
4,
|
||||
id=i,
|
||||
)
|
||||
for i in range(1, 9)
|
||||
]
|
||||
@@ -223,25 +235,6 @@ if use_test_workers:
|
||||
for i in range(17, 19)
|
||||
]
|
||||
)
|
||||
# Rota.add_workers([
|
||||
# Worker(
|
||||
# Rota,
|
||||
# i,
|
||||
# "Exe {}".format(i),
|
||||
# "exeter",
|
||||
# 4,
|
||||
# ) for i in range(20, 25)
|
||||
# ])
|
||||
# Rota.add_workers([
|
||||
# Worker(
|
||||
# Rota,
|
||||
# i,
|
||||
# "Torq {}".format(i),
|
||||
# "torbay",
|
||||
# 2,
|
||||
# 50,
|
||||
# ) for i in range(25, 29)
|
||||
# ])
|
||||
else:
|
||||
n = 0
|
||||
for worker in workers:
|
||||
@@ -318,10 +311,10 @@ else:
|
||||
Rota.add_worker(
|
||||
Worker(
|
||||
Rota,
|
||||
n,
|
||||
worker_name,
|
||||
site.lower(),
|
||||
int(grade[2]),
|
||||
n,
|
||||
int(fte),
|
||||
nwds,
|
||||
end_date,
|
||||
@@ -331,6 +324,8 @@ else:
|
||||
night_site=site_pref,
|
||||
previous_shifts=previous_shifts,
|
||||
pair=pair,
|
||||
shift_balance_extra=w["shift_balance_extra"],
|
||||
bank_holiday_extra=w["bank_holiday_extra"],
|
||||
)
|
||||
)
|
||||
|
||||
@@ -345,13 +340,11 @@ Rota.build_model()
|
||||
print(Rota.get_worker_details())
|
||||
|
||||
if not solve:
|
||||
ResultsHolder = RotaResults(Rota)
|
||||
ResultsHolder.export_rota_to_html()
|
||||
sys.exit(0)
|
||||
|
||||
solver_options = {
|
||||
"ratio" : ratio,
|
||||
"seconds" : time_to_run,
|
||||
"threads" : 10
|
||||
}
|
||||
solver_options = {"ratio": ratio, "seconds": time_to_run, "threads": 10}
|
||||
|
||||
Rota.solve_model(options=solver_options)
|
||||
|
||||
@@ -362,7 +355,7 @@ Rota.solve_model(options=solver_options)
|
||||
# result.Solver.Status = SolverStatus.warning
|
||||
# prob.solutions.load_from(result)
|
||||
|
||||
ResultsHolder = RotaResults(Rota, Rota.results)
|
||||
ResultsHolder = RotaResults(Rota)
|
||||
|
||||
worker_timetable_brief = ResultsHolder.get_worker_timetable_brief(
|
||||
show_prefs=False, show_unavailable=False
|
||||
|
||||
Reference in New Issue
Block a user