Search in sources :

Example 21 with CSVFile

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

the class ExamStudentDirectConflicts 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 1"), new CSVField("Enrl 1"), new CSVField("Period 1"), new CSVField("Date 1"), new CSVField("Time 1"), new CSVField("Exam 2"), new CSVField("Enrl 2"), new CSVField("Direct"), new CSVField("Direct [%]") });
    DecimalFormat df = new DecimalFormat("0.0");
    for (Exam ex1 : iModel.variables()) {
        ExamPlacement p1 = assignment.getValue(ex1);
        if (p1 == null)
            continue;
        for (Exam ex2 : iModel.variables()) {
            if (ex1.getId() >= ex2.getId())
                continue;
            ExamPlacement p2 = assignment.getValue(ex2);
            if (p2 == null || !p2.getPeriod().equals(p1.getPeriod()))
                continue;
            List<ExamStudent> students = ex1.getJointEnrollments().get(ex2);
            if (students == null || students.isEmpty())
                continue;
            csv.addLine(new CSVField[] { new CSVField(ex1.getName()), new CSVField(ex1.getStudents().size()), new CSVField(p1.getPeriod().getIndex() + 1), new CSVField(p1.getPeriod().getDayStr()), new CSVField(p1.getPeriod().getTimeStr()), new CSVField(ex2.getName()), new CSVField(ex2.getStudents().size()), new CSVField(students.size()), new CSVField(df.format(100.0 * students.size() / Math.min(ex1.getStudents().size(), ex2.getStudents().size()))) });
        }
    }
    return csv;
}
Also used : CSVFile(org.cpsolver.ifs.util.CSVFile) CSVField(org.cpsolver.ifs.util.CSVFile.CSVField) ExamPlacement(org.cpsolver.exam.model.ExamPlacement) DecimalFormat(java.text.DecimalFormat) ExamStudent(org.cpsolver.exam.model.ExamStudent) Exam(org.cpsolver.exam.model.Exam)

Example 22 with CSVFile

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

the class GetInfo method writeInfos.

public static void writeInfos(List<Info> infos, File file) {
    try {
        System.out.println("Writing " + file + " ...");
        TreeSet<String> keys = new TreeSet<String>();
        List<CSVFile.CSVField> headers = new ArrayList<CSVFile.CSVField>();
        headers.add(new CSVFile.CSVField(""));
        for (Info info : infos) {
            keys.addAll(info.getInfo().keySet());
            headers.add(new CSVFile.CSVField(info.getPrefix()));
        }
        CSVFile csvFile = new CSVFile();
        csvFile.setHeader(headers);
        for (String key : keys) {
            List<CSVFile.CSVField> line = new ArrayList<CSVFile.CSVField>();
            line.add(new CSVFile.CSVField(key));
            for (Info info : infos) {
                String value = info.getInfo().get(key);
                line.add(new CSVFile.CSVField(value == null ? "" : value));
            }
            csvFile.addLine(line);
        }
        csvFile.save(file);
    } catch (Exception e) {
        System.err.println("Error writing file " + file + ", message: " + e.getMessage());
    }
}
Also used : CSVFile(org.cpsolver.ifs.util.CSVFile) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList)

Example 23 with CSVFile

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

the class GetInfo method writeInfos.

public static void writeInfos(List<Info> infos, File file) {
    try {
        System.out.println("Writing " + file + " ...");
        TreeSet<String> keys = new TreeSet<String>();
        ArrayList<CSVFile.CSVField> headers = new ArrayList<CSVFile.CSVField>();
        headers.add(new CSVFile.CSVField(""));
        for (Info o : infos) {
            keys.addAll(o.getInfo().keySet());
            headers.add(new CSVFile.CSVField(o.getPrefix()));
        }
        CSVFile csvFile = new CSVFile();
        csvFile.setHeader(headers);
        for (String key : keys) {
            ArrayList<CSVFile.CSVField> line = new ArrayList<CSVFile.CSVField>();
            line.add(new CSVFile.CSVField(key));
            for (Info o : infos) {
                Map<String, String> info = o.getInfo();
                String value = info.get(key);
                line.add(new CSVFile.CSVField(value == null ? "" : value));
            }
            csvFile.addLine(line);
        }
        csvFile.save(file);
    } catch (Exception e) {
        System.err.println("Error writing file " + file + ", message: " + e.getMessage());
    }
}
Also used : CSVFile(org.cpsolver.ifs.util.CSVFile) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList)

Example 24 with CSVFile

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

