use of org.cpsolver.coursett.model.TimetableModel in project cpsolver by UniTime.
the class FlexibleConstraintCriterion method getInfo.
@Override
public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) {
TimetableModel m = (TimetableModel) getModel();
if (m.getFlexibleConstraints().isEmpty())
return;
for (FlexibleConstraintType type : FlexibleConstraintType.values()) {
StringBuilder debug = null;
int violated = 0, constraints = 0;
for (FlexibleConstraint c : m.getFlexibleConstraints()) {
if (type.equals(c.getType())) {
constraints++;
if (c.getContext(assignment).getPreference() > 0) {
violated++;
if (iDebug) {
if (debug == null)
debug = new StringBuilder(c.getOwner() + " (" + sDoubleFormat.format(c.getNrViolations(assignment, new HashSet<Placement>(), null)) + ")");
else
debug.append("; " + c.getOwner() + " (" + sDoubleFormat.format(c.getNrViolations(assignment, new HashSet<Placement>(), null)) + ")");
}
}
}
}
if (constraints > 0) {
info.put(type.getName() + " Constraints", getPerc(violated, 0, constraints) + "% (" + violated + ")");
if (iDebug && violated > 0)
info.put(type.getName() + " Violations", debug.toString());
}
}
}
Aggregations