diff --git a/src/org/cpsolver/exam/model/ExamModel.java b/src/org/cpsolver/exam/model/ExamModel.java index 95dbcac1..13ce94db 100644 --- a/src/org/cpsolver/exam/model/ExamModel.java +++ b/src/org/cpsolver/exam/model/ExamModel.java @@ -571,6 +571,8 @@ public Document save(Assignment assignment) { r.addAttribute("name", room.getName()); r.addAttribute("size", String.valueOf(room.getSize())); r.addAttribute("alt", String.valueOf(room.getAltSize())); + if (!room.isHard()) + r.addAttribute("hard", "false"); if (room.getCoordX() != null && room.getCoordY() != null) r.addAttribute("coordinates", room.getCoordX() + "," + room.getCoordY()); for (ExamPeriod period : getPeriods()) { @@ -868,6 +870,7 @@ else if (root.attribute("initiative") != null) Integer.parseInt(e.attributeValue("size")), Integer.parseInt(e.attributeValue("alt")), (coords == null ? null : Double.valueOf(coords.substring(0, coords.indexOf(',')))), (coords == null ? null : Double.valueOf(coords.substring(coords.indexOf(',') + 1)))); + room.setHard("true".equalsIgnoreCase(e.attributeValue("hard", "true"))); addConstraint(room); getRooms().add(room); rooms.put(new Long(room.getId()), room); diff --git a/src/org/cpsolver/exam/model/ExamRoom.java b/src/org/cpsolver/exam/model/ExamRoom.java index 8a8b0bfd..39fd7218 100644 --- a/src/org/cpsolver/exam/model/ExamRoom.java +++ b/src/org/cpsolver/exam/model/ExamRoom.java @@ -44,6 +44,7 @@ public class ExamRoom extends ConstraintWithContext iDistanceCache = new HashMap(); /** * Distance between two rooms. See {@link DistanceMetric} @@ -226,6 +232,7 @@ public ExamRoomSharing getRoomSharing() { */ @Override public void computeConflicts(Assignment assignment, ExamPlacement p, Set conflicts) { + if (!isHard()) return; if (!p.contains(this)) return; if (getRoomSharing() == null) { @@ -243,6 +250,7 @@ public void computeConflicts(Assignment assignment, ExamPla */ @Override public boolean inConflict(Assignment assignment, ExamPlacement p) { + if (!isHard()) return false; if (!p.contains(this)) return false; if (getRoomSharing() == null) { @@ -259,7 +267,7 @@ public boolean inConflict(Assignment assignment, ExamPlacem */ @Override public boolean isConsistent(ExamPlacement p1, ExamPlacement p2) { - return (p1.getPeriod() != p2.getPeriod() || !p1.contains(this) || !p2.contains(this)); + return !isHard() || (p1.getPeriod() != p2.getPeriod() || !p1.contains(this) || !p2.contains(this)); } /**