the class SectionConflictTable method createTable.

/**
 * Create report
 *
 * @param assignment current assignment
 * @param includeLastLikeStudents
 *            true, if last-like students should be included (i.e.,
 *            {@link Student#isDummy()} is true)
 * @param includeRealStudents
 *            true, if real students should be included (i.e.,
 *            {@link Student#isDummy()} is false)
 * @param useAmPm use 12-hour format
 * @return report as comma separated text file
 */
public CSVFile createTable(Assignment<Request, Enrollment> assignment, boolean includeLastLikeStudents, boolean includeRealStudents, boolean useAmPm) {
    HashMap<Course, Map<Section, Double[]>> unavailabilities = new HashMap<Course, Map<Section, Double[]>>();
    HashMap<Course, Set<Long>> totals = new HashMap<Course, Set<Long>>();
    HashMap<CourseSection, Map<CourseSection, Double>> conflictingPairs = new HashMap<CourseSection, Map<CourseSection, Double>>();
    HashMap<CourseSection, Double> sectionOverlaps = new HashMap<CourseSection, Double>();
    for (Request request : new ArrayList<Request>(getModel().unassignedVariables(assignment))) {
        if (request.getStudent().isDummy() && !includeLastLikeStudents)
            continue;
        if (!request.getStudent().isDummy() && !includeRealStudents)
            continue;
        if (request instanceof CourseRequest) {
            CourseRequest courseRequest = (CourseRequest) request;
            if (courseRequest.getStudent().isComplete(assignment))
                continue;
            List<Enrollment> values = courseRequest.values(assignment);
            SectionLimit limitConstraint = null;
            for (GlobalConstraint<Request, Enrollment> c : getModel().globalConstraints()) {
                if (c instanceof SectionLimit) {
                    limitConstraint = (SectionLimit) c;
                    break;
                }
            }
            if (limitConstraint == null) {
                limitConstraint = new SectionLimit(new DataProperties());
                limitConstraint.setModel(getModel());
            }
            List<Enrollment> notAvailableValues = new ArrayList<Enrollment>(values.size());
            List<Enrollment> availableValues = new ArrayList<Enrollment>(values.size());
            for (Enrollment enrollment : values) {
                if (limitConstraint.inConflict(assignment, enrollment))
                    notAvailableValues.add(enrollment);
                else
                    availableValues.add(enrollment);
            }
            if (!notAvailableValues.isEmpty() && iType.hasUnavailabilities()) {
                List<Enrollment> notOverlappingEnrollments = new ArrayList<Enrollment>(values.size());
                enrollments: for (Enrollment enrollment : notAvailableValues) {
                    for (Request other : request.getStudent().getRequests()) {
                        if (other.equals(request) || assignment.getValue(other) == null || other instanceof FreeTimeRequest)
                            continue;
                        if (assignment.getValue(other).isOverlapping(enrollment))
                            continue enrollments;
                    }
                    // not overlapping
                    notOverlappingEnrollments.add(enrollment);
                }
                if (notOverlappingEnrollments.isEmpty() && availableValues.isEmpty() && iOverlapsAllEnrollments) {
                    double fraction = request.getWeight() / notAvailableValues.size();
                    Set<CourseSection> ones = new HashSet<CourseSection>();
                    for (Enrollment enrollment : notAvailableValues) {
                        boolean hasConflict = false;
                        for (Section s : enrollment.getSections()) {
                            if (s.getLimit() >= 0 && s.getEnrollmentWeight(assignment, request) + request.getWeight() > s.getLimit()) {
                                hasConflict = true;
                                break;
                            }
                        }
                        Map<Section, Double[]> sections = unavailabilities.get(enrollment.getCourse());
                        if (sections == null) {
                            sections = new HashMap<Section, Double[]>();
                            unavailabilities.put(enrollment.getCourse(), sections);
                        }
                        for (Section s : enrollment.getSections()) {
                            if (hasConflict && s.getLimit() < 0 || s.getEnrollmentWeight(assignment, request) + request.getWeight() <= s.getLimit())
                                continue;
                            Double[] total = sections.get(s);
                            sections.put(s, new Double[] { fraction + (total == null ? 0.0 : total[0].doubleValue()), (total == null ? 0.0 : total[1].doubleValue()) });
                            ones.add(new CourseSection(enrollment.getCourse(), s));
                        }
                        Set<Long> total = totals.get(enrollment.getCourse());
                        if (total == null) {
                            total = new HashSet<Long>();
                            totals.put(enrollment.getCourse(), total);
                        }
                        total.add(enrollment.getStudent().getId());
                    }
                } else if (!notOverlappingEnrollments.isEmpty()) {
                    double fraction = request.getWeight() / notOverlappingEnrollments.size();
                    Set<CourseSection> ones = new HashSet<CourseSection>();
                    for (Enrollment enrollment : notOverlappingEnrollments) {
                        boolean hasConflict = false;
                        for (Section s : enrollment.getSections()) {
                            if (s.getLimit() >= 0 && s.getEnrollmentWeight(assignment, request) + request.getWeight() > s.getLimit()) {
                                hasConflict = true;
                                break;
                            }
                        }
                        Map<Section, Double[]> sections = unavailabilities.get(enrollment.getCourse());
                        if (sections == null) {
                            sections = new HashMap<Section, Double[]>();
                            unavailabilities.put(enrollment.getCourse(), sections);
                        }
                        for (Section s : enrollment.getSections()) {
                            if (hasConflict && s.getLimit() < 0 || s.getEnrollmentWeight(assignment, request) + request.getWeight() <= s.getLimit())
                                continue;
                            Double[] total = sections.get(s);
                            sections.put(s, new Double[] { fraction + (total == null ? 0.0 : total[0].doubleValue()), (total == null ? 0.0 : total[1].doubleValue()) });
                            ones.add(new CourseSection(enrollment.getCourse(), s));
                        }
                        Set<Long> total = totals.get(enrollment.getCourse());
                        if (total == null) {
                            total = new HashSet<Long>();
                            totals.put(enrollment.getCourse(), total);
                        }
                        total.add(enrollment.getStudent().getId());
                    }
                    for (CourseSection section : ones) {
                        Map<Section, Double[]> sections = unavailabilities.get(section.getCourse());
                        Double[] total = sections.get(section.getSection());
                        sections.put(section.getSection(), new Double[] { (total == null ? 0.0 : total[0].doubleValue()), request.getWeight() + (total == null ? 0.0 : total[1].doubleValue()) });
                    }
                }
            }
            if (iOverlapsAllEnrollments)
                availableValues = values;
            if (!availableValues.isEmpty() && iType.hasOverlaps()) {
                List<Map<CourseSection, List<CourseSection>>> conflicts = new ArrayList<Map<CourseSection, List<CourseSection>>>();
                for (Enrollment enrollment : availableValues) {
                    Map<CourseSection, List<CourseSection>> overlaps = new HashMap<CourseSection, List<CourseSection>>();
                    for (Request other : request.getStudent().getRequests()) {
                        Enrollment otherEnrollment = assignment.getValue(other);
                        if (other.equals(request) || otherEnrollment == null || other instanceof FreeTimeRequest)
                            continue;
                        if (enrollment.isOverlapping(otherEnrollment))
                            for (Section a : enrollment.getSections()) for (Section b : otherEnrollment.getSections()) if (a.getTime() != null && b.getTime() != null && !a.isAllowOverlap() && !b.isAllowOverlap() && !a.isToIgnoreStudentConflictsWith(b.getId()) && a.getTime().hasIntersection(b.getTime()) && !canIgnore(assignment, enrollment, a, availableValues)) {
                                List<CourseSection> x = overlaps.get(new CourseSection(enrollment.getCourse(), a));
                                if (x == null) {
                                    x = new ArrayList<CourseSection>();
                                    overlaps.put(new CourseSection(enrollment.getCourse(), a), x);
                                }
                                x.add(new CourseSection(otherEnrollment.getCourse(), b));
                            }
                    }
                    if (!overlaps.isEmpty()) {
                        conflicts.add(overlaps);
                        Set<Long> total = totals.get(enrollment.getCourse());
                        if (total == null) {
                            total = new HashSet<Long>();
                            totals.put(enrollment.getCourse(), total);
                        }
                        total.add(enrollment.getStudent().getId());
                    }
                }
                double fraction = request.getWeight() / conflicts.size();
                for (Map<CourseSection, List<CourseSection>> overlaps : conflicts) {
                    for (Map.Entry<CourseSection, List<CourseSection>> entry : overlaps.entrySet()) {
                        CourseSection a = entry.getKey();
                        Double total = sectionOverlaps.get(a);
                        sectionOverlaps.put(a, fraction + (total == null ? 0.0 : total.doubleValue()));
                        Map<CourseSection, Double> pair = conflictingPairs.get(a);
                        if (pair == null) {
                            pair = new HashMap<CourseSection, Double>();
                            conflictingPairs.put(a, pair);
                        }
                        for (CourseSection b : entry.getValue()) {
                            Double prev = pair.get(b);
                            pair.put(b, fraction + (prev == null ? 0.0 : prev.doubleValue()));
                        }
                    }
                }
            }
        }
    }
    Comparator<Course> courseComparator = new Comparator<Course>() {

        @Override
        public int compare(Course a, Course b) {
            int cmp = a.getName().compareTo(b.getName());
            if (cmp != 0)
                return cmp;
            return a.getId() < b.getId() ? -1 : a.getId() == b.getId() ? 0 : 1;
        }
    };
    Comparator<Section> sectionComparator = new Comparator<Section>() {

        @Override
        public int compare(Section a, Section b) {
            int cmp = a.getSubpart().getConfig().getOffering().getName().compareTo(b.getSubpart().getConfig().getOffering().getName());
            if (cmp != 0)
                return cmp;
            cmp = a.getSubpart().getInstructionalType().compareTo(b.getSubpart().getInstructionalType());
            // cmp = a.getName().compareTo(b.getName());
            if (cmp != 0)
                return cmp;
            return a.getId() < b.getId() ? -1 : a.getId() == b.getId() ? 0 : 1;
        }
    };
    CSVFile csv = new CSVFile();
    List<CSVFile.CSVField> headers = new ArrayList<CSVFile.CSVField>();
    headers.add(new CSVFile.CSVField("Course"));
    headers.add(new CSVFile.CSVField("Total\nConflicts"));
    if (iType.hasUnavailabilities()) {
        headers.add(new CSVFile.CSVField("Course\nEnrollment"));
        headers.add(new CSVFile.CSVField("Course\nLimit"));
    }
    headers.add(new CSVFile.CSVField("Class"));
    headers.add(new CSVFile.CSVField("Meeting Time"));
    if (iType.hasUnavailabilities()) {
        headers.add(new CSVFile.CSVField("Availability\nConflicts"));
        headers.add(new CSVFile.CSVField("% of Total\nConflicts"));
    }
    if (iType.hasOverlaps()) {
        headers.add(new CSVFile.CSVField("Time\nConflicts"));
        headers.add(new CSVFile.CSVField("% of Total\nConflicts"));
    }
    if (iType.hasUnavailabilities()) {
        headers.add(new CSVFile.CSVField("Class\nEnrollment"));
        headers.add(new CSVFile.CSVField("Class\nLimit"));
        if (!iType.hasOverlaps())
            headers.add(new CSVFile.CSVField("Class\nPotential"));
    }
    if (iType.hasOverlaps()) {
        headers.add(new CSVFile.CSVField("Conflicting\nClass"));
        headers.add(new CSVFile.CSVField("Conflicting\nMeeting Time"));
        headers.add(new CSVFile.CSVField("Joined\nConflicts"));
        headers.add(new CSVFile.CSVField("% of Total\nConflicts"));
    }
    csv.setHeader(headers);
    TreeSet<Course> courses = new TreeSet<Course>(courseComparator);
    courses.addAll(totals.keySet());
    for (Course course : courses) {
        Map<Section, Double[]> sectionUnavailability = unavailabilities.get(course);
        Set<Long> total = totals.get(course);
        TreeSet<Section> sections = new TreeSet<Section>(sectionComparator);
        if (sectionUnavailability != null)
            sections.addAll(sectionUnavailability.keySet());
        for (Map.Entry<CourseSection, Double> entry : sectionOverlaps.entrySet()) if (course.equals(entry.getKey().getCourse()))
            sections.add(entry.getKey().getSection());
        boolean firstCourse = true;
        for (Section section : sections) {
            Double[] sectionUnavailable = (sectionUnavailability == null ? null : sectionUnavailability.get(section));
            Double sectionOverlap = sectionOverlaps.get(new CourseSection(course, section));
            Map<CourseSection, Double> pair = conflictingPairs.get(new CourseSection(course, section));
            if (pair == null) {
                List<CSVFile.CSVField> line = new ArrayList<CSVFile.CSVField>();
                line.add(new CSVFile.CSVField(firstCourse ? course.getName() : ""));
                line.add(new CSVFile.CSVField(firstCourse ? total.size() : ""));
                if (iType.hasUnavailabilities()) {
                    line.add(new CSVFile.CSVField(firstCourse ? sDF1.format(course.getEnrollmentWeight(assignment, null)) : ""));
                    line.add(new CSVFile.CSVField(firstCourse ? course.getLimit() < 0 ? "" : String.valueOf(course.getLimit()) : ""));
                }
                line.add(new CSVFile.CSVField(section.getSubpart().getName() + " " + section.getName(course.getId())));
                line.add(new CSVFile.CSVField(section.getTime() == null ? "" : section.getTime().getDayHeader() + " " + section.getTime().getStartTimeHeader(useAmPm) + " - " + section.getTime().getEndTimeHeader(useAmPm)));
                if (iType.hasUnavailabilities()) {
                    line.add(new CSVFile.CSVField(sectionUnavailable != null ? sDF2.format(sectionUnavailable[0]) : ""));
                    line.add(new CSVFile.CSVField(sectionUnavailable != null ? sDF2.format(sectionUnavailable[0] / total.size()) : ""));
                }
                if (iType.hasOverlaps()) {
                    line.add(new CSVFile.CSVField(sectionOverlap != null ? sDF2.format(sectionOverlap) : ""));
                    line.add(new CSVFile.CSVField(sectionOverlap != null ? sDF2.format(sectionOverlap / total.size()) : ""));
                }
                if (iType.hasUnavailabilities()) {
                    line.add(new CSVFile.CSVField(sDF1.format(section.getEnrollmentWeight(assignment, null))));
                    line.add(new CSVFile.CSVField(section.getLimit() < 0 ? "" : String.valueOf(section.getLimit())));
                    if (!iType.hasOverlaps())
                        line.add(new CSVFile.CSVField(sectionUnavailable != null ? sDF1.format(sectionUnavailable[1]) : ""));
                }
                csv.addLine(line);
            } else {
                boolean firstClass = true;
                for (CourseSection other : new TreeSet<CourseSection>(pair.keySet())) {
                    List<CSVFile.CSVField> line = new ArrayList<CSVFile.CSVField>();
                    line.add(new CSVFile.CSVField(firstCourse && firstClass ? course.getName() : ""));
                    line.add(new CSVFile.CSVField(firstCourse && firstClass ? total.size() : ""));
                    if (iType.hasUnavailabilities()) {
                        line.add(new CSVFile.CSVField(firstCourse && firstClass ? sDF1.format(course.getEnrollmentWeight(assignment, null)) : ""));
                        line.add(new CSVFile.CSVField(firstCourse && firstClass ? course.getLimit() < 0 ? "" : String.valueOf(course.getLimit()) : ""));
                    }
                    line.add(new CSVFile.CSVField(firstClass ? section.getSubpart().getName() + " " + section.getName(course.getId()) : ""));
                    line.add(new CSVFile.CSVField(firstClass ? section.getTime() == null ? "" : section.getTime().getDayHeader() + " " + section.getTime().getStartTimeHeader(useAmPm) + " - " + section.getTime().getEndTimeHeader(useAmPm) : ""));
                    if (iType.hasUnavailabilities()) {
                        line.add(new CSVFile.CSVField(firstClass && sectionUnavailable != null ? sDF2.format(sectionUnavailable[0]) : ""));
                        line.add(new CSVFile.CSVField(sectionUnavailable != null ? sDF2.format(sectionUnavailable[0] / total.size()) : ""));
                    }
                    line.add(new CSVFile.CSVField(firstClass && sectionOverlap != null ? sDF2.format(sectionOverlap) : ""));
                    line.add(new CSVFile.CSVField(firstClass && sectionOverlap != null ? sDF2.format(sectionOverlap / total.size()) : ""));
                    if (iType.hasUnavailabilities()) {
                        line.add(new CSVFile.CSVField(firstClass ? sDF1.format(section.getEnrollmentWeight(assignment, null)) : ""));
                        line.add(new CSVFile.CSVField(firstClass ? section.getLimit() < 0 ? "" : String.valueOf(section.getLimit()) : ""));
                    }
                    line.add(new CSVFile.CSVField(other.getCourse().getName() + " " + other.getSection().getSubpart().getName() + " " + other.getSection().getName(other.getCourse().getId())));
                    line.add(new CSVFile.CSVField(other.getSection().getTime().getDayHeader() + " " + other.getSection().getTime().getStartTimeHeader(useAmPm) + " - " + other.getSection().getTime().getEndTimeHeader(useAmPm)));
                    line.add(new CSVFile.CSVField(sDF2.format(pair.get(other))));
                    line.add(new CSVFile.CSVField(sDF2.format(pair.get(other) / total.size())));
                    csv.addLine(line);
                    firstClass = false;
                }
            }
            firstCourse = false;
        }
        csv.addLine();
    }
    return csv;
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) CSVFile(org.cpsolver.ifs.util.CSVFile) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DataProperties(org.cpsolver.ifs.util.DataProperties) Comparator(java.util.Comparator) TreeSet(java.util.TreeSet) Enrollment(org.cpsolver.studentsct.model.Enrollment) ArrayList(java.util.ArrayList) List(java.util.List) Course(org.cpsolver.studentsct.model.Course) HashSet(java.util.HashSet) FreeTimeRequest(org.cpsolver.studentsct.model.FreeTimeRequest) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) FreeTimeRequest(org.cpsolver.studentsct.model.FreeTimeRequest) Request(org.cpsolver.studentsct.model.Request) Section(org.cpsolver.studentsct.model.Section) GlobalConstraint(org.cpsolver.ifs.model.GlobalConstraint) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) SectionLimit(org.cpsolver.studentsct.constraint.SectionLimit) HashMap(java.util.HashMap) Map(java.util.Map)

