Search in sources :

Example 6 with SctAssignment

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;
}
Also used : TimeLocation(org.cpsolver.coursett.model.TimeLocation) HashMap(java.util.HashMap) Request(org.cpsolver.studentsct.model.Request) Enrollment(org.cpsolver.studentsct.model.Enrollment) Student(org.cpsolver.studentsct.model.Student) SctAssignment(org.cpsolver.studentsct.model.SctAssignment)

Aggregations

SctAssignment (org.cpsolver.studentsct.model.SctAssignment)6 Enrollment (org.cpsolver.studentsct.model.Enrollment)5 Request (org.cpsolver.studentsct.model.Request)5 HashSet (java.util.HashSet)4 TimeLocation (org.cpsolver.coursett.model.TimeLocation)4 Section (org.cpsolver.studentsct.model.Section)4 Student (org.cpsolver.studentsct.model.Student)4 DecimalFormat (java.text.DecimalFormat)3 BitSet (java.util.BitSet)3 Placement (org.cpsolver.coursett.model.Placement)3 RoomLocation (org.cpsolver.coursett.model.RoomLocation)3 DefaultSingleAssignment (org.cpsolver.ifs.assignment.DefaultSingleAssignment)3 DataProperties (org.cpsolver.ifs.util.DataProperties)3 DistanceConflict (org.cpsolver.studentsct.extension.DistanceConflict)3 TimeOverlapsCounter (org.cpsolver.studentsct.extension.TimeOverlapsCounter)3 Config (org.cpsolver.studentsct.model.Config)3 Course (org.cpsolver.studentsct.model.Course)3 CourseRequest (org.cpsolver.studentsct.model.CourseRequest)3 Offering (org.cpsolver.studentsct.model.Offering)3 Subpart (org.cpsolver.studentsct.model.Subpart)3