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