|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
scheduler.generate.Schedule
public class Schedule
Contains the methods for generating a schedule. Most of the "magic" behind this class is hidden under the mask of the Generate_ui class. Thus, much of what is contained here is "under the hood". Furthermore, this class does not contain any of its own: all its information will come from the external, all-powerful database(s).
Field Summary | |
---|---|
protected java.util.LinkedList<Course> |
cList
Records how many courses are in the schedule (not number of sections) |
private java.util.Hashtable<Instructor,WeekAvail> |
iBookings
Used to keep track of when instructors are booked |
protected java.util.LinkedList<Instructor> |
iList
Records how many instructors are in the schedule |
private java.util.Hashtable<Location,WeekAvail> |
lBookings
Used to keep track of when rooms are booked |
protected java.util.LinkedList<Location> |
lList
Records how many locations are in the schedule |
java.util.Vector<ScheduleItem> |
s
The generated schedule |
java.util.Vector<ScheduleItem> |
TBAs
List of courses that had TBA locations. |
java.util.Hashtable<Instructor,Treatment> |
treatment
What courses, times, and WTU's an instructor had been assigned |
Constructor Summary | |
---|---|
Schedule()
Creates an empty schedule. |
|
Schedule(java.util.Collection<ScheduleItem> s)
Creates a schedule from a given vector of ScheduleItem's. |
Method Summary | |
---|---|
boolean |
add(ScheduleItem si)
Overrides "add", so as to put courses into the instance variable "cList" when appropriate. |
private static void |
book(WeekAvail a,
Week days,
Time start,
Time end)
Books a span of time over a set of days in a hash (indexed by numerical days) of availabilities. |
private static boolean |
check(WeekAvail a,
Week days,
Time start,
Time end)
Checks whether a given hash of availability has a given span of free time. |
private ScheduleItem |
createSI(Instructor i,
Course c,
ScheduledLocation l)
Creates a ScheduleItem. |
private Time |
endForLec(Time s,
int numOfDays)
|
private Time |
endForLecLab(Time s,
int numOfDays)
|
private Course |
findCourse(java.util.LinkedList<Course> cdb,
java.util.LinkedList<Instructor> idb,
Instructor i)
Finds the most suitable course for a given instructor to teach. |
private void |
findCourseCheckPre(java.util.LinkedList cdb,
java.util.LinkedList idb,
Instructor i)
Checks the preconditions for "findIdealCourse(...)" and throws appropriate exceptions. |
private ScheduledLocation |
findLoc(java.util.LinkedList<Location> ldb,
DaysAndTime dat,
Course c)
Finds a location for a given course for a given list of available days/times. |
private java.util.Vector<ScheduledLocation> |
findLocation(java.util.LinkedList<Location> ldb,
java.util.Vector<java.util.Vector<DaysAndTime>> times,
Course c)
Finds the location for a course and, if it has one, its labs. |
private java.util.Vector<java.util.Vector<DaysAndTime>> |
findTime(java.util.LinkedList<Course> cdb,
Instructor i,
Course c)
Finds a suitable time to apply to section |
private void |
findTimeCheckPre(java.util.LinkedList<Course> cdb,
Course c)
Checks preconditions regarding courses for the "findTime" method. |
void |
generate(java.util.LinkedList<Course> cdb,
java.util.LinkedList<Instructor> idb,
java.util.LinkedList<Location> ldb)
Generates a schedule. |
java.util.LinkedList<Course> |
getCourseList()
Returns the list of courses. |
java.util.LinkedList<Instructor> |
getInstructorList()
Returns the list of instructors. |
java.util.LinkedList<Location> |
getLocationList()
Returns the list of locations. |
private java.util.Vector<java.util.Vector<DaysAndTime>> |
getTimeForLec(java.util.ArrayList<TimePreference> tPrefs,
Instructor i)
Schedules days and times for 4-unit courses with no lab. |
private java.util.Vector<java.util.Vector<DaysAndTime>> |
getTimeForLecWithLab(java.util.ArrayList<TimePreference> tPrefs,
Instructor i)
Schedules days and times for 4-unit courses which have a lab. |
private void |
reset()
Resets all data particular to the schedule. |
private void |
updateRecords(ScheduleItem si)
Updates the c, i, and l lists for a given schedule item, along with the instructor's "treatment". |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.util.Hashtable<Instructor,Treatment> treatment
public java.util.Vector<ScheduleItem> s
public java.util.Vector<ScheduleItem> TBAs
private java.util.Hashtable<Location,WeekAvail> lBookings
private java.util.Hashtable<Instructor,WeekAvail> iBookings
protected java.util.LinkedList<Course> cList
protected java.util.LinkedList<Instructor> iList
protected java.util.LinkedList<Location> lList
Constructor Detail |
---|
public Schedule()
public Schedule(java.util.Collection<ScheduleItem> s)
s
- Vector of ScheduleItem's to create a schedule from.Method Detail |
---|
public java.util.LinkedList<Course> getCourseList()
Post: //Returned list must be equal to "cList" return.equals(this.cList)
public java.util.LinkedList<Instructor> getInstructorList()
Post: //Returned list must be equal to "iList" return.equals(this.iList)
public java.util.LinkedList<Location> getLocationList()
Post: //Returned list must be equal to "lList" return.equals(this.lList)
public void generate(java.util.LinkedList<Course> cdb, java.util.LinkedList<Instructor> idb, java.util.LinkedList<Location> ldb)
cdb
- The list of courses to scheduleidb
- The list of instructors with which to teach the coursesldb
- The list of location in which to teach the coursesprivate void reset()
private Course findCourse(java.util.LinkedList<Course> cdb, java.util.LinkedList<Instructor> idb, Instructor i) throws NullCourseDatabaseException, EmptyCourseDatabaseException, NullInstructorException, InstructorNotInDatabaseException, InstructorWTUMaxedException, InstructorCanTeachNothingException
cdb
- Database of coursesidb
- Database of instructorsi
- The instructor to select for
// **Pre and Post conditions** // Pre: //The course database cannot be null db.coursedb != null && //The course database must have at least one entry db.courseDB.getSize() > 0 && //Instructor cannot be null instructor != null && //Instructor must be in the instructor database db.instructorDB.isValidInstructor(instructor) && //Instructor "i" has a Treatment entry in the treatment hash Generate.treatment.get(i) != null Post: //The class returned must be one the instructor is "qualified" to teach instructor.getPref(return) > 0 && //The returned class must be in the course database cdb.contains(return) && //The returned class must not push the instructor over his max WTU //count treatment.get(i).wtu + return.getWTU() <= instructor.getMaxWTU()
NullCourseDatabaseException
EmptyCourseDatabaseException
NullInstructorException
InstructorNotInDatabaseException
InstructorWTUMaxedException
InstructorCanTeachNothingException
private void findCourseCheckPre(java.util.LinkedList cdb, java.util.LinkedList idb, Instructor i) throws NullCourseDatabaseException, EmptyCourseDatabaseException, NullInstructorException, InstructorNotInDatabaseException, InstructorWTUMaxedException, InstructorCanTeachNothingException
cdb
- The course databaseidb
- The instructor databasei
- The instructor
NullCourseDatabaseException
EmptyCourseDatabaseException
NullInstructorException
InstructorNotInDatabaseException
InstructorWTUMaxedException
InstructorCanTeachNothingException
private java.util.Vector<java.util.Vector<DaysAndTime>> findTime(java.util.LinkedList<Course> cdb, Instructor i, Course c) throws NullCourseException, CourseNotInDatabaseException
i
- The instructor to use in searchc
- The course that is being used to search for a time
// ** Pre and Post conditions ** // Pre: // Instructor value can not be null i != nil && // Course value can not be null c != nil && //Instructor must be in the instructor database db.instructorDB.isValidInstructor(i) && // Course must be in the course database db.coursedb.isValidCourse(c) Post: //The returned time must not conflict with instructors teaching times db.instructorDB.isValidTime(instructor,time) && //The returned time must not violate any schedule attributes scheduler.isValidTime(time)
NullCourseException
CourseNotInDatabaseException
private void findTimeCheckPre(java.util.LinkedList<Course> cdb, Course c) throws NullCourseException, CourseNotInDatabaseException
cdb
- The course databasec
- The course being scheduled
NullCourseException
CourseNotInDatabaseException
private java.util.Vector<java.util.Vector<DaysAndTime>> getTimeForLecWithLab(java.util.ArrayList<TimePreference> tPrefs, Instructor i)
tPrefs
- The list of the instructor's time preference.i
- The instructor to schedule.
private java.util.Vector<java.util.Vector<DaysAndTime>> getTimeForLec(java.util.ArrayList<TimePreference> tPrefs, Instructor i)
tPrefs
- The list of the instructor's time preference.i
- The instructor to schedule.
private Time endForLecLab(Time s, int numOfDays)
private Time endForLec(Time s, int numOfDays)
private java.util.Vector<ScheduledLocation> findLocation(java.util.LinkedList<Location> ldb, java.util.Vector<java.util.Vector<DaysAndTime>> times, Course c)
ldb
- List of locations to trytime
- List of day/time combinations to tryc
- The course to find a location for (contains its lab, if any).
private ScheduledLocation findLoc(java.util.LinkedList<Location> ldb, DaysAndTime dat, Course c)
ldb
- List of locations to trytimes
- Day/time combination to tryc
- The course to put in the returned location.
private ScheduleItem createSI(Instructor i, Course c, ScheduledLocation l)
i
- The instructorc
- The coursel
- The location and day/time pair
public boolean add(ScheduleItem si)
si
- ScheduleItem to add
Pre: //Can't add a null ScheduleItem. Note, the exception for this //should already be caught in the "super"'s "add" si != null && //"si" cannot double book a room for (Integer d: lBookings.get(si.l).keySet()) { if (days[d]) { lBookings.get(si.l).get(d).isFree(si.start, si.end)) } } && //"si" cannot put an instructor in two places at the same time for (Integer d: iBookings.get(si.i).keySet()) { if (days[d]) { iBookings.get(si.l).get(d).isFree(si.start, si.end)) } } Post: //Only thing different about old schedule and new schedule is "si" for (ScheduleItem si': s')) { if (!s.contains(si') { si == si'; } }
private static boolean check(WeekAvail a, Week days, Time start, Time end)
a
- Hash of availabilitydays
- Days to consider for span of availabilitystart
- Beginning of the given span of timeend
- End of the given span of time
private static void book(WeekAvail a, Week days, Time start, Time end)
a
- Hash of availabilitiesdays
- Set of daysstart
- Beginning of span of timeend
- End of span of timeprivate void updateRecords(ScheduleItem si)
si
- The ScheduleItem containing all the information needed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |