def generateSem(self,priorPushList, allCourses): conNotMet = []#0's if conc not met pushList = [] schedInd = 0 for prior in priorPushList:#load prior push list self.unconditionalAddCourse(self.nextCourse(allCourses,schedInd)) schedInd+=1 valid = allCourses.values() while(self.semCreditTotal < 14): self.unconditionalAddCourse(self.nextCourse(valid,schedInd)) valid = DankMath.listDiff(valid,self.coursesTaking) schedInd +=1 for crs in self.coursesTaking: if(crs.prereqsSatisfied(self.coursesTaken+self.coursesTaking, self.concurrentList,schedInd) != 1): conNotMet.append(1) else: conMet.append(0)#use pop #self.unconditionalAddCourse(self.nextCourse(allCourses,schedInd))#should cause necessary concurrent to be added #schedInd+=1 if(sum(conNotMet) == 1): self.unconditionalAddCourse(self.nextCourse(allCourses,schedInd))#first patch for concurrency schedInd+=1 if(not self.concurrencyMet()):#change the function concMet to rereqs sat somehow conNotMet.append(1) else: conMet.append(0)#use pop elif(sum(conNotMet) == 0): pass #peachy keen! #quit now while the going's good! else: n=0 conNotMet = [] removeList = [] for ob in self.coursesTaking: if(ob.prereqsSatisfied(self.coursesTaken+self.coursesTaking, self.concurrentList,schedInd) != 1): pass #conNotMet.append(0) else: #conNotMet.append(1) pushList.append(ob) removeList.append(n) n+=1#increment to determine which courses are not satisfied still #ok, so there is a flaw in the logic here. if I take out a course, it may through #off other courses that I satisfy the prerequisites for that depend on it. nextSubset = allCourses#the code will separate this from coursesTaking. for replacedCrs in pushList: #replace each course tempCrse = self.nextCourse(allCourses,schedInd) while(tempCrse.prereqsSatisfied(self.coursesTaken+self.coursesTaking, self.concurrentList,schedInd) != 1): nextSubset = DankMath.listDiff(nextSubset, [tempCrse]) tempCrse = self.nextCourse(nextSubset,schedInd) self.unconditionalAddCourse(self.nextCourse(allCourses,schedInd)) for rem in removeList: removeList.pop(rem)#clears out the pushed courses from the current semester return pushList #will be empty if not needed
def nextCourse(self,allCourses,schedInd):#schedInd is position in schedule. Needed for concurrency issues #to be implemented. see word doc #steps: #find largest fraction weighted course remaining #this assumes weights have been applied at the beginning of the program. validSubset = DankMath.listDiff(DankMath.listDiff(allCourses, self.coursesTaken), self.coursesTaking) crse = DankMath.maxValuedCourse(validSubset)#this should copy an object... do I need to worry about this? if(crse.prereqsSatisfied(self.coursesTaken,self.concurrentList,schedInd)): return crse else: return cres.nextUnsatReq(self.coursesTaken , self.coursesTaking, allCourses)
from SemesterSched import SemesterSched from Schedule import Schedule from Course2 import Course2 import DankMath c = Course2("ECE20000",[],"Some lame Course",0,1.0,["Fall","Spring"]) e = Course2("ECE20100",[],"Some lame Course",0,1.0,["Fall","Spring"]) print "woo" if c.isValid("Fall",[]) else "Boo" a = SemesterSched("Fall",2016,[],[],[c,e]) a.generateSem([]) d = Course2("ECE20000",[],"Some lame Course",0,1.0,["Fall","Spring"]) x = DankMath.listDiff([c,e],[d]) print x[0].title """class SubmitHandler(webapp2.RequestHandler): Submit Handler def get(self): SemsOnCampus = self.request.get("semesters") allCourses =[] for c in Course: allCourses.append(Course2(c.title,c.requisites,c.description,0,c.credits,c.semesters)) #Sched = Schedule(SemsOnCampus,DegreeType) #Sched.generateSched() Sems= [] for sem in SemsOnCampus: