def setData(self, courses_path, rooms_path, no_conflicts_path, b2b_path): """Populate the optimizer""" self.isBuilt = False try: self.rooms = readData.importRoomInventory(rooms_path) no_conflicts = readData.importNoConflictGroups(no_conflicts_path) self.courses = readData.importCourses(courses_path, self.rooms) b2b_pairs = readData.importB2BPairs(b2b_path, self.courses) self.optimizer = opt.Optimizer(self.courses, self.rooms, config.Options(), no_conflicts, quiet=self.quiet, b2b_pairs = b2b_pairs) except ses.SESError as e: print e pub.sendMessage("status_bar.error", str(e)) except Exception as e: print e pub.sendMessage("status_bar.error", str(e)) else: self.resetCourses() pub.sendMessage("data_loaded")
def main(): room_inventory = readData.importRoomInventory( "DataFiles/roomInventory.csv") ts1 = ses.TimeSlot("F", "W", "4:00 PM", "7:00 PM") course1 = ses.Course("15.051", "Economics", 58, ses.Instructor("Arnie"), ts1) rooms = allowedRooms(course1, room_inventory) print len(rooms), len(room_inventory) print min([r.capacity for r in rooms]) course1.addRoomPrefs((ses.Room("E62-223", 100), ), True) rooms = allowedRooms(course1, room_inventory) print len(rooms), len(room_inventory) print rooms[0] viable_times = allowedTimes(course1, []) print len(viable_times) #some sanity checks assert (ts1 in viable_times) for ts in viable_times: assert (course1.isViableTime(ts)) print ts #all times all_times = genAllTimeSlots() for t in all_times: print t
def main(): room_inventory = readData.importRoomInventory("DataFiles/roomInventory.csv") ts1 = ses.TimeSlot("F", "W", "4:00 PM", "7:00 PM") course1 = ses.Course("15.051", "Economics", 58, ses.Instructor("Arnie"), ts1) rooms = allowedRooms(course1, room_inventory) print len(rooms), len(room_inventory) print min([r.capacity for r in rooms]) course1.addRoomPrefs((ses.Room("E62-223", 100),), True) rooms = allowedRooms(course1, room_inventory) print len(rooms), len(room_inventory) print rooms[0] viable_times = allowedTimes(course1, []) print len(viable_times) #some sanity checks assert(ts1 in viable_times) for ts in viable_times: assert(course1.isViableTime(ts)) print ts #all times all_times = genAllTimeSlots() for t in all_times: print t
def setData(self, courses_path, rooms_path, no_conflicts_path, b2b_path): """Populate the optimizer""" self.isBuilt = False try: self.rooms = readData.importRoomInventory(rooms_path) no_conflicts = readData.importNoConflictGroups(no_conflicts_path) self.courses = readData.importCourses(courses_path, self.rooms) b2b_pairs = readData.importB2BPairs(b2b_path, self.courses) self.optimizer = opt.Optimizer(self.courses, self.rooms, config.Options(), no_conflicts, quiet=self.quiet, b2b_pairs=b2b_pairs) except ses.SESError as e: print e pub.sendMessage("status_bar.error", str(e)) except Exception as e: print e pub.sendMessage("status_bar.error", str(e)) else: self.resetCourses() pub.sendMessage("data_loaded")
def main(): #read in sample set of courses and inventory rooms = readData.importRoomInventory("./DataFiles/roomInventory.csv") courses = readData.importCourses("./DataFiles/F10c.csv", rooms) courses = readData.addAssignments(courses, rooms, "./DataFiles/F10_Final.csv") writeData(courses, roomInventory, "grid")
def test_breakout_partner(self): """Ensures we throw if recitation missing a parnter lecture""" roomInventory = readData.importRoomInventory( "./TestFiles/roominventory1.csv") self.assertRaises(SESError, readData.importCourses, "./TestFiles/breakout_no_partner1.csv", roomInventory)
def main(): """Analyze requests and output to tab-delimited txt file.""" rooms = readData.importRoomInventory("./F10_DataFiles/roomInventory.csv") courses = readData.importCourses("./F10_DataFiles/courseRequests.csv", rooms) courses = readData.addAssignments(courses, rooms, "./F10_DataFiles/Assignments.csv") #preferences types #Dept results = cc.countTypes(courses, lambda c: c.dept) plotTypeCount(results)
def main(): if len(sys.argv) <> 5: print "Inputs -roompath -courses_path - noConflict_path - back2back_path" sys.exit() #VG Change this to command line arguments room_path, courses_path, groups_path, b2b_path = tuple(sys.argv[1:]) #Building objects rooms = importRoomInventory(room_path) courses = importCourses(courses_path, rooms) config_details = config.Options() no_conflicts = importNoConflictGroups(groups_path) back_to_back = importB2BPairs(b2b_path, courses) #building optimization optimizer = opt.Optimizer(courses, rooms, config_details, no_conflicts, quiet=True, b2b_pairs = back_to_back) optimizer.build() #some optimization details print "Rooms \t %d" % len(rooms) print "Courses \t %d" % len(courses) print "Time Slots \t %d" % len(optimizer.allTimeSlots) #solve print "------ Solution 1 -------" optimizer.updateObjFcnAndSolve([10, 0, 0], pref_weight=1, e_cap_weight=0, congestion_weight=0, dept_fairness=0.0, b2b_weight = 1.0) #Debugging #optimizer.writeLP("debug_lp.lp") print "\n \n Max Cong:\t%d" % optimizer.getMaxCong() courses = optimizer.retrieveAssignment() courses_with_break = set([c.number + c.section for c in courses if c.isBreakout()] ) for sCourse in courses_with_break: filt = lambda c : c.number + c.section == sCourse courses_filt = filter(filt, courses) for c in courses_filt: if c.number + c.section == "15.665A": print "%s \t %s \t %s" % (c, c.assignedTime, c.assignedRoom) #solve print "------ Solution 2 -------" optimizer.updateObjFcnAndSolve([10, 5, 1], pref_weight=10, e_cap_weight=1, congestion_weight=1, dept_fairness=5, b2b_weight = 1.0) # # print "Excess Cap: \t", # f_ecap = lambda c: helpers.e_cap(c, c.assignedRoom) # e_caps = map(f_ecap, courses) # print 100 * sum(e_caps)/len(e_caps) # # print "Prefs: \n" # print cc.countTypes(courses, lambda c: c.gotRoomPref() ) # print cc.countTypes(courses, lambda c: c.gotTimePref() ) # # print "Fairness: \n" # results = getDeptScores(courses, optimizer, [10, 0, 0]) # for k in results.keys(): # print k, sum(results[k]) # for course in courses: # print "%s \t %s \t %s" % (course, course.assignedTime, course.assignedRoom) # course_times = [c.assignedTime for c in courses] # results = cc.createHeatMap(course_times, time_grid, "H1") # cc.outputHeatMap(results, time_grid) print "\n \n"
def test_duplicate_course(self): """Throw an error if try to add the same course twice.""" roomInventory = readData.importRoomInventory( "./TestFiles/roominventory1.csv") self.assertRaises(SESError, readData.importCourses, "./TestFiles/course_twice1.csv", roomInventory)
def test_breakout_partner(self): """Ensures we throw if recitation missing a parnter lecture""" roomInventory = readData.importRoomInventory("./TestFiles/roominventory1.csv") self.assertRaises(SESError, readData.importCourses, "./TestFiles/breakout_no_partner1.csv", roomInventory)
def test_duplicate_course(self): """Throw an error if try to add the same course twice.""" roomInventory = readData.importRoomInventory("./TestFiles/roominventory1.csv") self.assertRaises(SESError, readData.importCourses, "./TestFiles/course_twice1.csv", roomInventory)
def main(): if len(sys.argv) <> 5: print "Inputs -roompath -courses_path - noConflict_path - back2back_path" sys.exit() #VG Change this to command line arguments room_path, courses_path, groups_path, b2b_path = tuple(sys.argv[1:]) #Building objects rooms = importRoomInventory(room_path) courses = importCourses(courses_path, rooms) config_details = config.Options() no_conflicts = importNoConflictGroups(groups_path) back_to_back = importB2BPairs(b2b_path, courses) #building optimization optimizer = opt.Optimizer(courses, rooms, config_details, no_conflicts, quiet=True, b2b_pairs=back_to_back) optimizer.build() #some optimization details print "Rooms \t %d" % len(rooms) print "Courses \t %d" % len(courses) print "Time Slots \t %d" % len(optimizer.allTimeSlots) #solve print "------ Solution 1 -------" optimizer.updateObjFcnAndSolve([10, 0, 0], pref_weight=1, e_cap_weight=0, congestion_weight=0, dept_fairness=0.0, b2b_weight=1.0) #Debugging #optimizer.writeLP("debug_lp.lp") print "\n \n Max Cong:\t%d" % optimizer.getMaxCong() courses = optimizer.retrieveAssignment() courses_with_break = set( [c.number + c.section for c in courses if c.isBreakout()]) for sCourse in courses_with_break: filt = lambda c: c.number + c.section == sCourse courses_filt = filter(filt, courses) for c in courses_filt: if c.number + c.section == "15.665A": print "%s \t %s \t %s" % (c, c.assignedTime, c.assignedRoom) #solve print "------ Solution 2 -------" optimizer.updateObjFcnAndSolve([10, 5, 1], pref_weight=10, e_cap_weight=1, congestion_weight=1, dept_fairness=5, b2b_weight=1.0) # # print "Excess Cap: \t", # f_ecap = lambda c: helpers.e_cap(c, c.assignedRoom) # e_caps = map(f_ecap, courses) # print 100 * sum(e_caps)/len(e_caps) # # print "Prefs: \n" # print cc.countTypes(courses, lambda c: c.gotRoomPref() ) # print cc.countTypes(courses, lambda c: c.gotTimePref() ) # # print "Fairness: \n" # results = getDeptScores(courses, optimizer, [10, 0, 0]) # for k in results.keys(): # print k, sum(results[k]) # for course in courses: # print "%s \t %s \t %s" % (course, course.assignedTime, course.assignedRoom) # course_times = [c.assignedTime for c in courses] # results = cc.createHeatMap(course_times, time_grid, "H1") # cc.outputHeatMap(results, time_grid) print "\n \n"