Search in sources :

Example 6 with Instructor

use of org.cpsolver.instructor.model.Instructor in project cpsolver by UniTime.

the class ChmTest method generateReports.

@Override
protected void generateReports(File dir, Assignment<TeachingRequest.Variable, TeachingAssignment> assignment) throws IOException {
    PrintWriter out = new PrintWriter(new File(dir, "solution-assignments.csv"));
    out.println("Course,Sections,Time,Room,Skill,Qualification,Performance,Load,Student,Name,Not Available,Max Load,Skill,Qualification,Performance,Requested");
    for (TeachingRequest.Variable request : variables()) {
        out.print(request.getCourse().getCourseName());
        String sect = "", time = "", room = "";
        if (request.getId() < 0) {
            out.print(",\"SUPER\",,");
        } else {
            for (Iterator<Section> i = request.getSections().iterator(); i.hasNext(); ) {
                Section section = i.next();
                // if (section.isCommon() && section.isAllowOverlap()) continue;
                if (!sect.isEmpty()) {
                    sect += ", ";
                    time += ", ";
                    room += ", ";
                }
                sect += (section.isCommon() ? "(" : "") + section.getSectionType() + " " + section.getExternalId() + (section.isCommon() ? ")" : "");
                time += (section.getTime() == null ? "-" : section.getTime().getDayHeader() + " " + section.getTime().getStartTimeHeader(true) + "-" + section.getTime().getEndTimeHeader(true));
                room += (section.getRoom() == null ? "-" : section.getRoom());
            }
            out.print(",\"" + sect + "\",\"" + time + "\",\"" + room + "\"");
        }
        out.print(",\"" + getAttributes(request.getRequest(), "Skill") + "\"");
        out.print(",\"" + getAttributes(request.getRequest(), "Qualification") + "\"");
        out.print(",\"" + getAttributes(request.getRequest(), "Performance Level") + "\"");
        out.print("," + new DecimalFormat("0.0").format(request.getRequest().getLoad()));
        TeachingAssignment ta = assignment.getValue(request);
        if (ta != null) {
            Instructor instructor = ta.getInstructor();
            out.print("," + instructor.getExternalId());
            out.print(",\"" + instructor.getName() + "\"");
            out.print(",\"" + instructor.getAvailable() + "\"");
            out.print("," + new DecimalFormat("0.0").format(instructor.getMaxLoad()));
            out.print(",\"" + getAttributes(request.getRequest(), instructor, "Skill") + "\"");
            out.print(",\"" + getAttributes(request.getRequest(), instructor, "Qualification") + "\"");
            out.print(",\"" + getAttributes(request.getRequest(), instructor, "Performance Level") + "\"");
            out.print(",\"" + getCoursePreference(request.getRequest(), instructor) + "\"");
        }
        out.println();
    }
    out.flush();
    out.close();
    out = new PrintWriter(new File(dir, "solution-students.csv"));
    out.println("Student,Name,Not Available,Skill,Qualification,Performance,Requests,Max Load,Assigned Load,1st Assignment,2nd Assignment,Skill,Qualification,Performance,Requested");
    for (Instructor instructor : getInstructors()) {
        out.print(instructor.getExternalId());
        out.print(",\"" + instructor.getName() + "\"");
        out.print(",\"" + instructor.getAvailable() + "\"");
        out.print(",\"" + getAttributes(instructor, "Skill") + "\"");
        out.print(",\"" + getAttributes(instructor, "Qualification") + "\"");
        out.print(",\"" + getAttributes(instructor, "Performance Level") + "\"");
        out.print(",\"" + getCoursePrefs(instructor) + "\"");
        out.print("," + new DecimalFormat("0.0").format(instructor.getMaxLoad()));
        Instructor.Context context = instructor.getContext(assignment);
        out.print("," + new DecimalFormat("0.0").format(context.getLoad()));
        /*
            out.print("," + (context.countBackToBackPercentage() == 0.0 ? "" : new DecimalFormat("0.0").format(100.0 * context.countBackToBackPercentage())));
            out.print("," + (context.countDifferentLectures() == 0.0 ? "" : new DecimalFormat("0.0").format(100.0 * context.countDifferentLectures())));
            int share = 0;
            for (TeachingAssignment ta : context.getAssignments()) {
                for (Preference<TimeLocation> p: instructor.getTimePreferences()) {
                    if (!p.isProhibited())
                        share += ta.variable().getRequest().share(p.getTarget());
                }
            }
            out.print("," + (share == 0 ? "" : new DecimalFormat("0.#").format(share / 12.0)));
            */
        TeachingRequest req = null;
        for (TeachingAssignment ta : context.getAssignments()) {
            String sect = "";
            if (req == null || req.getRequestId() < 0)
                req = ta.variable().getRequest();
            if (ta.variable().getId() < 0) {
                sect = "SUPER";
            } else {
                for (Iterator<Section> i = ta.variable().getSections().iterator(); i.hasNext(); ) {
                    Section section = i.next();
                    if (section.isCommon() && section.isAllowOverlap())
                        continue;
                    sect += (sect.isEmpty() ? "" : ", ") + (section.isCommon() ? "(" : "") + section.getSectionType() + " " + section.getExternalId() + (section.getTime() == null ? "" : " " + section.getTime().getDayHeader() + " " + section.getTime().getStartTimeHeader(true) + "-" + section.getTime().getEndTimeHeader(true)) + (section.isCommon() ? ")" : "");
                }
            }
            out.print(",\"" + ta.variable().getCourse() + " " + sect + "\"");
        }
        if (req != null) {
            for (int i = context.getAssignments().size(); i < 2; i++) out.print(",");
            out.print(",\"" + getAttributes(req, instructor, "Skill") + "\"");
            out.print(",\"" + getAttributes(req, instructor, "Qualification") + "\"");
            out.print(",\"" + getAttributes(req, instructor, "Performance Level") + "\"");
            out.print(",\"" + getCoursePreference(req, instructor) + "\"");
        }
        out.println();
    }
    out.flush();
    out.close();
}
Also used : TeachingAssignment(org.cpsolver.instructor.model.TeachingAssignment) DecimalFormat(java.text.DecimalFormat) Instructor(org.cpsolver.instructor.model.Instructor) TeachingRequest(org.cpsolver.instructor.model.TeachingRequest) File(java.io.File) Section(org.cpsolver.instructor.model.Section) PrintWriter(java.io.PrintWriter)

Aggregations

Instructor (org.cpsolver.instructor.model.Instructor)6 TeachingRequest (org.cpsolver.instructor.model.TeachingRequest)6 TeachingAssignment (org.cpsolver.instructor.model.TeachingAssignment)5 File (java.io.File)4 HashSet (java.util.HashSet)4 Section (org.cpsolver.instructor.model.Section)4 PrintWriter (java.io.PrintWriter)3 DecimalFormat (java.text.DecimalFormat)3 Course (org.cpsolver.instructor.model.Course)3 HashMap (java.util.HashMap)2 TreeSet (java.util.TreeSet)2 TimeLocation (org.cpsolver.coursett.model.TimeLocation)2 Constraint (org.cpsolver.ifs.model.Constraint)2 SameInstructorConstraint (org.cpsolver.instructor.constraints.SameInstructorConstraint)2 SameLinkConstraint (org.cpsolver.instructor.constraints.SameLinkConstraint)2 Attribute (org.cpsolver.instructor.model.Attribute)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1