Example 25 with CSVFile

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

the class RequestPriorityTable method create.

@Override
public CSVFile create(Assignment<Request, Enrollment> assignment, DataProperties properties) {
    CSVFile csv = new CSVFile();
    csv.setHeader(new CSVFile.CSVField[] { new CSVFile.CSVField("__Student"), new CSVFile.CSVField("Student"), new CSVFile.CSVField("Course"), new CSVFile.CSVField("Alternative"), new CSVFile.CSVField("Enrolled"), new CSVFile.CSVField("Primary"), new CSVFile.CSVField("Priority"), new CSVFile.CSVField("Alternativity") });
    for (Student student : getModel().getStudents()) {
        if (student.isDummy())
            continue;
        int regPriority = 1, altPriority = 1;
        for (Request r : student.getRequests()) {
            if (r instanceof CourseRequest) {
                CourseRequest cr = (CourseRequest) r;
                Enrollment e = cr.getAssignment(assignment);
                int primary = (cr.isAlternative() ? 0 : 1);
                int priority = 0;
                if (cr.isAlternative())
                    priority = altPriority++;
                else
                    priority = regPriority++;
                int alternativity = 0;
                for (Course course : cr.getCourses()) {
                    int alternative = (primary == 0 || alternativity > 0 ? 1 : 0);
                    int enrolled = (e != null && e.getCourse().equals(course) ? 1 : 0);
                    csv.addLine(new CSVFile.CSVField[] { new CSVFile.CSVField(student.getId()), new CSVFile.CSVField(student.getExternalId()), new CSVFile.CSVField(cr.getCourses().get(alternativity).getName()), new CSVFile.CSVField(alternative), new CSVFile.CSVField(enrolled), new CSVFile.CSVField(primary), new CSVFile.CSVField(priority), new CSVFile.CSVField(alternativity) });
                    alternativity++;
                }
            }
        }
    }
    return csv;
}
Also used : CSVFile(org.cpsolver.ifs.util.CSVFile) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) Request(org.cpsolver.studentsct.model.Request) Enrollment(org.cpsolver.studentsct.model.Enrollment) Student(org.cpsolver.studentsct.model.Student) Course(org.cpsolver.studentsct.model.Course)

Aggregations

CSVFile (org.cpsolver.ifs.util.CSVFile)26 ArrayList (java.util.ArrayList)14 CSVField (org.cpsolver.ifs.util.CSVFile.CSVField)13 Exam (org.cpsolver.exam.model.Exam)12 ExamPlacement (org.cpsolver.exam.model.ExamPlacement)12 TreeSet (java.util.TreeSet)9 Enrollment (org.cpsolver.studentsct.model.Enrollment)9 Course (org.cpsolver.studentsct.model.Course)8 Request (org.cpsolver.studentsct.model.Request)8 CourseRequest (org.cpsolver.studentsct.model.CourseRequest)7 Section (org.cpsolver.studentsct.model.Section)7 ExamPeriod (org.cpsolver.exam.model.ExamPeriod)6 ExamRoomPlacement (org.cpsolver.exam.model.ExamRoomPlacement)6 ExamStudent (org.cpsolver.exam.model.ExamStudent)6 HashSet (java.util.HashSet)5 Map (java.util.Map)5 DecimalFormat (java.text.DecimalFormat)4 Comparator (java.util.Comparator)4 HashMap (java.util.HashMap)4 Set (java.util.Set)4