add step 6 logic
This commit is contained in:
1 parent
f0d0f4cd7e
commit
ffa58fd85b
1 file changed
+11
-15
@@ -338,16 +338,22 @@ def generateScheduleV3(students: list, courses: dict, blockClassLimit: int=40, s
|
|||||||
# Step 6 - Evaluate, move students to fix
|
# Step 6 - Evaluate, move students to fix
|
||||||
for student in students:
|
for student in students:
|
||||||
blocks = [student["schedule"][block] for block in student["schedule"]]
|
blocks = [student["schedule"][block] for block in student["schedule"]]
|
||||||
blockLens = [len(block) for block in blocks]
|
final = list(block)
|
||||||
|
exceptions = []
|
||||||
count, conflicts = 0, True
|
count, conflicts = 0, True
|
||||||
while conflicts:
|
while conflicts:
|
||||||
count = sum(1 for b in blocks if len(b)==1)
|
count = sum(1 for b in blocks if len(b)==1)
|
||||||
|
|
||||||
print(blocks, "\n")
|
|
||||||
|
|
||||||
if count < student["expectedClasses"]:
|
if count < student["expectedClasses"]:
|
||||||
|
index = None
|
||||||
# Attempt to fix
|
# Attempt to fix
|
||||||
index = blockLens.index(max(blockLens))
|
if len(exceptions) > 0:
|
||||||
|
blocks = [elem for i, elem in enumerate(blocks) if i not in exceptions]
|
||||||
|
for index in exceptions: blocks.insert(index, ['exception'])
|
||||||
|
elif len(exceptions) == 0:
|
||||||
|
index = blockLens.index(max(blockLens))
|
||||||
|
|
||||||
|
blockLens = [len(block) for block in blocks]
|
||||||
blockOut = f"block{index+1}"
|
blockOut = f"block{index+1}"
|
||||||
done = False
|
done = False
|
||||||
moveIndex = 0
|
moveIndex = 0
|
||||||
@@ -360,13 +366,6 @@ def generateScheduleV3(students: list, courses: dict, blockClassLimit: int=40, s
|
|||||||
if list(running).index(block) != index and list(running).index(block) in freeBlocks:
|
if list(running).index(block) != index and list(running).index(block) in freeBlocks:
|
||||||
for cname in running[block]:
|
for cname in running[block]:
|
||||||
if cname[:-2] == blocks[index][moveIndex][:-2] and len(running[block][cname]["students"]) < classCap:
|
if cname[:-2] == blocks[index][moveIndex][:-2] and len(running[block][cname]["students"]) < classCap:
|
||||||
|
|
||||||
print("index: ", index)
|
|
||||||
print("blockOut: ", blockOut)
|
|
||||||
print("classOut: ", classOut)
|
|
||||||
print("blockIn: ", block)
|
|
||||||
print("classIn: ", cname)
|
|
||||||
|
|
||||||
studentData = {
|
studentData = {
|
||||||
"Pupil #": student["Pupil #"],
|
"Pupil #": student["Pupil #"],
|
||||||
"index": student["studentIndex"]
|
"index": student["studentIndex"]
|
||||||
@@ -381,7 +380,6 @@ def generateScheduleV3(students: list, courses: dict, blockClassLimit: int=40, s
|
|||||||
del running[blockOut][classOut]["students"][studentIndex] # Remove final
|
del running[blockOut][classOut]["students"][studentIndex] # Remove final
|
||||||
running[block][cname]["students"].append(studentData)
|
running[block][cname]["students"].append(studentData)
|
||||||
|
|
||||||
print(blocks)
|
|
||||||
found, done = True, True
|
found, done = True, True
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -389,12 +387,10 @@ def generateScheduleV3(students: list, courses: dict, blockClassLimit: int=40, s
|
|||||||
if moveIndex < len(blocks[index])-1:
|
if moveIndex < len(blocks[index])-1:
|
||||||
moveIndex += 1
|
moveIndex += 1
|
||||||
elif moveIndex == len(blocks[index])-1:
|
elif moveIndex == len(blocks[index])-1:
|
||||||
print("Failed")
|
exceptions.append(index)
|
||||||
done = True
|
done = True
|
||||||
break
|
break
|
||||||
|
|
||||||
print("=========================\n")
|
|
||||||
|
|
||||||
elif count == student["expectedClasses"]:
|
elif count == student["expectedClasses"]:
|
||||||
conflicts = False
|
conflicts = False
|
||||||
elif count > student["expectedClasses"]:
|
elif count > student["expectedClasses"]:
|
||||||
|
|||||||
Reference in new issue
Block a user