Search in sources :

Example 11 with CSVField

use of org.cpsolver.ifs.util.CSVFile.CSVField in project cpsolver by UniTime.

the class ExamRoomSplit method report.

/**
     * generate report
     * @param assignment current assignment
     * @return resultant report
     */
public CSVFile report(Assignment<Exam, ExamPlacement> assignment) {
    CSVFile csv = new CSVFile();
    csv.setHeader(new CSVField[] { new CSVField("Exam"), new CSVField("Enrl"), new CSVField("Period"), new CSVField("Date"), new CSVField("Time"), new CSVField("Room 1"), new CSVField("Cap 1"), new CSVField("Room 2"), new CSVField("Cap 2"), new CSVField("Room 3"), new CSVField("Cap 3"), new CSVField("Room 4"), new CSVField("Cap 4") });
    for (Exam exam : iModel.variables()) {
        ExamPlacement placement = assignment.getValue(exam);
        if (placement == null || placement.getRoomPlacements().size() <= 1)
            continue;
        List<CSVField> fields = new ArrayList<CSVField>();
        fields.add(new CSVField(exam.getName()));
        fields.add(new CSVField(exam.getStudents().size()));
        fields.add(new CSVField(placement.getPeriod().getIndex() + 1));
        fields.add(new CSVField(placement.getPeriod().getDayStr()));
        fields.add(new CSVField(placement.getPeriod().getTimeStr()));
        TreeSet<ExamRoomPlacement> rooms = new TreeSet<ExamRoomPlacement>(new ExamRoomComparator(exam, false));
        rooms.addAll(placement.getRoomPlacements());
        for (ExamRoomPlacement room : rooms) {
            fields.add(new CSVField(room.getName()));
            fields.add(new CSVField(room.getSize(exam.hasAltSeating())));
        }
        csv.addLine(fields);
    }
    return csv;
}
Also used : CSVFile(org.cpsolver.ifs.util.CSVFile) ExamRoomPlacement(org.cpsolver.exam.model.ExamRoomPlacement) CSVField(org.cpsolver.ifs.util.CSVFile.CSVField) ExamPlacement(org.cpsolver.exam.model.ExamPlacement) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Exam(org.cpsolver.exam.model.Exam)

Example 12 with CSVField

use of org.cpsolver.ifs.util.CSVFile.CSVField in project cpsolver by UniTime.

the class ExamNbrMeetingsPerDay method report.

/**
     * generate report
     * @param assignment current assignment
     * @return resultant report
     */
public CSVFile report(Assignment<Exam, ExamPlacement> assignment) {
    CSVFile csv = new CSVFile();
    List<CSVField> header = new ArrayList<CSVField>();
    header.add(new CSVField("Date"));
    header.add(new CSVField("None"));
    boolean isDayBreakBackToBack = ((StudentBackToBackConflicts) iModel.getCriterion(StudentBackToBackConflicts.class)).isDayBreakBackToBack();
    for (int i = 1; i <= 5; i++) header.add(new CSVField(i == 5 ? "5+" : String.valueOf(i)));
    header.add(new CSVField("Back-To-Back"));
    csv.setHeader(header);
    int[] nrExamsTotal = new int[6];
    for (int i = 0; i <= 5; i++) nrExamsTotal[i] = 0;
    int btbTotal = 0;
    for (int d = 0; d < iModel.getNrDays(); d++) {
        ExamPeriod period = null;
        for (ExamPeriod p : iModel.getPeriods()) {
            if (p.getDay() == d) {
                period = p;
                break;
            }
        }
        int[] nrExams = new int[6];
        for (int i = 0; i <= 5; i++) nrExams[i] = 0;
        int btb = 0;
        for (ExamStudent student : iModel.getStudents()) {
            int ex = student.getExamsADay(assignment, d).size();
            nrExams[ex <= 5 ? ex : 5]++;
            ExamPeriod p = period;
            while (p.next() != null && (isDayBreakBackToBack ? p : p.next()).getDay() == d) {
                btb += student.getExams(assignment, p).size() * student.getExams(assignment, p.next()).size();
                p = p.next();
            }
        }
        List<CSVField> line = new ArrayList<CSVField>();
        line.add(new CSVField(period.getDayStr()));
        for (int i = 0; i <= 5; i++) {
            line.add(new CSVField(nrExams[i]));
            nrExamsTotal[i] += nrExams[i];
        }
        line.add(new CSVField(btb));
        btbTotal += btb;
        csv.addLine(line);
    }
    List<CSVField> line = new ArrayList<CSVField>();
    line.add(new CSVField("Total"));
    for (int i = 0; i <= 5; i++) line.add(new CSVField(nrExamsTotal[i]));
    line.add(new CSVField(btbTotal));
    csv.addLine(line);
    return csv;
}
Also used : ExamPeriod(org.cpsolver.exam.model.ExamPeriod) CSVFile(org.cpsolver.ifs.util.CSVFile) CSVField(org.cpsolver.ifs.util.CSVFile.CSVField) StudentBackToBackConflicts(org.cpsolver.exam.criteria.StudentBackToBackConflicts) ArrayList(java.util.ArrayList) ExamStudent(org.cpsolver.exam.model.ExamStudent)

