assignment[var] = classoffering return None class MyEncoder(JSONEncoder): def default(self, o): return o.__dict__ if __name__ == "__main__": course = sys.argv[1] csvpath = sys.argv[2] # course = "bs cmsc" # csvpath = "../csv/4thYrKomsai3.csv" student = classes.Student(3, "2016-2017", 2, course, classes.createSubjectList(csvpath)) coursesToTake = [ classes.Subject("4", "1", "cmsc137", "core", "3", "lec"), classes.Subject("4", "1", "cmsc137", "core", "", "lab"), classes.Subject("4", "1", "cmsc142", "core", "3", "lec"), classes.Subject("4", "1", "cmsc198.1", "core", "2", "lec"), classes.Subject("4", "1", "cmsc192", "core", "1", "lec"), classes.Subject("4", "1", "", "elective", "3", "lec"), classes.Subject("4", "1", "", "elective", "3", "lec"), classes.Subject("1", "1", "", "ge(ah)", "3", "lec") ] assignment = initbacktracking(coursesToTake, student.coursesTaken, student.electiveList) try: for key in assignment.keys():
constraintspath = sys.argv[3] preferencesPath = sys.argv[4] schedulePath = sys.argv[5] violated_path = sys.argv[6] preferred_path = sys.argv[7] ############################################ # course = "bs cmsc" # csvpath = "../csv/4thYrKomsai3.csv" # constraintspath = "../constraints/1.csv" # preferencesPath = "../preferences/1.csv" # schedulePath = "../schedule/1.csv" # violated_path = "../violated_constraints/1.csv" # preferred_path = "../preferred subjects/1.csv" ############################################ student = classes.Student(3, "2016-2017", 2, course, classes.createSubjectList(csvpath)) coursesToTake = classes.createSubjectList(preferencesPath) softconstraints = [] if Path(constraintspath).is_file(): softconstraints += classes.createConstraintsList(constraintspath) if Path(preferred_path).is_file(): softconstraints += classes.createPreferredConstraintsList( preferred_path) assignment, problem = initls(coursesToTake, student.coursesTaken, student.electiveList, softconstraints, student.campus) all_soft_violations = problem.all_soft_violations(assignment) classes.csvWriteConstraint(violated_path, all_soft_violations) all_soft_violations = MyEncoder().encode(all_soft_violations) print(all_soft_violations)
#!/usr/bin/python import csv import re import classes import neededcourses import study_plan as stp import sys def checkUnits(course, subject, subtype): for sub in course: if sub.courseName == subject: return sub.units elif subtype != "pe": return "3" elif subtype == "pe": return "2" if __name__ == '__main__': course = sys.argv[1] taken = sys.argv[2] studyplan = classes.createSubjectList(stp.getCoursePath(course)) takencourses = classes.createSubjectList(taken) for takencourse in takencourses: print(takencourse.courseName + ",") print(takencourse.courseType + ",") print( checkUnits(studyplan, takencourse.courseName, takencourse.courseType)) print("/")
import csv import classes import json import sys import acquire_schedule as acq if __name__ == '__main__': ############################################ path = "csv\\data.csv" prefered = "preferences\\" + sys.argv[1] + ".csv" ############################################ # path = "../csv/data.csv" # prefered = "../preferences/1.csv" ############################################ classOfferingList = classes.createClassesList(path) preferences = classes.createSubjectList(prefered) for prefer in preferences: classOfferingList1 = [ classoffering for classoffering in classOfferingList if (classoffering.courseName.lower().replace( " ", "") == prefer.courseName.lower().replace('"', "") and classoffering.semester == prefer.semester) ] for subject in classOfferingList1: print(subject.year + "|") print(subject.semester + "|") print(subject.courseName + "|") print(subject.section + "|") print(subject.units + "|") print(subject.campus + "|") for ses in subject.sessions:
#!/usr/bin/python import csv import re import classes import neededcourses import study_plan as stp import preference as pre import acad_progress import sys if __name__ == '__main__': course = sys.argv[1] taken = sys.argv[2] prefer = sys.argv[3] studyplan = classes.createSubjectList(stp.getCoursePath(course)) takencourses = classes.createSubjectList(taken) gelist = classes.createSubjectList("study plans\\ge_list.csv") remainAH = pre.remainAH(gelist, stp.getGEAH(takencourses)) remainSSP = pre.remainSSP(gelist, stp.getGESSP(takencourses)) remainMST = pre.remainMST(gelist, stp.getGEMST(takencourses)) remainCORE = pre.remainCORE(studyplan, taken, takencourses) if (prefer not in remainAH) and (prefer not in remainCORE) and ( prefer not in remainMST) and (prefer not in remainSSP): print("FALSE") else: print("TRUE") #print(prefer)
wildcard_courseTypes_max_counts = getWildCardCourses(allCourses) wildcard_courseTypes_current_counts = getCurrentCounts( coursesTaken, wildcard_courseTypes_max_counts) wildcard_courseTypes_lacking_counts = getLackingCounts( wildcard_courseTypes_max_counts, wildcard_courseTypes_current_counts) output = [] name_coursesTaken = [course.courseName for course in coursesTaken] for course in allCourses: if course.courseName.strip() != '': #if not blank, match name if course.courseName not in name_coursesTaken: output.append(course) else: # blank course name, match type courseType = course.courseType if wildcard_courseTypes_lacking_counts[courseType] > 0: output.append(course) wildcard_courseTypes_lacking_counts[courseType] -= 1 return output if __name__ == '__main__': student = classes.Student( 3, "2016-2017", 2, "bs cmsc", classes.createSubjectList("../csv/3rdYrKomsai.csv")) neededcourses = coursesToTake(student.allCourses, student.coursesTaken) for neededcourse in neededcourses: neededcourse.displaySubject()