Search in sources :

Example 21 with InstructorConstraint

use of org.cpsolver.coursett.constraint.InstructorConstraint in project cpsolver by UniTime.

the class Placement method getNotValidReason.

public String getNotValidReason(Assignment<Lecture, Placement> assignment, boolean useAmPm) {
    Lecture lecture = variable();
    String reason = lecture.getNotValidReason(assignment, this, useAmPm);
    if (reason != null)
        return reason;
    for (InstructorConstraint ic : lecture.getInstructorConstraints()) {
        if (!ic.isAvailable(lecture, this) && ic.isHard()) {
            if (!ic.isAvailable(lecture, getTimeLocation())) {
                for (Placement c : ic.getUnavailabilities()) {
                    if (c.getTimeLocation().hasIntersection(getTimeLocation()) && !lecture.canShareRoom(c.variable()))
                        return "instructor " + ic.getName() + " not available at " + getTimeLocation().getLongName(useAmPm) + " due to " + c.variable().getName();
                }
                return "instructor " + ic.getName() + " not available at " + getTimeLocation().getLongName(useAmPm);
            } else
                return "placement " + getTimeLocation().getLongName(useAmPm) + " " + getRoomName(", ") + " is too far for instructor " + ic.getName();
        }
    }
    if (lecture.getNrRooms() > 0) {
        if (isMultiRoom()) {
            for (RoomLocation roomLocation : getRoomLocations()) {
                if (roomLocation.getRoomConstraint() != null && !roomLocation.getRoomConstraint().isAvailable(lecture, getTimeLocation(), lecture.getScheduler())) {
                    if (roomLocation.getRoomConstraint().getAvailableArray() != null) {
                        for (Enumeration<Integer> e = getTimeLocation().getSlots(); e.hasMoreElements(); ) {
                            int slot = e.nextElement();
                            if (roomLocation.getRoomConstraint().getAvailableArray()[slot] != null) {
                                for (Placement c : roomLocation.getRoomConstraint().getAvailableArray()[slot]) {
                                    if (c.getTimeLocation().hasIntersection(getTimeLocation()) && !lecture.canShareRoom(c.variable())) {
                                        return "room " + roomLocation.getName() + " not available at " + getTimeLocation().getLongName(useAmPm) + " due to " + c.variable().getName();
                                    }
                                }
                            }
                        }
                    }
                    return "room " + roomLocation.getName() + " not available at " + getTimeLocation().getLongName(useAmPm);
                }
            }
        } else {
            if (getRoomLocation().getRoomConstraint() != null && !getRoomLocation().getRoomConstraint().isAvailable(lecture, getTimeLocation(), lecture.getScheduler()))
                if (getRoomLocation().getRoomConstraint().getAvailableArray() != null) {
                    for (Enumeration<Integer> e = getTimeLocation().getSlots(); e.hasMoreElements(); ) {
                        int slot = e.nextElement();
                        if (getRoomLocation().getRoomConstraint().getAvailableArray()[slot] != null) {
                            for (Placement c : getRoomLocation().getRoomConstraint().getAvailableArray()[slot]) {
                                if (c.getTimeLocation().hasIntersection(getTimeLocation()) && !lecture.canShareRoom(c.variable())) {
                                    return "room " + getRoomLocation().getName() + " not available at " + getTimeLocation().getLongName(useAmPm) + " due to " + c.variable().getName();
                                }
                            }
                        }
                    }
                }
            return "room " + getRoomLocation().getName() + " not available at " + getTimeLocation().getLongName(useAmPm);
        }
    }
    return reason;
}
Also used : Enumeration(java.util.Enumeration) InstructorConstraint(org.cpsolver.coursett.constraint.InstructorConstraint) SpreadConstraint(org.cpsolver.coursett.constraint.SpreadConstraint) GroupConstraint(org.cpsolver.coursett.constraint.GroupConstraint) InstructorConstraint(org.cpsolver.coursett.constraint.InstructorConstraint)

Aggregations

InstructorConstraint (org.cpsolver.coursett.constraint.InstructorConstraint)21 Lecture (org.cpsolver.coursett.model.Lecture)14 HashSet (java.util.HashSet)10 Placement (org.cpsolver.coursett.model.Placement)8 Student (org.cpsolver.coursett.model.Student)8 GroupConstraint (org.cpsolver.coursett.constraint.GroupConstraint)7 SpreadConstraint (org.cpsolver.coursett.constraint.SpreadConstraint)7 HashMap (java.util.HashMap)5 TreeSet (java.util.TreeSet)5 DepartmentSpreadConstraint (org.cpsolver.coursett.constraint.DepartmentSpreadConstraint)5 JenrlConstraint (org.cpsolver.coursett.constraint.JenrlConstraint)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ClassLimitConstraint (org.cpsolver.coursett.constraint.ClassLimitConstraint)4 RoomConstraint (org.cpsolver.coursett.constraint.RoomConstraint)4 SoftInstructorConstraint (org.cpsolver.coursett.constraint.SoftInstructorConstraint)4 Constraint (org.cpsolver.ifs.model.Constraint)4 BitSet (java.util.BitSet)3 FlexibleConstraint (org.cpsolver.coursett.constraint.FlexibleConstraint)3 RoomLocation (org.cpsolver.coursett.model.RoomLocation)3