-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroup_polishing.py
124 lines (115 loc) · 6.57 KB
/
group_polishing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from copy import deepcopy
from collections import defaultdict
from schedule import Schedule
from competitors import Competitor
def stationNumbersEventStage(scheduleInfo,personInfo,event):
for groupNum in scheduleInfo.groups[event]:
counter = 0
realCounter = 0
while realCounter < len(scheduleInfo.groups[event][groupNum]):
for stage in range(scheduleInfo.amountStages):
if stage == 0:
counter +=1
if realCounter < len(scheduleInfo.groups[event][groupNum]):
person = scheduleInfo.groups[event][groupNum][realCounter]
personInfo[person].stationNumbers[event] = int(stage*(scheduleInfo.amountStations/scheduleInfo.amountStages) + (counter))
scheduleInfo.stationOveriew[event][groupNum][person] = int(stage*(scheduleInfo.amountStations/scheduleInfo.amountStages) + (counter))
realCounter += 1
def stationNumbersEventNoStage(scheduleInfo,personInfo,event):
for groupNum in scheduleInfo.groups[event]:
for idx,person in enumerate(scheduleInfo.groups[event][groupNum]):
personInfo[person].stationNumbers[event] = idx+1
scheduleInfo.stationOveriew[event][groupNum][person] = idx+1
def assignStationNumbers(scheduleInfo:Schedule,personInfo:dict[str,Competitor]):
useStages = True if scheduleInfo.amountStages > 1 else False
for event in scheduleInfo.eventWOTimes:
if event not in scheduleInfo.setOfCombinedEvents:
if useStages:
stationNumbersEventStage(scheduleInfo,personInfo,event)
else:
stationNumbersEventNoStage(scheduleInfo,personInfo,event)
def getStationNumbers(scheduleInfo,personInfo,combined,stages):
if not stages:
for event in scheduleInfo.eventWOTimes:
scheduleInfo.stationOveriew[event] = {}
for groupNum in scheduleInfo.groups[event]:
scheduleInfo.stationOveriew[event][groupNum] = {}
for idx,person in enumerate(scheduleInfo.groups[event][groupNum]):
personInfo[person].stationNumbers[event] = idx+1
scheduleInfo.stationOveriew[event][groupNum][person] = idx+1
# if scheduleInfo.maxAmountGroups > 3:
# for event in scheduleInfo.eventWOTimes:
# scheduleInfo.judgeStationOveriew = {}
# if len(scheduleInfo.groups[event]) > 3:
# scheduleInfo.judgeStationOveriew[event] = {}
# for groupNum in scheduleInfo.groups[event]:
# scheduleInfo.judgeStationOveriew[event][groupNum] = {}
# for idx,person in enumerate(scheduleInfo.groupJudges[event][groupNum]):
# scheduleInfo.judgeStationOveriew[event][groupNum][person] = idx+1
else:
for event in scheduleInfo.eventWOTimes:
scheduleInfo.stationOveriew[event] = {}
for groupNum in scheduleInfo.groups[event]:
scheduleInfo.stationOveriew[event][groupNum] = {}
counter = 0
realCounter = 0
while realCounter < len(scheduleInfo.groups[event][groupNum]):
for stage in range(stages):
if stage == 0:
counter +=1
if realCounter < len(scheduleInfo.groups[event][groupNum]):
person = scheduleInfo.groups[event][groupNum][realCounter]
personInfo[person].stationNumbers[event] = int(stage*(scheduleInfo.amountStations/stages) + (counter))
scheduleInfo.stationOveriew[event][groupNum][person] = int(stage*(scheduleInfo.amountStations/stages) + (counter))
realCounter += 1
# if scheduleInfo.maxAmountGroups > 3:
# scheduleInfo.judgeStationOveriew = {}
# for event in scheduleInfo.eventWOTimes:
# scheduleInfo.judgeStationOveriew[event] = {}
# if len(scheduleInfo.groups[event]) > 3:
# scheduleInfo.judgeStationOveriew[event][groupNum] = {}
# for groupNum in scheduleInfo.groups[event]:
# scheduleInfo.judgeStationOveriew[event][groupNum] = {}
# counter = 0
# realCounter = 0
# while realCounter < len(scheduleInfo.groupJudges[event][groupNum]):
# for stage in range(stages):
# if stage == 0:
# counter +=1
# if realCounter < len(scheduleInfo.groupJudges[event][groupNum]):
# person = scheduleInfo.groupJudges[event][groupNum][realCounter]
# scheduleInfo.judgeStationOveriew[event][groupNum][person] = int(stage*(scheduleInfo.amountStations/stages) + (counter))
# realCounter += 1
if combined: # Fix the assignment back to regular events
combHy = combined[0]+'-'+combined[1]
for person in personInfo:
for comSplit in combined:
if comSplit in personInfo[person].events:
personInfo[person].stationNumbers[comSplit] = deepcopy(personInfo[person].stationNumbers[combHy])
if combHy in personInfo[person].stationNumbers:
personInfo[person].stationNumbers.pop(combHy)
def sortForDelegates(competitors,delegates):
# newList = []
for i in range(len(competitors)):
for j in range(i+1,len(competitors)):
if competitors[j] in delegates:
competitors[i],competitors[j] = competitors[j],competitors[i]
return competitors
def tempCombinedAssigning(scheduleInfo,personInfo,hdcEvents,delegates): # Only works for two groups
competitorsInAll = []
for event in hdcEvents:
scheduleInfo.stationOveriew[event] = {}
for groupNum in range(1,3):
scheduleInfo.stationOveriew[event][groupNum] = {}
competitorsInAll = list(set(scheduleInfo.eventCompetitors[event]) | set(competitorsInAll))
# competitorsInAll.sort(key=lambda x:personInfo[x].orga)
competitorsInAll = sortForDelegates(competitorsInAll,delegates)
halfs = [competitorsInAll[::2],competitorsInAll[1::2]]
for groupNum in range(1,3):
for stationNumber, competitor in enumerate(halfs[groupNum-1]):
for event in hdcEvents:
if event in personInfo[competitor].events:
personInfo[competitor].groups[event] = groupNum
scheduleInfo.groups[event][groupNum].append(competitor)
scheduleInfo.stationOveriew[event][groupNum][competitor] = stationNumber+1
personInfo[competitor].stationNumbers[event] = stationNumber+1