Search in sources :

Example 1 with ExamRoom

use of org.cpsolver.exam.model.ExamRoom in project cpsolver by UniTime.

the class ExamRoomSchedule method report.

public CSVFile report(Assignment<Exam, ExamPlacement> assignment) {
    CSVFile csv = new CSVFile();
    csv.setHeader(new CSVField[] { new CSVField("Room"), new CSVField("Cap"), new CSVField("AltCap"), new CSVField("Period"), new CSVField("Date"), new CSVField("Time"), new CSVField("Exam"), new CSVField("Enrl") });
    List<ExamRoom> rooms = new ArrayList<ExamRoom>(iModel.getRooms());
    Collections.sort(rooms, new Comparator<ExamRoom>() {

        @Override
        public int compare(ExamRoom r1, ExamRoom r2) {
            int cmp = -Double.compare(r1.getSize(), r2.getSize());
            if (cmp != 0)
                return cmp;
            cmp = -Double.compare(r1.getAltSize(), r2.getAltSize());
            if (cmp != 0)
                return cmp;
            return r1.compareTo(r2);
        }
    });
    for (ExamRoom room : rooms) {
        boolean first = true;
        int day = -1;
        for (ExamPeriod period : iModel.getPeriods()) {
            for (ExamPlacement placement : room.getPlacements(assignment, period)) {
                Exam exam = placement.variable();
                csv.addLine(new CSVField[] { new CSVField(first ? room.getName() : ""), new CSVField(first ? "" + room.getSize() : ""), new CSVField(first ? "" + room.getAltSize() : ""), new CSVField(period.getIndex() + 1), new CSVField(day == period.getDay() ? "" : period.getDayStr()), new CSVField(period.getTimeStr()), new CSVField(exam.getName()), new CSVField(exam.getStudents().size()) });
                first = false;
                day = period.getDay();
            }
        }
    }
    return csv;
}
Also used : ExamPeriod(org.cpsolver.exam.model.ExamPeriod) CSVFile(org.cpsolver.ifs.util.CSVFile) ExamRoom(org.cpsolver.exam.model.ExamRoom) CSVField(org.cpsolver.ifs.util.CSVFile.CSVField) ExamPlacement(org.cpsolver.exam.model.ExamPlacement) ArrayList(java.util.ArrayList) Exam(org.cpsolver.exam.model.Exam)

Aggregations

ArrayList (java.util.ArrayList)1 Exam (org.cpsolver.exam.model.Exam)1 ExamPeriod (org.cpsolver.exam.model.ExamPeriod)1 ExamPlacement (org.cpsolver.exam.model.ExamPlacement)1 ExamRoom (org.cpsolver.exam.model.ExamRoom)1 CSVFile (org.cpsolver.ifs.util.CSVFile)1 CSVField (org.cpsolver.ifs.util.CSVFile.CSVField)1