use of org.cpsolver.studentsct.model.SctAssignment in project cpsolver by UniTime.
the class OverlapCheck method check.
/**
* Check for overlapping sections that are attended by the same student
* @param a current assignment
* @return false, if there is such a case
*/
public boolean check(Assignment<Request, Enrollment> a) {
sLog.info("Checking for overlaps...");
boolean ret = true;
for (Student student : getModel().getStudents()) {
HashMap<TimeLocation, SctAssignment> times = new HashMap<TimeLocation, SctAssignment>();
for (Request request : student.getRequests()) {
Enrollment enrollment = a.getValue(request);
if (enrollment == null)
continue;
for (SctAssignment assignment : enrollment.getAssignments()) {
if (assignment.getTime() == null)
continue;
for (TimeLocation time : times.keySet()) {
if (time.hasIntersection(assignment.getTime())) {
sLog.error("Student " + student + " assignment " + assignment + " overlaps with " + times.get(time));
ret = false;
}
}
times.put(assignment.getTime(), assignment);
}
}
}
return ret;
}
Aggregations