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;
}
Aggregations