use of org.cpsolver.instructor.model.Preference in project cpsolver by UniTime.
the class MathTest method toString.
public String toString(Instructor instructor) {
StringBuffer sb = new StringBuffer();
sb.append(instructor.getExternalId());
sb.append(",\"" + instructor.getAvailable() + "\"");
Collections.sort(instructor.getCoursePreferences(), new Comparator<Preference<Course>>() {
@Override
public int compare(Preference<Course> p1, Preference<Course> p2) {
if (p1.getPreference() == p2.getPreference())
return p1.getTarget().getCourseName().compareTo(p2.getTarget().getCourseName());
return p1.getPreference() < p2.getPreference() ? -1 : 1;
}
});
for (int i = 0; i < 3; i++) {
Preference<Course> p = (i < instructor.getCoursePreferences().size() ? instructor.getCoursePreferences().get(i) : null);
sb.append("," + (p == null ? "" : p.getTarget().getCourseName()));
}
sb.append("," + (instructor.getPreference() == 0 ? "Yes" : "No"));
sb.append("," + (instructor.isBackToBackPreferred() ? "1" : instructor.isBackToBackDiscouraged() ? "-1" : "0"));
sb.append("," + new DecimalFormat("0.0").format(instructor.getMaxLoad()));
String level = getLevel(instructor);
sb.append("," + (level == null ? "" : level));
return sb.toString();
}
use of org.cpsolver.instructor.model.Preference in project cpsolver by UniTime.
the class ChmTest method getAttributes.
public String getAttributes(Instructor instructor, String type) {
TreeSet<String> attributes = new TreeSet<String>();
for (Attribute attribute : instructor.getAttributes()) if (attribute.getType().getTypeName().equals(type)) {
attributes.add(attribute.getAttributeName());
}
StringBuffer s = new StringBuffer();
if ("Qualification".equals(type))
for (Preference<Course> p : instructor.getCoursePreferences()) attributes.remove(p.getTarget().getCourseName().substring(4));
for (String attribute : attributes) {
// if ("00000".equals(attribute)) continue;
if (s.length() > 0)
s.append(",");
s.append(attribute);
}
return s.toString();
}
Aggregations