521 lines
49 KiB
Plaintext
521 lines
49 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from pyomo.environ import *\n",
|
|
"from pyomo.opt import SolverFactory\n",
|
|
"from shifts import SingleShift, RotaBuilder, days\n",
|
|
"from workers import Worker\n",
|
|
"\n",
|
|
"import math\n",
|
|
"\n",
|
|
"import scipy.stats as stats\n",
|
|
"\n",
|
|
"import statistics\n",
|
|
"\n",
|
|
"import datetime\n",
|
|
"import itertools\n",
|
|
"import operator\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#night_balance_offset = 2\n",
|
|
"#twilight_balance_offset = 1\n",
|
|
"weeks_to_rota = 26\n",
|
|
"use_test_workers = False"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"\n",
|
|
"sites = (\"truro\", \"exeter\", \"torquay\", \"barnstaple\", \"plymouth\")\n",
|
|
"\n",
|
|
"Rota = RotaBuilder(datetime.date(2020, 9, 7), weeks_to_rota=weeks_to_rota, balance_offset_modifier=1)\n",
|
|
"\n",
|
|
"rota_collections = {\n",
|
|
"\n",
|
|
" #\"current\" : RotaBuilder(datetime.date(2020, 9, 7), weeks_to_rota=weeks_to_rota, balance_offset_modifier=2)\n",
|
|
"}\n",
|
|
"\n",
|
|
"Rota.add_shifts(\n",
|
|
" SingleShift((\"exeter\",), \"exeter_twilight\", 12.5, days[:5]),\n",
|
|
" SingleShift((\"truro\",), \"truro_twilight\", 12.5, days[:5]),\n",
|
|
" SingleShift((\"torquay\",), \"torquay_twilight\", 12.5, days[:5]),\n",
|
|
" SingleShift((\"plymouth\",), \"plymouth_twilight\", 12.5, days[:5]), \n",
|
|
" SingleShift((\"exeter\",), \"weekend_exeter\", 12.5, days[5:], assign_as_block=True), \n",
|
|
" SingleShift((\"truro\",), \"weekend_truro\", 12.5, days[5:], assign_as_block=True), \n",
|
|
" SingleShift((\"torquay\",), \"weekend_torquay\", 12.5, days[5:], assign_as_block=True), \n",
|
|
" SingleShift((\"plymouth\",), \"weekend_plymouth\", 8, days[5:], workers_required=2, assign_as_block=True), \n",
|
|
" #SingleShift((sites), \"night\", 12.5, days, balance_weighting=1, workers_required=3, rota_on_nwds=True), \n",
|
|
" SingleShift((sites), \"night\", 12.5, days, balance_offset=2, balance_weighting=1, workers_required=3, rota_on_nwds=True), \n",
|
|
")\n",
|
|
"\n",
|
|
"\n",
|
|
"#Rota2 = RotaBuilder(weeks_to_rota=weeks_to_rota)\n",
|
|
"\n",
|
|
"#Rota2.add_shifts(\n",
|
|
"# SingleShift((\"exeter\",), \"exeter_twilight\", 12.5, days[:5], balance_offset=3), \n",
|
|
"# SingleShift((\"exeter\",), \"weekend_exeter\", 12.5, days[5:], balance_offset=3, balance_weighting=1), \n",
|
|
"# SingleShift((sites), \"night\", 12.5, days, balance_offset=2, balance_weighting=4, workers_required=3, rota_on_nwds=True), \n",
|
|
"#)\n",
|
|
"\n",
|
|
"#Rota = Rota2\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"if use_test_workers:\n",
|
|
" # Enter workers ids (name, number, ...)\n",
|
|
" Rota.add_workers([Worker(Rota, i, \"Truro {}\".format(i), \"truro\", 3, nwd=['Fri', \"Sat\", \"Sun\"]) for i in range(1, 2)])\n",
|
|
" Rota.add_workers([Worker(Rota,i, \"Truro {}\".format(i), \"truro\", 4, pref_not_to_work=((\"2020/09/07\"),(\"2020/09/08\"),(\"2020/09/09\"),(\"2020/09/10\")) ) for i in range(2, 14)])\n",
|
|
" Rota.add_workers([Worker(Rota,i, \"Plym {}\".format(i), \"plymouth\", 4) for i in range(16, 30)])\n",
|
|
" Rota.add_workers([Worker(Rota,i, \"Exe {}\".format(i), \"exeter\", 4, pref_not_to_work=((\"2020/09/07\"),)) for i in range(30, 40)])\n",
|
|
" Rota.add_workers([Worker(Rota,i, \"Torq {}\".format(i), \"torquay\", 4, pref_not_to_work=((\"2020/09/07\"),)) for i in range(50, 60)])\n",
|
|
" #workers.extend([workerClass(i, \"Test Person {}\".format(i), 4, 200, \"\") for i in range(48, 49)])\n",
|
|
" \n",
|
|
" #workers.extend([Worker(Rota,i, \"Test Person {}\".format(i), \"exeter\", 4) for i in range(34, 45)])\n",
|
|
" #Rota.add_worker([Worker(Rota,i, \"Test Person {}\".format(i), \"torquay\", 4, pref_not_to_work=(\"2020/09/10\",\"2020/09/7\",\"2020/09/14\",\"2020/09/23\")) for i in range(45, 46)])\n",
|
|
"else:\n",
|
|
" # Import trainee data\n",
|
|
" import csv\n",
|
|
"\n",
|
|
" with open('trainees.csv', newline='') as f:\n",
|
|
" reader = csv.reader(f, delimiter=',', quotechar='|')\n",
|
|
" next(reader) # skip header\n",
|
|
"\n",
|
|
" n = 0\n",
|
|
" for row in reader:\n",
|
|
" n = n + 1\n",
|
|
" #print(row)\n",
|
|
" name, site, grade, fte, nwd, end_date, oop, extra = row\n",
|
|
"\n",
|
|
" # Ignore trainees if fte == 0 (what are they doing here anyway)\n",
|
|
" if fte == 0:\n",
|
|
" continue\n",
|
|
"\n",
|
|
" nwds = nwd.split(\",\").title() if nwd else None\n",
|
|
" end_date = end_date if end_date else None\n",
|
|
" oop = oop.split(\"-\") if oop else None\n",
|
|
" #print(nwds, end_date, oop)\n",
|
|
" Rota.add_worker(Worker(Rota, n, name, site.lower(), int(grade[2]), int(fte), nwds, end_date, oop))\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {
|
|
"tags": [
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend"
|
|
]
|
|
},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": "{'exeter', 'truro', 'plymouth', 'barnstaple', 'torquay'}\n"
|
|
}
|
|
],
|
|
"source": [
|
|
"Rota.build_workers()\n",
|
|
"print(Rota.sites)\n",
|
|
"Rota.build_model()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {
|
|
"tags": [
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend",
|
|
"outputPrepend"
|
|
]
|
|
},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": "Welcome to the CBC MILP Solver \nVersion: 2.9.9 \nBuild Date: Aug 7 2019 \n\ncommand line - /usr/bin/cbc -seconds 3600 -allow 3500 -printingOptions all -import /tmp/tmpf5i54yvl.pyomo.lp -stat=1 -solve -solu /tmp/tmpf5i54yvl.pyomo.soln (default strategy 1)\nseconds was changed from 1e+100 to 3600\nallowableGap was changed from 1e-10 to 3500\nOption for printingOptions changed from normal to all\nPresolve 53080 (-28899) rows, 22855 (-73242) columns and 199897 (-492588) elements\nStatistics for presolved model\nOriginal problem has 95524 integers (94640 of which binary)\nPresolved problem has 22765 integers (22453 of which binary)\n==== 19020 zero objective 4 different\n19020 variables have objective of 0\n208 variables have objective of 20\n1271 variables have objective of 100\n2356 variables have objective of 1000\n==== absolute objective values 4 different\n19020 variables have objective of 0\n208 variables have objective of 20\n1271 variables have objective of 100\n2356 variables have objective of 1000\n==== for integers 19020 zero objective 4 different\n19020 variables have objective of 0\n208 variables have objective of 20\n1271 variables have objective of 100\n2266 variables have objective of 1000\n==== for integers absolute objective values 4 different\n19020 variables have objective of 0\n208 variables have objective of 20\n1271 variables have objective of 100\n2266 variables have objective of 1000\n===== end objective counts\n\n\nProblem has 53080 rows, 22855 columns (3835 with objective) and 199897 elements\nThere are 1569 singletons with objective 852 singletons with no objective \nColumn breakdown:\n402 of type 0.0->inf, 0 of type 0.0->up, 0 of type lo->inf, \n0 of type lo->up, 0 of type free, 0 of type fixed, \n0 of type -inf->0.0, 0 of type -inf->up, 22453 of type 0.0->1.0 \nRow breakdown:\n2124 of type E 0.0, 1528 of type E 1.0, 0 of type E -1.0, \n799 of type E other, 0 of type G 0.0, 52 of type G 1.0, \n334 of type G other, 1271 of type L 0.0, 45119 of type L 1.0, \n1853 of type L other, 0 of type Range 0.0->1.0, 0 of type Range other, \n0 of type Free \nContinuous objective value is 7026.09 - 11.42 seconds\nCgl0002I 67382 variables fixed\nCgl0003I 110 fixed, 208 tightened bounds, 41717 strengthened rows, 45229 substitutions\nCgl0003I 0 fixed, 0 tightened bounds, 1344 strengthened rows, 8755 substitutions\nCgl0003I 488 fixed, 0 tightened bounds, 3602 strengthened rows, 26 substitutions\nCgl0003I 0 fixed, 0 tightened bounds, 150 strengthened rows, 0 substitutions\nCgl0003I 0 fixed, 0 tightened bounds, 268 strengthened rows, 0 substitutions\nCgl0003I 0 fixed, 0 tightened bounds, 167 strengthened rows, 0 substitutions\nCgl0003I 0 fixed, 0 tightened bounds, 167 strengthened rows, 0 substitutions\nCgl0003I 0 fixed, 0 tightened bounds, 166 strengthened rows, 0 substitutions\nCgl0003I 0 fixed, 0 tightened bounds, 165 strengthened rows, 0 substitutions\nCgl0003I 0 fixed, 0 tightened bounds, 162 strengthened rows, 0 substitutions\nCgl0003I 0 fixed, 0 tightened bounds, 162 strengthened rows, 0 substitutions\nCgl0004I processed model has 13820 rows, 13726 columns (13636 integer (13428 of which binary)) and 85182 elements\nCbc0038I Initial state - 928 integers unsatisfied sum - 260.353\nCbc0038I Pass 1: (22.71 seconds) suminf. 130.17048 (361) obj. 54418.3 iterations 3281\nCbc0038I Pass 2: (22.78 seconds) suminf. 114.65515 (321) obj. 61548.2 iterations 714\nCbc0038I Pass 3: (22.82 seconds) suminf. 111.57450 (319) obj. 63556.3 iterations 146\nCbc0038I Pass 4: (22.85 seconds) suminf. 110.79486 (316) obj. 63527.3 iterations 76\nCbc0038I Pass 5: (22.87 seconds) suminf. 110.29486 (315) obj. 63577.3 iterations 4\nCbc0038I Pass 6: (22.90 seconds) suminf. 102.79486 (300) obj. 64327.3 iterations 21\nCbc0038I Pass 7: (22.92 seconds) suminf. 93.79486 (282) obj. 65227.3 iterations 24\nCbc0038I Pass 8: (22.95 seconds) suminf. 88.29486 (271) obj. 65777.3 iterations 11\nCbc0038I Pass 9: (22.97 seconds) suminf. 81.79486 (258) obj. 66427.3 iterations 18\nCbc0038I Pass 10: (23.00 seconds) suminf. 75.79486 (246) obj. 67027.3 iterations 19\nCbc0038I Pass 11: (23.03 seconds) suminf. 65.79486 (226) obj. 68027.3 iterations 38\nCbc0038I Pass 12: (23.05 seconds) suminf. 54.48204 (201) obj. 69116.3 iterations 125\nCbc0038I Pass 13: (23.08 seconds) suminf. 42.98204 (178) obj. 70266.3 iterations 29\nCbc0038I Pass 14: (23.15 seconds) suminf. 26.99681 (126) obj. 71658.8 iterations 545\nCbc0038I Pass 15: (23.18 seconds) suminf. 23.15673 (110) obj. 74088.5 iterations 62\nCbc0038I Pass 16: (23.23 seconds) suminf. 12.43064 (83) obj. 76945.6 iterations 459\nCbc0038I Pass 17: (23.27 seconds) suminf. 11.05741 (71) obj. 76158.1 iterations 220\nCbc0038I Pass 18: (23.31 seconds) suminf. 7.01292 (50) obj. 78595.2 iterations 378\nCbc0038I Pass 19: (23.34 seconds) suminf. 6.86964 (57) obj. 78751.1 iterations 89\nCbc0038I Pass 20: (23.37 seconds) suminf. 5.08719 (42) obj. 81358.4 iterations 288\nCbc0038I Pass 21: (23.40 seconds) suminf. 5.08719 (42) obj. 81358.4 iterations 4\nCbc0038I Pass 22: (23.43 seconds) suminf. 4.53125 (37) obj. 83406.5 iterations 160\nCbc0038I Pass 23: (23.46 seconds) suminf. 4.41533 (38) obj. 82267 iterations 71\nCbc0038I Pass 24: (23.50 seconds) suminf. 5.00933 (32) obj. 76370.5 iterations 406\nCbc0038I Pass 25: (23.53 seconds) suminf. 5.00933 (32) obj. 76370.5 iterations 90\nCbc0038I Pass 26: (23.58 seconds) suminf. 3.12866 (19) obj. 81141.9 iterations 521\nCbc0038I Pass 27: (23.60 seconds) suminf. 3.12866 (19) obj. 81141.9 iterations 2\nCbc0038I Pass 28: (23.65 seconds) suminf. 3.96820 (13) obj. 75644.8 iterations 302\nCbc0038I Pass 29: (23.68 seconds) suminf. 3.96820 (13) obj. 75644.8 iterations 7\nCbc0038I Pass 30: (23.71 seconds) suminf. 2.05382 (6) obj. 77470.6 iterations 129\nCbc0038I No solution found this major pass\nCbc0038I Before mini branch and bound, 12420 integers at bound fixed and 21 continuous\nCbc0038I Full problem 13820 rows 13726 columns, reduced to 770 rows 705 columns\nCbc0038I Mini branch and bound did not improve solution (24.79 seconds)\nCbc0038I After 24.79 seconds - Feasibility pump exiting - took 2.76 seconds\nCbc0031I 175 added rows had average density of 83.977143\nCbc0013I At root node, 175 cuts changed objective from 16776.086 to 28416.154 in 10 passes\nCbc0014I Cut generator 0 (Probing) - 1123 row cuts average 2.0 elements, 0 column cuts (37 active) in 4.086 seconds - new frequency is 1\nCbc0014I Cut generator 1 (Gomory) - 534 row cuts average 247.5 elements, 0 column cuts (0 active) in 2.320 seconds - new frequency is 1\nCbc0014I Cut generator 2 (Knapsack) - 606 row cuts average 2.2 elements, 0 column cuts (0 active) in 0.113 seconds - new frequency is 1\nCbc0014I Cut generator 3 (Clique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.041 seconds - new frequency is -100\nCbc0014I Cut generator 4 (MixedIntegerRounding2) - 906 row cuts average 43.6 elements, 0 column cuts (0 active) in 0.246 seconds - new frequency is 1\nCbc0014I Cut generator 5 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.050 seconds - new frequency is -100\nCbc0014I Cut generator 6 (TwoMirCuts) - 1048 row cuts average 73.2 elements, 0 column cuts (0 active) in 1.688 seconds - new frequency is 1\nCbc0010I After 0 nodes, 1 on tree, 1e+50 best solution, best possible 28416.154 (45.59 seconds)\nCbc0012I Integer solution of 37000.826 found by DiveCoefficient after 18584 iterations and 6 nodes (60.40 seconds)\nCbc0038I Full problem 13820 rows 13726 columns, reduced to 158 rows 189 columns\nCbc0012I Integer solution of 34382.245 found by RINS after 18584 iterations and 6 nodes (61.78 seconds)\nCbc0038I Full problem 13820 rows 13726 columns, reduced to 147 rows 212 columns\nCbc0012I Integer solution of 30728.276 found by RINS after 24677 iterations and 41 nodes (80.09 seconds)\nCbc0011I Exiting as integer gap of 2312.1218 less than 3500 or 0%%\nCbc0001I Search completed - best objective 30728.27563158896, took 24697 iterations and 42 nodes (80.23 seconds)\nCbc0032I Strong branching done 938 times (36727 iterations), fathomed 0 nodes and fixed 0 variables\nCbc0035I Maximum depth 22, 0 variables fixed on reduced cost\nCuts at root node changed objective from 16776.1 to 28416.2\nProbing was tried 57 times and created 2617 cuts of which 37 were active after adding rounds of cuts (4.375 seconds)\nGomory was tried 57 times and created 706 cuts of which 0 were active after adding rounds of cuts (3.023 seconds)\nKnapsack was tried 57 times and created 1360 cuts of which 0 were active after adding rounds of cuts (0.537 seconds)\nClique was tried 10 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.041 seconds)\nMixedIntegerRounding2 was tried 57 times and created 2057 cuts of which 0 were active after adding rounds of cuts (0.914 seconds)\nFlowCover was tried 10 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.050 seconds)\nTwoMirCuts was tried 57 times and created 1692 cuts of which 0 were active after adding rounds of cuts (2.318 seconds)\nImplicationCuts was tried 14 times and created 1011 cuts of which 0 were active after adding rounds of cuts (0.031 seconds)\n\nResult - Optimal solution found (within gap tolerance)\n\nObjective value: 30728.27563159\nLower bound: 28416.154\nGap: 0.08\nEnumerated nodes: 42\nTotal iterations: 24697\nTime (CPU seconds): 81.01\nTime (Wallclock seconds): 81.36\n\nTotal time (CPU seconds): 82.74 (Wallclock seconds): 83.24\n\n"
|
|
}
|
|
],
|
|
"source": [
|
|
"opt = SolverFactory('cbc') # choose a solver\n",
|
|
"#opt = SolverFactory('ipopt') # choose a solver\n",
|
|
"\n",
|
|
"results = opt.solve(Rota.model, tee=True, options={\"seconds\":3600, \"allow\": 3500}) # solve the model with the, options=\"seconds=60\" selected solver"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "execute_result",
|
|
"data": {
|
|
"text/plain": "EnumValue(<pyutilib.enum.enum.Enum object at 0x7fbee280c310>, 0, 'ok')"
|
|
},
|
|
"metadata": {},
|
|
"execution_count": 7
|
|
}
|
|
],
|
|
"source": [
|
|
"results.solver.status\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from shifts import RotaResults\n",
|
|
"\n",
|
|
"ResultsHolder = RotaResults(Rota, results)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"metadata": {
|
|
"tags": [
|
|
"outputPrepend",
|
|
"outputPrepend"
|
|
]
|
|
},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": "exeter 1 weekend 1.0 0.0 0.0\nexeter 2 weekend 1.0 0.0 0.0\nexeter 3 weekend 0.0 0.0 1.0\nexeter 4 weekend 1.0 0.0 0.0\nexeter 5 weekend 0.0 0.0 1.0\nexeter 6 weekend 1.0 0.0 0.0\nexeter 7 weekend 1.0 0.0 0.0\nexeter 8 weekend 0.0 0.0 1.0\nexeter 9 weekend 1.0 0.0 0.0\nexeter 10 weekend 1.0 0.0 0.0\nexeter 11 weekend 1.0 0.0 0.0\nexeter 12 weekend 0.0 0.0 1.0\nexeter 13 weekend 1.0 0.0 0.0\nexeter 14 weekend 1.0 0.0 0.0\nexeter 15 weekend 1.0 0.0 0.0\nexeter 16 weekend 0.0 0.0 1.0\nexeter 17 weekend 1.0 0.0 0.0\nexeter 18 weekend 1.0 0.0 0.0\nexeter 19 weekend 1.0 0.0 0.0\nexeter 20 weekend 1.0 0.0 0.0\nexeter 21 weekend 1.0 0.0 0.0\nexeter 22 weekend 1.0 0.0 0.0\nexeter 23 weekend 1.0 0.0 0.0\nexeter 24 weekend 0.0 0.0 1.0\nexeter 25 weekend 1.0 0.0 0.0\nexeter 26 weekend 1.0 0.0 0.0\nexeter 1 weekday 0.0 0.0 1.0\nexeter 2 weekday 0.0 0.0 1.0\nexeter 3 weekday 0.0 0.0 1.0\nexeter 4 weekday 1.0 0.0 0.0\nexeter 5 weekday 1.0 0.0 0.0\nexeter 6 weekday 1.0 0.0 0.0\nexeter 7 weekday 0.0 0.0 1.0\nexeter 8 weekday 1.0 0.0 0.0\nexeter 9 weekday 1.0 0.0 0.0\nexeter 10 weekday 1.0 0.0 0.0\nexeter 11 weekday 1.0 0.0 0.0\nexeter 12 weekday 1.0 0.0 0.0\nexeter 13 weekday 1.0 0.0 0.0\nexeter 14 weekday 1.0 0.0 0.0\nexeter 15 weekday 0.0 0.0 1.0\nexeter 16 weekday 1.0 0.0 0.0\nexeter 17 weekday 0.0 0.0 1.0\nexeter 18 weekday 0.0 0.0 1.0\nexeter 19 weekday 0.0 0.0 1.0\nexeter 20 weekday 0.0 0.0 1.0\nexeter 21 weekday 1.0 0.0 0.0\nexeter 22 weekday 0.0 0.0 1.0\nexeter 23 weekday 0.0 0.0 1.0\nexeter 24 weekday 1.0 0.0 0.0\nexeter 25 weekday 0.0 0.0 1.0\nexeter 26 weekday 1.0 0.0 0.0\ntruro 1 weekend 0.0 0.0 1.0\ntruro 2 weekend 0.0 0.0 1.0\ntruro 3 weekend 1.0 0.0 0.0\ntruro 4 weekend 1.0 0.0 0.0\ntruro 5 weekend 1.0 0.0 0.0\ntruro 6 weekend 1.0 0.0 0.0\ntruro 7 weekend 1.0 0.0 0.0\ntruro 8 weekend 1.0 0.0 0.0\ntruro 9 weekend 1.0 0.0 0.0\ntruro 10 weekend 0.0 0.0 1.0\ntruro 11 weekend 0.0 0.0 1.0\ntruro 12 weekend 1.0 0.0 0.0\ntruro 13 weekend 0.0 0.0 1.0\ntruro 14 weekend 0.0 0.0 1.0\ntruro 15 weekend 0.0 0.0 1.0\ntruro 16 weekend 1.0 0.0 0.0\ntruro 17 weekend 1.0 0.0 0.0\ntruro 18 weekend 0.0 0.0 1.0\ntruro 19 weekend 1.0 0.0 0.0\ntruro 20 weekend 0.0 0.0 1.0\ntruro 21 weekend 0.0 0.0 1.0\ntruro 22 weekend 1.0 0.0 0.0\ntruro 23 weekend 1.0 0.0 0.0\ntruro 24 weekend 1.0 0.0 0.0\ntruro 25 weekend 0.0 0.0 1.0\ntruro 26 weekend 1.0 0.0 0.0\ntruro 1 weekday 1.0 0.0 0.0\ntruro 2 weekday 1.0 0.0 0.0\ntruro 3 weekday 1.0 0.0 0.0\ntruro 4 weekday 0.0 0.0 1.0\ntruro 5 weekday 1.0 0.0 0.0\ntruro 6 weekday 0.0 0.0 1.0\ntruro 7 weekday 1.0 0.0 0.0\ntruro 8 weekday 1.0 0.0 0.0\ntruro 9 weekday 0.0 0.0 1.0\ntruro 10 weekday 1.0 0.0 0.0\ntruro 11 weekday 0.0 0.0 1.0\ntruro 12 weekday 1.0 0.0 0.0\ntruro 13 weekday 1.0 0.0 0.0\ntruro 14 weekday 0.0 0.0 1.0\ntruro 15 weekday 1.0 0.0 0.0\ntruro 16 weekday 0.0 0.0 1.0\ntruro 17 weekday 1.0 0.0 0.0\ntruro 18 weekday 1.0 0.0 0.0\ntruro 19 weekday 1.0 0.0 0.0\ntruro 20 weekday 1.0 0.0 0.0\ntruro 21 weekday 1.0 0.0 0.0\ntruro 22 weekday 1.0 0.0 0.0\ntruro 23 weekday 1.0 0.0 0.0\ntruro 24 weekday 1.0 0.0 0.0\ntruro 25 weekday 1.0 0.0 0.0\ntruro 26 weekday 1.0 0.0 0.0\nplymouth 1 weekend 1.0 0.0 0.0\nplymouth 2 weekend 1.0 0.0 0.0\nplymouth 3 weekend 1.0 0.0 0.0\nplymouth 4 weekend 1.0 0.0 0.0\nplymouth 5 weekend 1.0 0.0 0.0\nplymouth 6 weekend 1.0 0.0 0.0\nplymouth 7 weekend 1.0 0.0 0.0\nplymouth 8 weekend 1.0 0.0 0.0\nplymouth 9 weekend 1.0 0.0 0.0\nplymouth 10 weekend 1.0 0.0 0.0\nplymouth 11 weekend 1.0 0.0 0.0\nplymouth 12 weekend 1.0 0.0 0.0\nplymouth 13 weekend 1.0 0.0 0.0\nplymouth 14 weekend 1.0 0.0 0.0\nplymouth 15 weekend 1.0 0.0 0.0\nplymouth 16 weekend 1.0 0.0 0.0\nplymouth 17 weekend 1.0 0.0 0.0\nplymouth 18 weekend 1.0 0.0 0.0\nplymouth 19 weekend 1.0 0.0 0.0\nplymouth 20 weekend 1.0 0.0 0.0\nplymouth 21 weekend 1.0 0.0 0.0\nplymouth 22 weekend 0.0 0.0 1.0\nplymouth 23 weekend 1.0 0.0 0.0\nplymouth 24 weekend 1.0 0.0 0.0\nplymouth 25 weekend 1.0 0.0 0.0\nplymouth 26 weekend 1.0 0.0 0.0\nplymouth 1 weekday 1.0 0.0 0.0\nplymouth 2 weekday 1.0 0.0 0.0\nplymouth 3 weekday 1.0 0.0 0.0\nplymouth 4 weekday 1.0 0.0 0.0\nplymouth 5 weekday 1.0 0.0 0.0\nplymouth 6 weekday 1.0 0.0 0.0\nplymouth 7 weekday 1.0 0.0 0.0\nplymouth 8 weekday 1.0 0.0 0.0\nplymouth 9 weekday 1.0 0.0 0.0\nplymouth 10 weekday 1.0 0.0 0.0\nplymouth 11 weekday 1.0 0.0 0.0\nplymouth 12 weekday 0.0 0.0 1.0\nplymouth 13 weekday 0.0 0.0 1.0\nplymouth 14 weekday 1.0 0.0 0.0\nplymouth 15 weekday 1.0 0.0 0.0\nplymouth 16 weekday 1.0 0.0 0.0\nplymouth 17 weekday 1.0 0.0 0.0\nplymouth 18 weekday 1.0 0.0 0.0\nplymouth 19 weekday 1.0 0.0 0.0\nplymouth 20 weekday 1.0 0.0 0.0\nplymouth 21 weekday 1.0 0.0 0.0\nplymouth 22 weekday 1.0 0.0 0.0\nplymouth 23 weekday 1.0 0.0 0.0\nplymouth 24 weekday 1.0 0.0 0.0\nplymouth 25 weekday 1.0 0.0 0.0\nplymouth 26 weekday 1.0 0.0 0.0\nbarnstaple 1 weekend 0.0 0.0 1.0\nbarnstaple 2 weekend 0.0 0.0 1.0\nbarnstaple 3 weekend 0.0 0.0 1.0\nbarnstaple 4 weekend 0.0 0.0 1.0\nbarnstaple 5 weekend 0.0 0.0 1.0\nbarnstaple 6 weekend 0.0 0.0 1.0\nbarnstaple 7 weekend 0.0 0.0 1.0\nbarnstaple 8 weekend 0.0 0.0 1.0\nbarnstaple 9 weekend 0.0 0.0 1.0\nbarnstaple 10 weekend 0.0 0.0 1.0\nbarnstaple 11 weekend 0.0 0.0 1.0\nbarnstaple 12 weekend 0.0 0.0 1.0\nbarnstaple 13 weekend 0.0 0.0 1.0\nbarnstaple 14 weekend 0.0 0.0 1.0\nbarnstaple 15 weekend 0.0 0.0 1.0\nbarnstaple 16 weekend 0.0 0.0 1.0\nbarnstaple 17 weekend 0.0 0.0 1.0\nbarnstaple 18 weekend 0.0 0.0 1.0\nbarnstaple 19 weekend 0.0 0.0 1.0\nbarnstaple 20 weekend 0.0 0.0 1.0\nbarnstaple 21 weekend 0.0 0.0 1.0\nbarnstaple 22 weekend 0.0 0.0 1.0\nbarnstaple 23 weekend 0.0 0.0 1.0\nbarnstaple 24 weekend 0.0 0.0 1.0\nbarnstaple 25 weekend 0.0 0.0 1.0\nbarnstaple 26 weekend 0.0 0.0 1.0\nbarnstaple 1 weekday 0.0 0.0 1.0\nbarnstaple 2 weekday 0.0 0.0 1.0\nbarnstaple 3 weekday 0.0 0.0 1.0\nbarnstaple 4 weekday 0.0 0.0 1.0\nbarnstaple 5 weekday 0.0 0.0 1.0\nbarnstaple 6 weekday 0.0 0.0 1.0\nbarnstaple 7 weekday 0.0 0.0 1.0\nbarnstaple 8 weekday 0.0 0.0 1.0\nbarnstaple 9 weekday 0.0 0.0 1.0\nbarnstaple 10 weekday 0.0 0.0 1.0\nbarnstaple 11 weekday 0.0 0.0 1.0\nbarnstaple 12 weekday 0.0 0.0 1.0\nbarnstaple 13 weekday 0.0 0.0 1.0\nbarnstaple 14 weekday 0.0 0.0 1.0\nbarnstaple 15 weekday 0.0 0.0 1.0\nbarnstaple 16 weekday 0.0 0.0 1.0\nbarnstaple 17 weekday 0.0 0.0 1.0\nbarnstaple 18 weekday 0.0 0.0 1.0\nbarnstaple 19 weekday 0.0 0.0 1.0\nbarnstaple 20 weekday 0.0 0.0 1.0\nbarnstaple 21 weekday 0.0 0.0 1.0\nbarnstaple 22 weekday 0.0 0.0 1.0\nbarnstaple 23 weekday 0.0 0.0 1.0\nbarnstaple 24 weekday 0.0 0.0 1.0\nbarnstaple 25 weekday 0.0 0.0 1.0\nbarnstaple 26 weekday 0.0 0.0 1.0\ntorquay 1 weekend 1.0 0.0 0.0\ntorquay 2 weekend 1.0 0.0 0.0\ntorquay 3 weekend 1.0 0.0 0.0\ntorquay 4 weekend 0.0 0.0 1.0\ntorquay 5 weekend 1.0 0.0 0.0\ntorquay 6 weekend 0.0 0.0 1.0\ntorquay 7 weekend 0.0 0.0 1.0\ntorquay 8 weekend 1.0 0.0 0.0\ntorquay 9 weekend 0.0 0.0 1.0\ntorquay 10 weekend 1.0 0.0 0.0\ntorquay 11 weekend 1.0 0.0 0.0\ntorquay 12 weekend 1.0 0.0 0.0\ntorquay 13 weekend 1.0 0.0 0.0\ntorquay 14 weekend 1.0 0.0 0.0\ntorquay 15 weekend 1.0 0.0 0.0\ntorquay 16 weekend 1.0 0.0 0.0\ntorquay 17 weekend 0.0 0.0 1.0\ntorquay 18 weekend 1.0 0.0 0.0\ntorquay 19 weekend 0.0 0.0 1.0\ntorquay 20 weekend 1.0 0.0 0.0\ntorquay 21 weekend 1.0 0.0 0.0\ntorquay 22 weekend 1.0 0.0 0.0\ntorquay 23 weekend 0.0 0.0 1.0\ntorquay 24 weekend 1.0 0.0 0.0\ntorquay 25 weekend 1.0 0.0 0.0\ntorquay 26 weekend 0.0 0.0 1.0\ntorquay 1 weekday 1.0 0.0 0.0\ntorquay 2 weekday 1.0 0.0 0.0\ntorquay 3 weekday 1.0 0.0 0.0\ntorquay 4 weekday 1.0 0.0 0.0\ntorquay 5 weekday 0.0 0.0 1.0\ntorquay 6 weekday 1.0 0.0 0.0\ntorquay 7 weekday 1.0 0.0 0.0\ntorquay 8 weekday0.0 0.0 1.0\ntorquay 9 weekday 1.0 0.0 0.0\ntorquay 10 weekday 0.0 0.0 1.0\ntorquay 11 weekday 1.0 0.0 0.0\ntorquay 12 weekday 1.0 0.0 0.0\ntorquay 13 weekday 1.0 0.0 0.0\ntorquay 14 weekday 1.0 0.0 0.0\ntorquay 15 weekday 1.0 0.0 0.0\ntorquay 16 weekday 1.0 0.0 0.0\ntorquay 17 weekday 1.0 0.0 0.0\ntorquay 18 weekday 1.0 0.0 0.0\ntorquay 19 weekday 1.0 0.0 0.0\ntorquay 20 weekday 1.0 0.0 0.0\ntorquay 21 weekday 0.0 0.0 1.0\ntorquay 22 weekday 1.0 0.0 0.0\ntorquay 23 weekday 1.0 0.0 0.0\ntorquay 24 weekday 0.0 0.0 1.0\ntorquay 25 weekday 1.0 0.0 0.0\ntorquay 26 weekday 0.0 0.0 1.0\n"
|
|
}
|
|
],
|
|
"source": [
|
|
"#def get_workers_needed(needed):\n",
|
|
"# \"\"\"Extract to a list the needed workers for the optimal solution.\"\"\"\n",
|
|
"# workers_needed = []\n",
|
|
"# for worker in workers:\n",
|
|
"# if needed[worker.id].value == 1:\n",
|
|
"# workers_needed.append(worker.name)\n",
|
|
"# return workers_needed\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"#workers_needed = get_workers_needed(model.needed) # dict with the optimal timetable\n",
|
|
"week_table = ResultsHolder.get_work_table() # list with the required workers\n",
|
|
"worker_timetable = ResultsHolder.get_worker_timetable()\n",
|
|
"worker_timetable_brief = ResultsHolder.get_worker_timetable_brief(show_prefs=False)\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)\n",
|
|
"worker_night_block = ResultsHolder.get_night_blocks()\n",
|
|
"worker_shift_summary = ResultsHolder.get_shift_summary()\n",
|
|
"multi = ResultsHolder.get_multinight()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"\n",
|
|
"\n",
|
|
"ResultsHolder.export_rota_to_csv()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": "-Day- MTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSS\n-Week- 11111112222222333333344444445555555666666677777778888888999999900000001111111222222233333334444444555555566666667777777888888899999990000000111111122222223333333444444455555556666666\nAlex Wood --e----------------------------------------ee-----------ee--nnn--e-----------------------------nnn-----ww---e---e---nnn-----w----------e----e---ewwe-------ee--ww-e-------e-----e--nnn weekend_exeter: 7,night: 12,exeter_twilight: 17,\nMichal Tomek -----ww----nnn--e-------------e-----------e---ewwe--e--------ww----nnn-------nnnn----e-------------------eee-e------------e---------------ww----nnn------------------e--e---------e--- weekend_exeter: 8,night: 13,exeter_twilight: 15,\nWijhdan Abusrewil e---nnn--------------nnnn------e--------ww---------e--------------e-------nnn---------e----e-e--ww---------------e--e--ee---------eww-------nnnn-------e-----ee-----e----------------- weekend_exeter: 6,night: 14,exeter_twilight: 16,\nMadalina Drumea ---------------------e---nnn-----ww--e-e------nnn----e-----ee------e----e-e-------ww----nnn---e-------nnn---------------------e-------e-e--------------nnn---------e---------wwe------ weekend_exeter: 6,night: 15,exeter_twilight: 15,\nSalma Aslam -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- \nSayed Alqarooni -e--------ee------e-------ww-e------e-e-----------e---ww-------nnnn--------wwe---------e---nnnn------e---------------------nnn--e--------------e-----------------e----------nnn--e-e-- weekend_exeter: 6,night: 14,exeter_twilight: 16,\nDelilah Trimmer -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- \nRebecca Murphy -------e------e-------e-e---nnnn--------------------------e----e-------e-e-----e--------e---e-----e------nnnn------------e-e-w-e-----e---nnn------------------nnn-----ww----e-------ww weekend_exeter: 5,night: 14,exeter_twilight: 17,\nTom Welsh ----e---e-----------------------e--nnnn-------------------------e---wwe-------------e----ww-----------------------ee-ww-----------nnn----e---ee-----eee----------nnnn----e-----nnnn--- weekend_exeter: 6,night: 15,exeter_twilight: 15,\nJin Virdi ---e-----e---------ww--e-e--e------e---------e----------nnnn------------------------nnnn-------e---ee---------ww---------------------------------------------------------------------- weekend_exeter: 4,night: 8,exeter_twilight: 10,\nTania King Mohammed ------------ww-e-e---------------------nnn-------nnnn-----------------nnnn----e-ee--------------------e--------------------------e----------------------wwe----------------e---------- weekend_exeter: 4,night: 11,exeter_twilight: 9,\nTom Davies -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- \nAlexander Sanchez ------------ww--p--------p--------------------p-----p----p-----p-----------ww-----ww-----------p------nnn-----w-------------ww----nnn--------------nnnn---p-------p-p---nnnn---------- weekend_plymouth: 9,night: 14,plymouth_twilight: 10,\nHannah Lewis ----p-------wwp-------------nnnn----p-ppww-------nnnn---p--p----p-----nnnn-------------------p-----p----------ww-----------------------------p---------------p-ww--------------------- weekend_plymouth: 8,night: 12,plymouth_twilight: 12,\nSeren Peters ---p-ww------------------------p-ww---------pp-------nnn-------------------------nnn-------nnnn-----------pp---w----------------p-----p-p--------------pww-------nnnn--------ww------- weekend_plymouth: 9,night: 14,plymouth_twilight: 10,\nAdeola Omotade -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- \nAmina Odeh ---------p----nnnn--------ww--p----nnnn--------ww----------------------p----------------p-------ww---p---p-------p--nnn------------------nnn-----ww--p--------p----p--------------p--- weekend_plymouth: 8,night: 14,plymouth_twilight: 11,\nGeorge Edwards --------------------------ww------w--------p-----pp-----nnnn--------------------ppww-----ww-------p------nnnn-----p----p-------------nnnn----------p-----------------nnn--p-----p----- weekend_plymouth: 7,night: 15,plymouth_twilight: 11,\nJean Sukumar -----ww---p--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- weekend_plymouth: 2,plymouth_twilight: 1,\n-Week- 11111112222222333333344444445555555666666677777778888888999999900000001111111222222233333334444444555555566666667777777888888899999990000000111111122222223333333444444455555556666666\n-Day- MTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSS\nJenn Fong -p-----nnnn-------p----------------------------ww-----ww----------------------------p-------------nnnn------p--------ww----p--pp--pww-----------nnn-----------nnn-------p---p--p------ weekend_plymouth: 8,night: 14,plymouth_twilight: 11,\nSafi Rahman -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- \nKhalil Madbak ---------------p---------nnn-----------nnn---------p--------nnn----p------nnn------------ww-p---ww--p--ww------------ww------------------------ppw----p--------------p-------------nnn weekend_plymouth: 9,night: 15,plymouth_twilight: 9,\nNatasha Hougham ----nnn------------------------------------------------------ww---------pp--------------------p------------------------nnnn----------p----ww---------------pp-----------------------ww plymouth_twilight: 6,night: 7,weekend_plymouth: 6,\nRichard Chaytor p-------p--p----------------pp-----p------------------ww-----------nnn-----ww--------------------------------p--nnnn----------nnnn------------p-----------nnnn--------ww-p-p--------ww weekend_plymouth: 8,night: 15,plymouth_twilight: 10,\nS Ghauri --p---------------------p-------nnn-------------------------------p-ww------------------nnn------------ww------------------nnn--------------------w-p----------------------------p---- weekend_plymouth: 5,night: 9,plymouth_twilight: 5,\nSophie McGlade -----------------p-ww-p--------------p--------nnn-----------p----p--wwp---p--------------------nnn------------------p----p--ww---------p----nnnn--------ww-------p----------nnn----p-- weekend_plymouth: 8,night: 13,plymouth_twilight: 12,\nHuub Witt -------p---nnn-------nnnn--------w--------nnnn-------p----p----nnnn------------------ppp---p--------------------p---------p------p--------wwp-------------------------ww-----ww------- weekend_plymouth: 7,night: 15,plymouth_twilight: 11,\nJon Stokes -------------------wwp---------------------------------------------------------------------------------------------------------------------------------------------------------------- weekend_plymouth: 2,plymouth_twilight: 1,\nKaris McFeely nnnn--------------nnn--p--------p-------wwp------------------ww--------------ppp----------------------p------nnn---p----p----------ww----p---------------------ww--------------nnnn--- weekend_plymouth: 8,night: 14,plymouth_twilight: 10,\nMirna Long -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- \nChristian Greer -------nnnn----------t------------------------t-----------------------------------------------t-ww-----ww-t-----nnnn-----------t----------wwttt----t------nnnn----t--t------t---t----w torquay_twilight: 13,night: 12,weekend_torquay: 7,\nMax Ireland ---------ttt--t---t----------------nnnn-----------------nnnn------------------------nnnn----t------------t---tww-----------------t---t----------t---t---ww------------ww--t---------w- weekend_torquay: 7,torquay_twilight: 13,night: 12,\nAlan Eccles -----ww----------------t------------------nnnn-----t------t------------------------------wwt-t---------------nnn-------nnnn-----t--------------------------t-------tt----t------------ night: 11,torquay_twilight: 10,weekend_torquay: 4,\nCharles Finan tt-----------------ww-t---------tww-t--t-------------nnn----t---------nnnn------------------------tt---------------t----------nnnn----t-t----------------------------nnn-----ww------- night: 14,torquay_twilight: 12,weekend_torquay: 6,\nChong Ng ----nnn----------t-------tww--t----t--t--------ww---------------t-tt----t-t----t--------nnn----------t------t--------------nnn---------------------nnnn-------t-------------------t--- torquay_twilight: 15,night: 13,weekend_torquay: 4,\nMatthew Thorley nnnn--------------nnn-------t---------------t---------wwt------------------wwt---t----t--------nnn----t----------t------t--t-------------nnn----------t-----t-----------t------t------ torquay_twilight: 14,night: 13,weekend_torquay: 4,\nMo Babsail ---t--------------------t----t----------ww-----------------t-ww----nnn---t-------nnn---t------------t----nnnn-------t----t--------t----t---------ww----nnn-----------------------t-t-- night: 13,torquay_twilight: 13,weekend_torquay: 6,\nNeil McIntyre --------t---ww-------nnnn------t----------tt-t-----------------t----wwt---nnn---t----t----------------nnn---------------------t----------t-----------t----t------t------nnnn---------- night: 14,torquay_twilight: 14,weekend_torquay: 4,\n-Week- 11111112222222333333344444445555555666666677777778888888999999900000001111111222222233333334444444555555566666667777777888888899999990000000111111122222223333333444444455555556666666\n-Day- MTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSSMTWTFSS\nPaul Jenkins ---------------t----------------nnn--t------------t--------------t-----t-----nnnn--------------t--nnnn----------t----wwt--t--------ww-----------nnn----t-----t-ww----------t---------- weekend_torquay: 6,torquay_twilight: 12,night: 14,\nGana Kugathasan -----------nnn--t--------------------------------------------------------------------------------------------------------------------------------------------------------------------- torquay_twilight: 1,night: 3,\nHarriet Conley -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- \nJon Skinner --t-t--t------nnnn-------------------------------t--tt---t--------------------t---wwt---t--nnnn------------t------t---------ww-------nnnn------t----------------------------nnn------- weekend_torquay: 4,torquay_twilight: 13,night: 15,\nNicolas Dziad nnnn-------t------nnn---t-ww-----------------------t-----------nnnn-----------------t-------------nnnn------------------t-t---------------ww---t-----ttt--t----ww-----------------tt-- weekend_truro: 6,truro_twilight: 13,night: 15,\nVilim Kalamar t--t------t-----------------ttt--ww-----wwt--t--------------------t---------------ww----------------------t--nnn--t----nnnn----------nnnn----------t----------nnn--------t------------ weekend_truro: 6,truro_twilight: 13,night: 14,\nAmoolya Mannava ------------wwtt----------------t---t------------nnnn------t-------------t------------t----------------ww-------nnnn----------ttt-t----t-t------t---t------------nnnn--------ww------- weekend_truro: 6,truro_twilight: 15,night: 12,\nChi Leung --------------nnnn----t---------------------------t--t------nnn--t-----------nnnn-------------t---t--------t----tt-------t------------------nnnn--------ww-tt-----t---ww---------t---- weekend_truro: 4,truro_twilight: 14,night: 15,\nJenna Millington --------------------------------nnn---------t-t-------------------------t-t---ttt---nnnn-------------------------------------------ww-------------------------------------t--------nnn weekend_truro: 2,truro_twilight: 8,night: 10,\nPaul Ward -t------t----------------nnn--------------nnnn-------------------------------t---------tt---t-------tt---t--ttww-----ww-----ww----nnn------------------------t------t---nnnn---------- weekend_truro: 6,truro_twilight: 13,night: 14,\nSarath Vennam ----------------t-twwt------nnnn-----t---------ww---------------------t-------------------wt---t------t------------t-------t-----t---t--t----tt-----------nnnn-----t-----------nnnn--- weekend_truro: 5,truro_twilight: 16,night: 12,\nRoss Kruger --t----nnnn------------t-t---------t-------t-----t---nnn--------t--t-------ww-------------------ww-t-------------------t--------------t------------nnnn--------------nnn---tt---t---ww weekend_truro: 6,truro_twilight: 14,night: 14,\nJack Looker -----wwt---------t--------------------tt------nnn---t-wwtt-----t----ww-t---------nnn---------t----------------------nnn--------------------------------nnn----t--t---t--t------t------ weekend_truro: 6,truro_twilight: 15,night: 12,\nPete Abernethy ----t----t---------------------t-------nnn----------------t-tww------------------t---t---w--------------------------t---------nnnn----------t----ww----------------------------------- weekend_truro: 5,truro_twilight: 9,night: 7,\n-Week- 11111112222222333333344444445555555666666677777778888888999999900000001111111222222233333334444444555555566666667777777888888899999990000000111111122222223333333444444455555556666666\n"
|
|
}
|
|
],
|
|
"source": [
|
|
"\n",
|
|
"print(worker_timetable_brief)\n",
|
|
""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": "7 e 2 [36]: exeter_twilight (17), weekend_exeter (7), night (12)\n6 e 2 [36]: exeter_twilight (15), weekend_exeter (8), night (13)\n1 e 2 [36]: exeter_twilight (16), weekend_exeter (6), night (14)\n18 e 3 [36]: exeter_twilight (15), weekend_exeter (6), night (15)\n11 e 3 [0]: \n19 e 3 [36]: exeter_twilight (16), weekend_exeter (6), night (14)\n28 e 4 [0]: \n27 e 4 [36]: exeter_twilight (17), weekend_exeter (5), night (14)\n26 e 4 [36]: exeter_twilight (15), weekend_exeter (6), night (15)\n43 e 5 [22]: exeter_twilight (10), weekend_exeter (4), night (8)\n42 e 5 [24]: exeter_twilight (9), weekend_exeter (4), night (11)\n41 e 5 [0]: \n8 p 2 [33]: plymouth_twilight (10), weekend_plymouth (9), night (14)\n3 p 2 [32]: plymouth_twilight (12), weekend_plymouth (8), night (12)\n2 p 2 [33]: plymouth_twilight (10), weekend_plymouth (9), night (14)\n12 p 3 [0]: \n13 p 3 [33]: plymouth_twilight (11), weekend_plymouth (8), night (14)\n35 p 3 [33]: plymouth_twilight (11), weekend_plymouth (7), night (15)\n20 p 3 [3]: plymouth_twilight (1), weekend_plymouth (2)\n21 p 3 [33]: plymouth_twilight (11), weekend_plymouth (8), night (14)\n34 p 3 [0]: \n31 p 4 [33]: plymouth_twilight (9), weekend_plymouth (9), night (15)\n32 p 4 [19]: plymouth_twilight (6), weekend_plymouth (6), night (7)\n33 p 4 [33]: plymouth_twilight (10), weekend_plymouth (8), night (15)\n30 p 4 [19]: plymouth_twilight (5), weekend_plymouth (5), night (9)\n29 p 4 [33]: plymouth_twilight (12), weekend_plymouth (8), night (13)\n44 p 5 [33]: plymouth_twilight (11), weekend_plymouth (7), night (15)\n46 p 5 [3]: plymouth_twilight (1), weekend_plymouth (2)\n47 p 5 [32]: plymouth_twilight (10), weekend_plymouth (8), night (14)\n45 p 5 [0]: \n4 t 2 [32]: torquay_twilight (13), weekend_torquay (7), night (12)\n9 t 2 [32]: torquay_twilight (13), weekend_torquay (7), night (12)\n15 t 3 [25]: torquay_twilight (10), weekend_torquay (4), night (11)\n14 t 3 [32]: torquay_twilight (12), weekend_torquay (6), night (14)\n22 t 3 [32]: torquay_twilight (15), weekend_torquay (4), night (13)\n23 t 3 [31]: torquay_twilight (14), weekend_torquay (4), night (13)\n37 t 3 [32]: torquay_twilight (13), weekend_torquay (6), night (13)\n36 t 4 [32]: torquay_twilight (14), weekend_torquay (4), night (14)\n38 t 4 [32]: torquay_twilight (12), weekend_torquay (6), night (14)\n50 t 5 [4]: torquay_twilight (1), night (3)\n48 t 5 [0]: \n49 t 5 [32]: torquay_twilight (13), weekend_torquay (4), night (15)\n5 t 2 [34]: truro_twilight (13), weekend_truro (6), night (15)\n10 t 2 [33]: truro_twilight (13), weekend_truro (6), night (14)\n40 t 3 [33]: truro_twilight (15), weekend_truro (6), night (12)\n25 t 3 [33]: truro_twilight (14), weekend_truro (4), night (15)\n24 t 3 [20]: truro_twilight (8), weekend_truro (2), night (10)\n17 t 3 [33]: truro_twilight (13), weekend_truro (6), night (14)\n16 t 3 [33]: truro_twilight (16), weekend_truro (5), night (12)\n39 t 4 [34]: truro_twilight (14), weekend_truro (6), night (14)\n51 t 5 [33]: truro_twilight (15), weekend_truro (6), night (12)\n52 t 5 [21]: truro_twilight (9), weekend_truro (5), night (7)\n"
|
|
}
|
|
],
|
|
"source": [
|
|
"#workers_needed\n",
|
|
"print(worker_shift_summary)\n",
|
|
""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 13,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": "None\n"
|
|
}
|
|
],
|
|
"source": [
|
|
"print(multi)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 14,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#worker_night_block"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 15,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#[[worker, week, day, shift] for day in days for shift in [\"night\"]]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "execute_result",
|
|
"data": {
|
|
"text/plain": "1"
|
|
},
|
|
"metadata": {},
|
|
"execution_count": 16
|
|
}
|
|
],
|
|
"source": [
|
|
"1 if 4 in [4, 1, 0] else 0"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 17,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "execute_result",
|
|
"data": {
|
|
"text/plain": "0"
|
|
},
|
|
"metadata": {},
|
|
"execution_count": 17
|
|
}
|
|
],
|
|
"source": [
|
|
"(4 + 1) // 7"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 18,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#for worker in workers:\n",
|
|
"# for shift in shifts:\n",
|
|
"# a = [model.works[worker.id, week, day, shift].value for week in weeks for day in days]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 19,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "error",
|
|
"ename": "NameError",
|
|
"evalue": "name 'a' is not defined",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[0;32m<ipython-input-19-3f786850e387>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0ma\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
"\u001b[0;31mNameError\u001b[0m: name 'a' is not defined"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"a"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 20,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "execute_result",
|
|
"data": {
|
|
"text/plain": "0"
|
|
},
|
|
"metadata": {},
|
|
"execution_count": 20
|
|
}
|
|
],
|
|
"source": [
|
|
"0 % 7"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 21,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "execute_result",
|
|
"data": {
|
|
"text/plain": "6"
|
|
},
|
|
"metadata": {},
|
|
"execution_count": 21
|
|
}
|
|
],
|
|
"source": [
|
|
"-1 % 7"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 22,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "error",
|
|
"ename": "NameError",
|
|
"evalue": "name 'model' is not defined",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[0;32m<ipython-input-22-4d45c109f633>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshift_count\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"night\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
"\u001b[0;31mNameError\u001b[0m: name 'model' is not defined"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"model.shift_count[(5, \"night\")].value"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 23,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "error",
|
|
"ename": "NameError",
|
|
"evalue": "name 'workers' is not defined",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[0;32m<ipython-input-23-2f761ca0465d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;34m[\u001b[0m\u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mid\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mw\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mworkers\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
"\u001b[0;31mNameError\u001b[0m: name 'workers' is not defined"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"[w.id for w in workers]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"language_info": {
|
|
"name": "python",
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"version": "3.7.5-final"
|
|
},
|
|
"orig_nbformat": 2,
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"npconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": 3,
|
|
"kernelspec": {
|
|
"name": "python37564bit5ba0d1a6f89f489d9799b0f9b976a56e",
|
|
"display_name": "Python 3.7.5 64-bit"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
} |