Search in sources :

Example 1 with Preference

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();
}
Also used : Preference(org.cpsolver.instructor.model.Preference) DecimalFormat(java.text.DecimalFormat) Course(org.cpsolver.instructor.model.Course) SameLinkConstraint(org.cpsolver.instructor.constraints.SameLinkConstraint) Constraint(org.cpsolver.ifs.model.Constraint) SameInstructorConstraint(org.cpsolver.instructor.constraints.SameInstructorConstraint)

Example 2 with Preference

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();
}
Also used : Attribute(org.cpsolver.instructor.model.Attribute) Preference(org.cpsolver.instructor.model.Preference) TreeSet(java.util.TreeSet)

Aggregations

Preference (org.cpsolver.instructor.model.Preference)2 DecimalFormat (java.text.DecimalFormat)1 TreeSet (java.util.TreeSet)1 Constraint (org.cpsolver.ifs.model.Constraint)1 SameInstructorConstraint (org.cpsolver.instructor.constraints.SameInstructorConstraint)1 SameLinkConstraint (org.cpsolver.instructor.constraints.SameLinkConstraint)1 Attribute (org.cpsolver.instructor.model.Attribute)1 Course (org.cpsolver.instructor.model.Course)1