From 21fd6d49ca37c04a25f787965c6edf554d4689c6 Mon Sep 17 00:00:00 2001 From: KeerthanaSrikanth Date: Tue, 11 Sep 2018 18:12:19 +0530 Subject: [PATCH] Instructor preference, fill applied queue, sort courses --- Compute.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Compute.py b/Compute.py index f3d1e8c..70f39da 100644 --- a/Compute.py +++ b/Compute.py @@ -22,3 +22,36 @@ def lambda_c(course, student_list): #course is an object of course class, studen def lambda_s(student): #Returns lambda_s return (student.preferences[0][1]*0.8+student.CG*0.2); + +def instructorAllotPreference(instructor_list, course_list): #Not checking for clashes, not checking if student applied for the course. + #List of all instructors, list of all courses. + for i in instructor_list: + for j in course_list: + for k, l in i.preference: + if (k==j.course_code): + heapq.heappush(j.selected, l); + l.alloted=j; + j.size_remaining=j.size_remaining-1; + +def fillApplied(course_list, student_list): +#List of all courses, list of all students + for i in student_list: + for j in course_list: + if(i.preferences[0][0]==j.course_code): + heapq.heappush(j.applied, i); + +def sortCourses(course_list, student_list): +#List of all courses, list of all students + lambda_c_list=[]; + for i in course_list: + c=lambda_c(i, student_list); + lambda_c_list.append((i, c)); + + sorted(lambda_c_list, key=getKey); + return lambda_c_list; + + + +def getKey(item): + return item[1]; +