update
This commit is contained in:
@@ -6,34 +6,29 @@ from pyomo.opt.results import SolverStatus
|
||||
from shifts import SingleShift, RotaBuilder, RotaResults, days
|
||||
from workers import Worker
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
import math
|
||||
|
||||
import scipy.stats as stats
|
||||
|
||||
import statistics
|
||||
|
||||
import datetime
|
||||
import itertools
|
||||
import operator
|
||||
|
||||
import sys
|
||||
|
||||
use_neos = True
|
||||
use_neos = False
|
||||
use_cplex = False
|
||||
solve = True
|
||||
|
||||
weeks_to_rota = 26
|
||||
weeks_to_rota = 13
|
||||
|
||||
time_to_run = 28500
|
||||
allow = 10000
|
||||
#allow = 5000
|
||||
ratio = 0.5
|
||||
|
||||
use_live_rota = True
|
||||
|
||||
use_cplex = True
|
||||
|
||||
sites = ("truro", "exeter", "torbay", "barnstaple", "plymouth")
|
||||
|
||||
Rota = RotaBuilder(datetime.date(2021, 9, 6),
|
||||
#Rota = RotaBuilder(datetime.date(2021, 11, 8),
|
||||
weeks_to_rota=weeks_to_rota,
|
||||
balance_offset_modifier=1,
|
||||
balance_offset_modifier=2,
|
||||
max_weekend_frequency=2,
|
||||
max_night_frequency=2)
|
||||
|
||||
@@ -44,7 +39,8 @@ 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["avoid_st1_first_month"] = True
|
||||
Rota.constraint_options["balance_bank_holidays"] = True
|
||||
Rota.constraint_options["avoid_st2_first_month"] = True
|
||||
Rota.constraint_options["max_weekends"] = 20
|
||||
Rota.constraint_options["prevent_monday_and_tuesday_after_full_weekends"] = [
|
||||
"truro", "torbay", "exeter"
|
||||
@@ -142,7 +138,7 @@ Rota.build_shifts_and_workers()
|
||||
if load_leave:
|
||||
import leave
|
||||
|
||||
workers = leave.load_leave(Rota)
|
||||
workers = leave.load_leave(Rota, use_live_rota)
|
||||
|
||||
|
||||
# Import trainee data
|
||||
@@ -250,37 +246,6 @@ else:
|
||||
work_requests = w["requests"]
|
||||
site_pref = w["site_pref"]
|
||||
|
||||
#print(nwds, end_date, oop)
|
||||
# Rota.add_worker(
|
||||
# Worker(Rota, n, name, site.lower(), int(grade[2]), 100,
|
||||
# ))
|
||||
# if name.startswith(("Alex", "Michal", "Ross")):
|
||||
# Rota.add_worker(
|
||||
# Worker(Rota,
|
||||
# n,
|
||||
# name,
|
||||
# site.lower(),
|
||||
# int(grade[2]),
|
||||
# int(fte),
|
||||
# nwds,
|
||||
# end_date,
|
||||
# oop,
|
||||
# work_requests=(("2020/09/07", "night_weekday"), )))
|
||||
# continue
|
||||
# if "Salma" in name:
|
||||
# Rota.add_worker(
|
||||
# Worker(Rota,
|
||||
# n,
|
||||
# name,
|
||||
# site.lower(),
|
||||
# int(grade[2]),
|
||||
# int(fte),
|
||||
# nwds,
|
||||
# end_date,
|
||||
# oop,
|
||||
# work_requests=(("2020/12/25",
|
||||
# "exeter_twilight"), )))
|
||||
# continue
|
||||
Rota.add_worker(
|
||||
Worker(Rota,
|
||||
n,
|
||||
@@ -315,7 +280,8 @@ else:
|
||||
opt = SolverFactory('cbc') # choose a solver
|
||||
#opt = SolverFactory('ipopt') # choose a solver
|
||||
|
||||
opt.options['allow'] = allow
|
||||
#opt.options['allow'] = allow
|
||||
opt.options['ratio'] = ratio
|
||||
opt.options['seconds'] = time_to_run
|
||||
|
||||
print("Solving")
|
||||
@@ -330,7 +296,8 @@ else:
|
||||
options={
|
||||
"seconds": time_to_run,
|
||||
#"allow": allow,
|
||||
"threads": 2,
|
||||
"ratio": ratio,
|
||||
"threads": 10,
|
||||
},
|
||||
logfile="test.log"
|
||||
) # solve the model with the, options="seconds=60" selected solver
|
||||
@@ -361,41 +328,4 @@ ResultsHolder.get_weekend_details()
|
||||
with open("test.html", "w") as f:
|
||||
f.write(ResultsHolder.get_worker_timetable_html(True))
|
||||
|
||||
ResultsHolder.export_rota_to_csv("rota")
|
||||
|
||||
# for i in ResultsHolder.rota.model.blocks_worker_shift_count:
|
||||
# n = ResultsHolder.rota.model.blocks_worker_shift_count[i].value
|
||||
|
||||
# if n > 0:
|
||||
# print(i, n)
|
||||
# #print(ResultsHolder.rota.model.blocks_assigned[i].value)
|
||||
# else:
|
||||
# pass
|
||||
# #print("SHIT")
|
||||
# for i in ResultsHolder.rota.model.blocks_assigned:
|
||||
# n = ResultsHolder.rota.model.blocks_assigned[i].value
|
||||
# if n:
|
||||
# print(i, n)
|
||||
# #print(ResultsHolder.rota.model.blocks_assigned[i].value)
|
||||
# else:
|
||||
# pass
|
||||
|
||||
# ResultsHolder.export_rota_to_csv("rotas/"+rot)
|
||||
# with open("cest", "a") as f:
|
||||
# f.write(rot)
|
||||
# f.write("\n\n")
|
||||
|
||||
# for s in Rota.shifts:
|
||||
# f.write(s.get_shift_summary())
|
||||
# f.write("\n")
|
||||
# f.write("\n\n")
|
||||
|
||||
# f.write(worker_timetable_brief)
|
||||
# f.write("\n\n\n")
|
||||
#workers_no_pref = ResultsHolder.get_no_preference(Rota.model.no_pref) # list with the non-satisfied workers (work on Sat but not on Sun)
|
||||
|
||||
# worker_night_block = ResultsHolder.get_night_blocks()
|
||||
# worker_shift_summary = ResultsHolder.get_shift_summary()
|
||||
# multi = ResultsHolder.get_multinight()
|
||||
|
||||
#break
|
||||
ResultsHolder.export_rota_to_csv("rota")
|
||||
Reference in New Issue
Block a user