use of org.cpsolver.coursett.constraint.RoomConstraint in project cpsolver by UniTime.
the class Test method printRoomInfo.
/** Print room utilization
* @param pw writer
* @param model problem model
* @param assignment current assignment
**/
public static void printRoomInfo(PrintWriter pw, TimetableModel model, Assignment<Lecture, Placement> assignment) {
pw.println("Room info:");
pw.println("id, name, size, used_day, used_total");
int firstDaySlot = model.getProperties().getPropertyInt("General.FirstDaySlot", Constants.DAY_SLOTS_FIRST);
int lastDaySlot = model.getProperties().getPropertyInt("General.LastDaySlot", Constants.DAY_SLOTS_LAST);
int firstWorkDay = model.getProperties().getPropertyInt("General.FirstWorkDay", 0);
int lastWorkDay = model.getProperties().getPropertyInt("General.LastWorkDay", Constants.NR_DAYS_WEEK - 1);
for (RoomConstraint rc : model.getRoomConstraints()) {
int used_day = 0;
int used_total = 0;
for (int day = firstWorkDay; day <= lastWorkDay; day++) {
for (int time = firstDaySlot; time <= lastDaySlot; time++) {
if (!rc.getContext(assignment).getPlacements(day * Constants.SLOTS_PER_DAY + time).isEmpty())
used_day++;
}
}
for (int day = 0; day < Constants.DAY_CODES.length; day++) {
for (int time = 0; time < Constants.SLOTS_PER_DAY; time++) {
if (!rc.getContext(assignment).getPlacements(day * Constants.SLOTS_PER_DAY + time).isEmpty())
used_total++;
}
}
pw.println(rc.getResourceId() + "," + rc.getName() + "," + rc.getCapacity() + "," + used_day + "," + used_total);
}
}
Aggregations