use of org.cpsolver.exam.model.ExamDistributionConstraint in project cpsolver by UniTime.
the class DistributionViolation method getValue.
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, Collection<Exam> variables) {
int penalty = 0;
Set<ExamDistributionConstraint> added = new HashSet<ExamDistributionConstraint>();
for (Exam exam : variables) {
for (ExamDistributionConstraint dc : exam.getDistributionConstraints()) {
if (added.add(dc)) {
if (dc.isHard() || getWeight() != dc.getWeight())
continue;
if (!dc.isSatisfied(assignment))
penalty += 1;
}
}
}
return penalty;
}
use of org.cpsolver.exam.model.ExamDistributionConstraint in project cpsolver by UniTime.
the class DistributionPenalty method getValue.
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, Collection<Exam> variables) {
int penalty = 0;
Set<ExamDistributionConstraint> added = new HashSet<ExamDistributionConstraint>();
for (Exam exam : variables) {
for (ExamDistributionConstraint dc : exam.getDistributionConstraints()) {
if (added.add(dc)) {
if (dc.isHard() || (iSoftDistributions != null && iSoftDistributions == dc.getWeight()))
continue;
if (!dc.isSatisfied(assignment))
penalty += dc.getWeight();
}
}
}
return penalty;
}
Aggregations