v3 logic begin
This commit is contained in:
1 parent
0493f8b147
commit
4d57a93e69
1 file changed
+22
-13
+22
-13
@@ -355,7 +355,6 @@ def generateScheduleV2():
|
|||||||
def generateScheduleV3(students, courses):
|
def generateScheduleV3(students, courses):
|
||||||
# Step 1 - Calculate which classes can run
|
# Step 1 - Calculate which classes can run
|
||||||
global err1, err2
|
global err1, err2
|
||||||
# Collect data and calculate schedules
|
|
||||||
for student in students:
|
for student in students:
|
||||||
# Tally class request
|
# Tally class request
|
||||||
for request in student["requests"]:
|
for request in student["requests"]:
|
||||||
@@ -363,34 +362,44 @@ def generateScheduleV3(students, courses):
|
|||||||
code = request["CrsNo"]
|
code = request["CrsNo"]
|
||||||
courses[code]["Requests"] += 1
|
courses[code]["Requests"] += 1
|
||||||
# Add course to active list if enough requests
|
# Add course to active list if enough requests
|
||||||
if courses[code]["Requests"] > 12 and courses[code]["CrsNo"] not in activeCourses:
|
if courses[code]["Requests"] > minReq and courses[code]["CrsNo"] not in activeCourses:
|
||||||
activeCourses[code] = courses[code]
|
activeCourses[code] = courses[code]
|
||||||
|
|
||||||
# Step 2 - Generate class list without timetable
|
# Step 2 - Generate class list without timetable
|
||||||
selectedCourses = {}
|
selectedCourses = {}
|
||||||
|
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)):
|
||||||
index = list(activeCourses)[i]
|
index = list(activeCourses)[i]
|
||||||
|
if index not in emptyClasses: emptyClasses[index] = {}
|
||||||
classRunCount = math.floor(activeCourses[index]["Requests"] / median)
|
classRunCount = math.floor(activeCourses[index]["Requests"] / median)
|
||||||
remaining = activeCourses[index]["Requests"] % median
|
remaining = activeCourses[index]["Requests"] % median
|
||||||
|
|
||||||
if remaining <= (classCap - median):
|
# Put # of classRunCount classes in emptyClasses
|
||||||
for j in classRunCount:
|
for j in classRunCount:
|
||||||
pass
|
emptyClasses[index][f"{activeCourses[index]['Description']}-{j}"] = {
|
||||||
# Equally disperse remaining into classRunCount
|
"CrsNo": index,
|
||||||
|
"Description": activeCourses[index]["Description"],
|
||||||
|
"expectedLen": median # Number of students expected in this class / may be altered
|
||||||
|
}
|
||||||
|
SomeCondition = True # Just so I don't get an error
|
||||||
|
|
||||||
# Elif we can fit them in, and there is more than 12, drain classRunCount
|
# If remaining fit in open slots in existing classes
|
||||||
|
# equally disperse remaining into existing classes
|
||||||
|
if remaining <= classRunCount * (classCap - median):
|
||||||
|
for j in classRunCount:
|
||||||
|
# TODO: Equally disperse remaining into existing classes
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Else if we can't fit remaining in,
|
||||||
|
# and there is more than 12, equally drain expectedLen from each classRunCount
|
||||||
# to fill another class, add 1 to classRunCount
|
# to fill another class, add 1 to classRunCount
|
||||||
|
elif remaining > classRunCount * (classCap - median) and SomeCondition:
|
||||||
|
pass
|
||||||
|
|
||||||
# else fold students into another class (alternate?)
|
# else fold students into another class (alternate?)
|
||||||
|
|
||||||
if remaining >= minReq: classRunCount += 1
|
#=================================================================
|
||||||
elif 6 <= remaining < minReq:
|
|
||||||
evenClasses = True if classRunCount > 0 else False
|
|
||||||
offset = classRunCount
|
|
||||||
while evenClasses:
|
|
||||||
lastIndex = list(activeCourses)[len(activeCourses)-offset]
|
|
||||||
|
|
||||||
|
|
||||||
classNum = classRunCount
|
classNum = classRunCount
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user