Skip to content

Commit

Permalink
should be able to regenerate ok with existing schedule items
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://scheduler.csc.calpoly.edu/repo@2800 13b268f7-8392-4c9d-bc7d-1e80a86bc2f9
  • Loading branch information
snavarre committed May 21, 2012
1 parent 55463bc commit f603100
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
Binary file modified implementation/database.db
Binary file not shown.
21 changes: 18 additions & 3 deletions implementation/src/scheduler/model/algorithm/Generate.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ public static Vector<ScheduleItem> generate(Model model, Document document,
starttime = System.currentTimeMillis();

Vector<ScheduleItemDecorator> items = new Vector<ScheduleItemDecorator>();
for (ScheduleItem si : s_items)
items.add(new ScheduleItemDecorator(si));
Vector<ScheduleItem> temporaryItems = new Vector<ScheduleItem>();
for (ScheduleItem si : s_items) {
// if(si.getInstructor().equals(document.getChooseForMeInstructor())) {
// //temporaryItems.
// }
//else
items.add(new ScheduleItemDecorator(si));
}

HashMap<Integer, SectionTracker> sections = new HashMap<Integer, SectionTracker>();
TimeRange bounds = new TimeRange(14, 44);
Expand All @@ -65,7 +71,8 @@ public static Vector<ScheduleItem> generate(Model model, Document document,
//Generate labs from the course list
HashMap<Integer, Course> tetheredLabs = new HashMap<Integer, Course>();
ArrayList<Course> untetheredLabs = new ArrayList<Course>();
ArrayList<Course> indStudyCourses = new ArrayList<Course>();
ArrayList<Course> indStudyCourses = new ArrayList<Course>();

for (Course c : c_list) {

//Is a lab (or until a case found otherwise, an ACT or DIS) associated with a lecture
Expand Down Expand Up @@ -197,6 +204,14 @@ public static Vector<ScheduleItem> generate(Model model, Document document,
return result;
}

public static void findInstructorForScheduleItem() {

}

public static void findLocationforScheduleItem() {

}

/**
* Gets the SectionTracker associated with course 'c'. If no tracker yet
* exists for the Course, one is created and added.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.Collection;
import java.util.Vector;

import com.sun.xml.internal.bind.v2.model.core.ID;
import scheduler.model.Day;
import scheduler.model.Course;
import scheduler.model.Document;
import scheduler.model.Instructor;
Expand Down Expand Up @@ -50,10 +52,29 @@ public static Vector<ScheduleItem> generate(Model model, Document document, Coll
} catch (BadCourseDataException e) {
e.printStackTrace();
}

}

//how to defensively access components of a scheduleitem?

//check schedule items - note, this should never get the staff, choose for me or tba items since they'll never be
//in the given lists
for(InstructorDecorator id : insD)
for(ScheduleItem s: s_items)
if(id.equals(s.getInstructor())) {
//System.out.println("+++found the instructor+++ " + s.getInstructor().getFirstName());
//update the instructor decorator
id.addWTU(new Integer(s.getCourse().getWTUInt()));
//System.out.println("WTUs for id: " + id.getCurWTU());
TimeRange tmp = new TimeRange(s.getStartHalfHour(), s.getEndHalfHour());
id.getAvailability().book(new Week(s.getDays()), tmp);
//remove the course from the course collection, it's been scheduled
c_list.remove(s.getCourse());
}
//update the location but don't remove it
for(LocationDecorator ld : locD)
for(ScheduleItem s : s_items)
if(ld.equals(s.getLocation())) {
TimeRange tmp = new TimeRange(s.getStartHalfHour(), s.getEndHalfHour());
ld.getAvailability().book(new Week(s.getDays()), tmp);
}

return Generate.generate(model, document, s_items, c_list, insD, locD);
}
Expand Down Expand Up @@ -155,7 +176,7 @@ private static void checkValid(Course c) throws BadCourseDataException, Database

//there should be an extra reqt..it can't be higher than soemthing (check)

if(c.getNumHalfHoursPerWeek() == null || c.getNumHalfHoursPerWeekInt() <= 0)
if(c.getNumHalfHoursPerWeek() == null || c.getNumHalfHoursPerWeekInt() < 0)
throw new BadCourseDataException(BadCourseDataException.ConflictType.BAD_HHR_WEEK, c, "null or <= 0", "integer > 0");
//adding the reqt of 0 being valid. a course with 0 as max enrollment makes no sense to me
if(c.getMaxEnrollment() == null || c.getMaxEnrollmentInt() < 0)
Expand Down
2 changes: 1 addition & 1 deletion implementation/test/scheduler/model/AlgorithmTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void testThing() throws DatabaseException, BadInstructorDataExcept
for (ScheduleItem si : sis) {
System.err.println(si);
}

System.out.println("Second run with schedule items");
courses.addAll(generateAdditionalCourses(model, doc));
Vector<ScheduleItem> items = GenerateEntryPoint.generate(model, doc, sis, courses, instructors, locations);

Expand Down

0 comments on commit f603100

Please sign in to comment.