Search in sources :

Example 6 with RoomConstraint

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);
    }
}
Also used : RoomConstraint(org.cpsolver.coursett.constraint.RoomConstraint) DepartmentSpreadConstraint(org.cpsolver.coursett.constraint.DepartmentSpreadConstraint) InstructorConstraint(org.cpsolver.coursett.constraint.InstructorConstraint) SpreadConstraint(org.cpsolver.coursett.constraint.SpreadConstraint) GroupConstraint(org.cpsolver.coursett.constraint.GroupConstraint) Constraint(org.cpsolver.ifs.model.Constraint) RoomConstraint(org.cpsolver.coursett.constraint.RoomConstraint) JenrlConstraint(org.cpsolver.coursett.constraint.JenrlConstraint)

Aggregations

RoomConstraint (org.cpsolver.coursett.constraint.RoomConstraint)6 HashSet (java.util.HashSet)5 GroupConstraint (org.cpsolver.coursett.constraint.GroupConstraint)5 InstructorConstraint (org.cpsolver.coursett.constraint.InstructorConstraint)5 SpreadConstraint (org.cpsolver.coursett.constraint.SpreadConstraint)5 Lecture (org.cpsolver.coursett.model.Lecture)5 Placement (org.cpsolver.coursett.model.Placement)5 Constraint (org.cpsolver.ifs.model.Constraint)5 DepartmentSpreadConstraint (org.cpsolver.coursett.constraint.DepartmentSpreadConstraint)4 JenrlConstraint (org.cpsolver.coursett.constraint.JenrlConstraint)4 RoomLocation (org.cpsolver.coursett.model.RoomLocation)4 Student (org.cpsolver.coursett.model.Student)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 TreeSet (java.util.TreeSet)3 TimeLocation (org.cpsolver.coursett.model.TimeLocation)3 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 BitSet (java.util.BitSet)2