v3/begin step 4

This commit is contained in:
SowinskiBraeden committed 2022-04-12 15:06:55 -07:00
1 parent 2aa3530173
commit 3f9511e77a
1 file changed
+23 -21
+23 -21
View File
@@ -36,7 +36,7 @@ from util.generateCourses import getSampleCourses
} }
''' '''
minReq, median, classCap, blockClassLimit = 18, 24, 30, 12 minReq, median, classCap, blockClassLimit = 18, 24, 30, 26
mockStudents = [] mockStudents = []
activeCourses = {} activeCourses = {}
running = { running = {
@@ -65,7 +65,6 @@ def generateScheduleV3(students, courses):
# Step 1 - Calculate which classes can run # Step 1 - Calculate which classes can run
global err1, err2
for student in students: for student in students:
# Tally class request # Tally class request
for request in student["requests"]: for request in student["requests"]:
@@ -78,6 +77,8 @@ def generateScheduleV3(students, courses):
# Step 2 - Generate empty classes # Step 2 - Generate empty classes
allClassRunCounts = []
courseRunInfo = {} # Generated now, used in step 4
emptyClasses = {} # List of all classes with how many students should be entered during generation emptyClasses = {} # List of all classes with how many students should be entered during generation
# calculate # of times to run class # calculate # of times to run class
for i in range(len(activeCourses)): for i in range(len(activeCourses)):
@@ -105,7 +106,7 @@ def generateScheduleV3(students, courses):
# If we can create a class using remaining, but no other classes # If we can create a class using remaining, but no other classes
# exists, create class, and do not equalize # exists, create class, and do not equalize
elif remaining >= minReq and classRunCount == 0: elif remaining >= minReq:
# Create a class using remaining # Create a class using remaining
emptyClasses[index][f"{index}-{classRunCount}"] = { emptyClasses[index][f"{index}-{classRunCount}"] = {
"CrsNo": index, "CrsNo": index,
@@ -114,19 +115,7 @@ def generateScheduleV3(students, courses):
} }
classRunCount += 1 classRunCount += 1
if classRunCount >= 2:
# Else if the remaining can create a class
elif remaining >= minReq and classRunCount > 0:
# Create a class using remaining
emptyClasses[index][f"{index}-{classRunCount}"] = {
"CrsNo": index,
"Description": activeCourses[index]["Description"],
"expectedLen": remaining
}
classRunCount += 1
# Equalize (level) class expectedLen's # Equalize (level) class expectedLen's
expectedLengths = [emptyClasses[index][f"{index}-{j}"]["expectedLen"] for j in range(classRunCount)] expectedLengths = [emptyClasses[index][f"{index}-{j}"]["expectedLen"] for j in range(classRunCount)]
newExpectedLens = equal(expectedLengths) newExpectedLens = equal(expectedLengths)
@@ -168,6 +157,11 @@ def generateScheduleV3(students, courses):
emptyClasses[index][f"{index}-{j}"]["expectedLen"] += 1 emptyClasses[index][f"{index}-{j}"]["expectedLen"] += 1
remaining -= 1 remaining -= 1
courseRunInfo[index] = {
"Total": classRunCount,
"CrsNo": index
}
allClassRunCounts.append(classRunCount)
# Step 3 Fill emptyClasses with Students # Step 3 Fill emptyClasses with Students
selectedCourses = {} selectedCourses = {}
@@ -228,11 +222,19 @@ def generateScheduleV3(students, courses):
tempStudents.remove(student) tempStudents.remove(student)
# Step 4 - Attempt to fit classes into timetable # Step 4 - Attempt to fit classes into timetable
# TODO: Prioratize classes with maximum resouce limit; while len(allClassRunCounts) > 0:
# for example, classes that have lowest run counts, # Get lowest resource class (least times run)
# classes that have limited rooms dedicated for them. index = allClassRunCounts.index(min(allClassRunCounts))
# Fit these into the timetable first, then work from course = courseRunInfo[index]["CrsNo"]
# there on fitting other classes into the timetable.
# Insert 1 class into timetable
for i in range(courseRunInfo[index]["Total"]):
pass
# Remove course when fully inserted
if allClassRunCounts[index] == 0:
allClassRunCounts.remove(allClassRunCounts[index])
courseRunInfo.pop(list(courseRunInfo)[index])
# This will require knowing how many classrooms there are, # This will require knowing how many classrooms there are,
# how many classrooms for a type of class, computer, wood, # how many classrooms for a type of class, computer, wood,