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