Example 13 with CSVField

use of org.cpsolver.ifs.util.CSVFile.CSVField in project cpsolver by UniTime.

the class ExamPeriodUsage method report.

/**
     * generate report
     * @param assignment current assignment
     * @return resultant report
     */
public CSVFile report(Assignment<Exam, ExamPlacement> assignment) {
    CSVFile csv = new CSVFile();
    List<CSVField> header = new ArrayList<CSVField>();
    header.add(new CSVField("Period"));
    header.add(new CSVField("Date"));
    header.add(new CSVField("Time"));
    header.add(new CSVField("Weight"));
    header.add(new CSVField("NrExams"));
    header.add(new CSVField("Students"));
    for (int i = 0; i < sLimits.length; i++) {
        header.add(new CSVField("NrExams>=" + sLimits[i]));
    }
    header.add(new CSVField("AvgPeriod"));
    header.add(new CSVField("WgAvgPeriod"));
    csv.setHeader(header);
    for (ExamPeriod period : iModel.getPeriods()) {
        int nrExams = 0;
        int nrStudents = 0;
        int[] nrExamsLim = new int[sLimits.length];
        int totAvgPer = 0, nrAvgPer = 0, totWgAvgPer = 0;
        for (int i = 0; i < sLimits.length; i++) nrExamsLim[i] = 0;
        for (Exam exam : iModel.variables()) {
            ExamPlacement placement = assignment.getValue(exam);
            if (placement == null || !(placement.getPeriod().equals(period)))
                continue;
            nrExams++;
            nrStudents += exam.getStudents().size();
            if (exam.getAveragePeriod() >= 0) {
                totAvgPer += exam.getAveragePeriod();
                nrAvgPer++;
                totWgAvgPer += exam.getAveragePeriod() * exam.getStudents().size();
            }
            for (int i = 0; i < sLimits.length; i++) if (exam.getStudents().size() >= sLimits[i])
                nrExamsLim[i]++;
        }
        List<CSVField> line = new ArrayList<CSVField>();
        line.add(new CSVField(period.getIndex() + 1));
        line.add(new CSVField(period.getDayStr()));
        line.add(new CSVField(period.getTimeStr()));
        line.add(new CSVField(period.getPenalty()));
        line.add(new CSVField(nrExams));
        line.add(new CSVField(nrStudents));
        for (int i = 0; i < sLimits.length; i++) line.add(new CSVField(nrExamsLim[i]));
        if (nrAvgPer > 0) {
            line.add(new CSVField(sDF.format(((double) totAvgPer) / nrAvgPer)));
            line.add(new CSVField(sDF.format(((double) totWgAvgPer) / nrAvgPer)));
        }
        csv.addLine(line);
    }
    return csv;
}
Also used : ExamPeriod(org.cpsolver.exam.model.ExamPeriod) CSVFile(org.cpsolver.ifs.util.CSVFile) CSVField(org.cpsolver.ifs.util.CSVFile.CSVField) ExamPlacement(org.cpsolver.exam.model.ExamPlacement) ArrayList(java.util.ArrayList) Exam(org.cpsolver.exam.model.Exam)

Aggregations

CSVFile (org.cpsolver.ifs.util.CSVFile)13 CSVField (org.cpsolver.ifs.util.CSVFile.CSVField)13 Exam (org.cpsolver.exam.model.Exam)12 ExamPlacement (org.cpsolver.exam.model.ExamPlacement)12 ArrayList (java.util.ArrayList)7 ExamPeriod (org.cpsolver.exam.model.ExamPeriod)6 ExamRoomPlacement (org.cpsolver.exam.model.ExamRoomPlacement)6 ExamStudent (org.cpsolver.exam.model.ExamStudent)6 DecimalFormat (java.text.DecimalFormat)4 StudentBackToBackConflicts (org.cpsolver.exam.criteria.StudentBackToBackConflicts)4 ExamOwner (org.cpsolver.exam.model.ExamOwner)4 StudentDistanceBackToBackConflicts (org.cpsolver.exam.criteria.StudentDistanceBackToBackConflicts)3 TreeSet (java.util.TreeSet)2 InstructorBackToBackConflicts (org.cpsolver.exam.criteria.InstructorBackToBackConflicts)1 InstructorDistanceBackToBackConflicts (org.cpsolver.exam.criteria.InstructorDistanceBackToBackConflicts)1 StudentDirectConflicts (org.cpsolver.exam.criteria.StudentDirectConflicts)1 StudentNotAvailableConflicts (org.cpsolver.exam.criteria.StudentNotAvailableConflicts)1 ExamInstructor (org.cpsolver.exam.model.ExamInstructor)1 ExamRoom (org.cpsolver.exam.model.ExamRoom)1