This commit is contained in:
SowinskiBraeden committed 2022-06-21 18:02:47 -07:00
1 parent aa8abf3c9d
commit fd914e4be7
2 files changed
+31 -19

No files matched your search

+9 -16
View File
@@ -21,7 +21,6 @@ from util.generateCourses import getSampleCourses
...
}
running example:
running: {
"block1": {
@@ -44,21 +43,15 @@ def getLineNumber(): return currentframe().f_back.f_lineno
# Returns if the particular student has a previous error
def newConflict(pupilNum: str, email: str, conflictType: str, code: str, description: str, logs: dict) -> bool:
exists = True if pupilNum in logs else False
if exists: logs[pupilNum].append({
"Pupil #": pupilNum,
"Email": email,
"Type": conflictType,
"Code": code,
"Conflict": description
})
else:
logs[pupilNum] = [{
"Pupil #": pupilNum,
"Email": email,
"Type": conflictType,
"Code": code,
"Conflict": description
}]
log = {
"Pupil #": pupilNum,
"Email": email,
"Type": conflictType,
"Code": code,
"Conflict": description
}
if exists: logs[pupilNum].append(log)
else: logs[pupilNum] = [log]
return exists
minReq, median, classCap = 18, 24, 30
+22 -3
View File
@@ -1,6 +1,9 @@
#! python
from prettytable import PrettyTable
from typing import Tuple
from time import time, sleep
import itertools
import threading
import json
import sys
@@ -11,6 +14,15 @@ from util.generateCourses import getSampleCourses
# Import Algorithm
from scheduleGenerator.generator import generateScheduleV3
done = False
def processing():
for c in itertools.cycle(['|', '/', '-', '\\']):
if done: break
sys.stdout.write(f'\rProcessing {c}')
sys.stdout.flush()
sleep(0.1)
def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
# Error Table calulation / output
f = open('./output/conflicts.json')
@@ -34,7 +46,11 @@ def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
if __name__ == '__main__':
if len(sys.argv) == 1:
print("Processing...\n")
print()
st = time() # Start time
t = threading.Thread(target=processing)
t.start() # Start animation
sampleStudents = getSampleStudents("./sample_data/course_selection_data.csv", True)
samplemockCourses = getSampleCourses("./sample_data/course_selection_data.csv", True)
@@ -42,6 +58,11 @@ if __name__ == '__main__':
timetable["Version"] = 3
timetable["timetable"] = generateScheduleV3(sampleStudents, samplemockCourses, 40, "./output/students.json", "./output/conflicts.json")
done = True # End Animation
et = time() # End time
elapsed_time = round((et - st), 3) # Execution time
print(f'\n\nDone - Finished in {elapsed_time} seconds\n')
errors, _, _ = errorOutput(sampleStudents)
print(errors)
@@ -69,5 +90,3 @@ if __name__ == '__main__':
with open("./output/timetable.json", "w") as outfile:
json.dump(timetable, outfile, indent=2)
print("\nDone")