update v2 test
This commit is contained in:
1 parent
c7bdc8c75b
commit
e53e050ff8
2 files changed
+28
-27
No files matched your search
+12
-12
@@ -4,18 +4,18 @@ let students = require('./students.json');
|
|||||||
// console.table(schedule)
|
// console.table(schedule)
|
||||||
|
|
||||||
// Display first semester
|
// Display first semester
|
||||||
// console.table(schedule.block1)
|
console.table(schedule.block1)
|
||||||
// console.table(schedule.block2)
|
console.table(schedule.block2)
|
||||||
// console.table(schedule.block3)
|
console.table(schedule.block3)
|
||||||
// console.table(schedule.block4)
|
console.table(schedule.block4)
|
||||||
|
|
||||||
// // Display second semester
|
// Display second semester
|
||||||
// console.table(schedule.block5)
|
console.table(schedule.block5)
|
||||||
// console.table(schedule.block6)
|
console.table(schedule.block6)
|
||||||
// console.table(schedule.block7)
|
console.table(schedule.block7)
|
||||||
// console.table(schedule.block8)
|
console.table(schedule.block8)
|
||||||
|
|
||||||
// Display each students schedule
|
// Display each students schedule
|
||||||
for (let i = 0; i < students.length; i++) {
|
// for (let i = 0; i < students.length; i++) {
|
||||||
console.table(students[i].schedule)
|
// console.table(students[i].schedule)
|
||||||
}
|
// }
|
||||||
+16
-15
@@ -53,7 +53,7 @@ running: {
|
|||||||
studentsNum = 400
|
studentsNum = 400
|
||||||
|
|
||||||
err1, err2, = 0,0
|
err1, err2, = 0,0
|
||||||
minReq, classCap, blockClassLimit = 18, 30, 21
|
minReq, classCap, blockClassLimit = 18, 30, 18
|
||||||
mockStudents = []
|
mockStudents = []
|
||||||
running = {
|
running = {
|
||||||
"block1": {},
|
"block1": {},
|
||||||
@@ -196,18 +196,19 @@ def generateScheduleV2():
|
|||||||
|
|
||||||
# calculate # of times to run class
|
# calculate # of times to run class
|
||||||
for i in range(len(activeCourses)):
|
for i in range(len(activeCourses)):
|
||||||
classRunCount = math.floor(activeCourses[list(activeCourses)[i]]["totalrequests"] / classCap)
|
index = list(activeCourses)[i]
|
||||||
|
classRunCount = math.floor(activeCourses[index]["totalrequests"] / classCap)
|
||||||
# If there is minReq+ requests left, 1 more class could be run
|
# If there is minReq+ requests left, 1 more class could be run
|
||||||
if (activeCourses[list(activeCourses)[i]]["totalrequests"] % classCap) > minReq: classRunCount += 1
|
if (activeCourses[index]["totalrequests"] % classCap) > minReq: classRunCount += 1
|
||||||
activeCourses[list(activeCourses)[i]]["classRunCount"] = classRunCount
|
activeCourses[index]["classRunCount"] = classRunCount
|
||||||
|
|
||||||
blockIndex = 1
|
blockIndex = 1
|
||||||
while classRunCount > 0:
|
while classRunCount > 0:
|
||||||
block = f"block{blockIndex}"
|
block = f"block{blockIndex}"
|
||||||
if activeCourses[i] not in running[block]:
|
if activeCourses[index]["code"] not in running[block] and len(running[block]) < blockClassLimit:
|
||||||
# Generate class and sub 1 from classRunCount
|
# Generate class and sub 1 from classRunCount
|
||||||
running[block][activeCourses[i]] = {
|
running[block][activeCourses[index]["code"]] = {
|
||||||
"name": courses[activeCourses[i]]["name"],
|
"name": activeCourses[index]["name"],
|
||||||
"students": []
|
"students": []
|
||||||
}
|
}
|
||||||
classRunCount -= 1
|
classRunCount -= 1
|
||||||
@@ -244,7 +245,7 @@ if __name__ == '__main__':
|
|||||||
exit()
|
exit()
|
||||||
print("Processing...")
|
print("Processing...")
|
||||||
mockStudents = generateMockStudents(studentsNum)
|
mockStudents = generateMockStudents(studentsNum)
|
||||||
generateScheduleV1()
|
generateScheduleV2()
|
||||||
else:
|
else:
|
||||||
print("Invalid argument")
|
print("Invalid argument")
|
||||||
exit()
|
exit()
|
||||||
@@ -264,14 +265,14 @@ if __name__ == '__main__':
|
|||||||
# print(f"Class: {name} | Students: {students}")
|
# print(f"Class: {name} | Students: {students}")
|
||||||
|
|
||||||
# Count errors in students schedules
|
# Count errors in students schedules
|
||||||
errors = 0
|
# errors = 0
|
||||||
for i in range(len(mockStudents)):
|
# for i in range(len(mockStudents)):
|
||||||
count = 0
|
# count = 0
|
||||||
for course in mockStudents[i]["schedule"]:
|
# for course in mockStudents[i]["schedule"]:
|
||||||
if mockStudents[i]["schedule"][course]=="": count+=1
|
# if mockStudents[i]["schedule"][course]=="": count+=1
|
||||||
if count > 0: errors += 1
|
# if count > 0: errors += 1
|
||||||
|
|
||||||
print(f"{errors}/{studentsNum} student(s) have a issue with their schedule")
|
# print(f"{errors}/{studentsNum} student(s) have a issue with their schedule")
|
||||||
|
|
||||||
|
|
||||||
with open("schedule.json", "w") as outfile:
|
with open("schedule.json", "w") as outfile:
|
||||||
|
|||||||
Reference in new issue
Block a user