detail errors output
This commit is contained in:
1 parent
1c1f0ee6f0
commit
a2d365625e
2 files changed
+62
-21
No files matched your search
@@ -346,9 +346,8 @@ def generateScheduleV3(
|
|||||||
students[student["index"]]["classes"] += 1
|
students[student["index"]]["classes"] += 1
|
||||||
|
|
||||||
|
|
||||||
# Step 6 | Part A - Evaluate, move students to fix conflicts
|
# Step 6 - Evaluate, move students to fix conflicts
|
||||||
conflictLogs = [] # Counts as an error that is an issue
|
conflictLogs = []
|
||||||
acceptableConflictLogs = [] # Is minor error that is not an issue
|
|
||||||
|
|
||||||
for student in students:
|
for student in students:
|
||||||
initialBlocks = [student["schedule"][block] for block in student["schedule"]]
|
initialBlocks = [student["schedule"][block] for block in student["schedule"]]
|
||||||
@@ -421,7 +420,9 @@ def generateScheduleV3(
|
|||||||
conflictLogs.append({
|
conflictLogs.append({
|
||||||
"Pupil #": student["Pupil #"],
|
"Pupil #": student["Pupil #"],
|
||||||
"Email": "",
|
"Email": "",
|
||||||
"Conflict": "Critical: Couldn't solve schedule"
|
"Type": "Critical",
|
||||||
|
"Code": "C-CSS",
|
||||||
|
"Conflict": "Couldn't solve schedule"
|
||||||
})
|
})
|
||||||
hasConflicts = False
|
hasConflicts = False
|
||||||
# classOut = blocks[clashIndex][classIndex]
|
# classOut = blocks[clashIndex][classIndex]
|
||||||
@@ -449,10 +450,12 @@ def generateScheduleV3(
|
|||||||
while not metSelfRequirements:
|
while not metSelfRequirements:
|
||||||
|
|
||||||
if (student["expectedClasses"] - 2) <= student["classes"] < student["expectedClasses"]:
|
if (student["expectedClasses"] - 2) <= student["classes"] < student["expectedClasses"]:
|
||||||
acceptableConflictLogs.append({
|
conflictLogs.append({
|
||||||
"Pupil #": student["Pupil #"],
|
"Pupil #": student["Pupil #"],
|
||||||
"Email": "",
|
"Email": "",
|
||||||
"Conflict": "Acceptable: Missing 1-2 classes"
|
"Type": "Acceptable",
|
||||||
|
"Code": "A-MC",
|
||||||
|
"Conflict": "Missing 1-2 classes"
|
||||||
})
|
})
|
||||||
metSelfRequirements = True
|
metSelfRequirements = True
|
||||||
|
|
||||||
@@ -462,7 +465,9 @@ def generateScheduleV3(
|
|||||||
conflictLogs.append({
|
conflictLogs.append({
|
||||||
"Pupil #": student["Pupil #"],
|
"Pupil #": student["Pupil #"],
|
||||||
"Email": "",
|
"Email": "",
|
||||||
"Conflict": "Critical: Missing too many classes"
|
"Type": "Critical",
|
||||||
|
"Code": "C-MC",
|
||||||
|
"Conflict": "Missing too many classes"
|
||||||
})
|
})
|
||||||
metSelfRequirements = True
|
metSelfRequirements = True
|
||||||
|
|
||||||
@@ -471,8 +476,8 @@ def generateScheduleV3(
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
finalConflictLogs = {
|
finalConflictLogs = {
|
||||||
"Critical": conflictLogs,
|
"Critical": [conflict for conflict in conflictLogs if conflict["Type"] == "Critical"],
|
||||||
"Acceptable": acceptableConflictLogs
|
"Acceptable": [conflict for conflict in conflictLogs if conflict["Type"] == "Acceptable"]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update Student records
|
# Update Student records
|
||||||
|
|||||||
+48
-12
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
from prettytable import PrettyTable
|
from prettytable import PrettyTable
|
||||||
|
from typing import Tuple
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -13,6 +14,24 @@ from scheduleGenerator.generator_v1 import generateScheduleV1
|
|||||||
from scheduleGenerator.generator_v2 import generateScheduleV2
|
from scheduleGenerator.generator_v2 import generateScheduleV2
|
||||||
from scheduleGenerator.generator_v3 import generateScheduleV3
|
from scheduleGenerator.generator_v3 import generateScheduleV3
|
||||||
|
|
||||||
|
def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
||||||
|
# Error Table calulation / output
|
||||||
|
f = open('./output/conflicts.json')
|
||||||
|
conflicts = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
t = PrettyTable(['Type', 'Error %', 'Success %', 'Error Ratio'])
|
||||||
|
|
||||||
|
errorsC = round(len(conflicts["Critical"]) / len(students) * 100, 2)
|
||||||
|
successC = round(100 - errorsC, 2)
|
||||||
|
errorsA = round(len(conflicts["Acceptable"]) / len(students) * 100, 2)
|
||||||
|
successA = round(100 - errorsA, 2)
|
||||||
|
|
||||||
|
t.add_row(['Critical', f"{errorsC} %", f"{successC} %", f"{len(conflicts['Critical'])}/{len(students)}"])
|
||||||
|
t.add_row(['Acceptable', f"{errorsA} %", f"{successA} %", f"{len(conflicts['Acceptable'])}/{len(students)}"])
|
||||||
|
|
||||||
|
return t, conflicts["Critical"], conflicts["Acceptable"]
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
@@ -46,19 +65,36 @@ if __name__ == '__main__':
|
|||||||
timetable["Version"] = 3
|
timetable["Version"] = 3
|
||||||
timetable["timetable"] = generateScheduleV3(sampleStudents, samplemockCourses, 40, "./output/students.json", "./output/conflicts.json")
|
timetable["timetable"] = generateScheduleV3(sampleStudents, samplemockCourses, 40, "./output/students.json", "./output/conflicts.json")
|
||||||
|
|
||||||
# Error Table calulation / output
|
errors, _, _ = errorOutput(sampleStudents)
|
||||||
f = open('./output/conflicts.json')
|
print(errors)
|
||||||
conflicts = json.load(f)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
t = PrettyTable(['Type', 'Error %', 'Success %', 'Error Ratio'])
|
elif sys.argv[1].upper() == "ERRORS":
|
||||||
errors = round(len(conflicts["Critical"]) / len(sampleStudents) * 100, 2)
|
sampleStudents = getSampleStudents("./sample_data/course_selection_data.csv", True)
|
||||||
success = round(100 - errors, 2)
|
errors, critical, acceptable = errorOutput(sampleStudents)
|
||||||
t.add_row(['Critical', f"{errors} %", f"{success} %", f"{len(conflicts['Critical'])}/{len(sampleStudents)}"])
|
print()
|
||||||
errors = round(len(conflicts["Acceptable"]) / len(sampleStudents) * 100, 2)
|
print(errors)
|
||||||
success = round(100 - errors, 2)
|
|
||||||
t.add_row(['Acceptable', f"{errors} %", f"{success} %", f"{len(conflicts['Acceptable'])}/{len(sampleStudents)}"])
|
print(f"\n{len(critical)} critical errors")
|
||||||
print(t)
|
c1, c2, co = 0, 0, 0
|
||||||
|
for error in critical:
|
||||||
|
if error["Code"] == "C-MC": c1 +=1
|
||||||
|
elif error["Code"] == "C-CSS": c2 += 1
|
||||||
|
else: co += 1
|
||||||
|
|
||||||
|
print(f"x{c1} C-MC Errors: Critical - Missing Classes")
|
||||||
|
print(f"x{c2} C-CSS Errors: Critical - Couldn't Solve Schedule")
|
||||||
|
print(f"x{co} Other/Undefined Critical Errors")
|
||||||
|
|
||||||
|
print(f"\n{len(acceptable)} acceptable errors")
|
||||||
|
a1, ao = 0, 0
|
||||||
|
for error in acceptable:
|
||||||
|
if error["Code"] == "A-MC": a1 +=1
|
||||||
|
else: ao += 1
|
||||||
|
|
||||||
|
print(f"x{a1} A-MC Errors: Acceptable - Missing 1-2 Classes")
|
||||||
|
print(f"x{ao} Other/Undefined Acceptable Errors")
|
||||||
|
|
||||||
|
exit()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Invalid argument")
|
print("Invalid argument")
|
||||||
|
|||||||
Reference in new issue
Block a user