Search in sources :

Example 1 with ExamDistributionConstraint

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;
}
Also used : ExamDistributionConstraint(org.cpsolver.exam.model.ExamDistributionConstraint) ExamDistributionConstraint(org.cpsolver.exam.model.ExamDistributionConstraint) Exam(org.cpsolver.exam.model.Exam) HashSet(java.util.HashSet)

Example 2 with ExamDistributionConstraint

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;
}
Also used : ExamDistributionConstraint(org.cpsolver.exam.model.ExamDistributionConstraint) ExamDistributionConstraint(org.cpsolver.exam.model.ExamDistributionConstraint) Exam(org.cpsolver.exam.model.Exam) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 Exam (org.cpsolver.exam.model.Exam)2 ExamDistributionConstraint (org.cpsolver.exam.model.ExamDistributionConstraint)2