use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.
the class StudentSwap method incJenrl.
/**
* Increment {@link JenrlConstraint} between the given two classes by the given student
*/
protected void incJenrl(Assignment<Lecture, Placement> assignment, Student student, Lecture l1, Lecture l2) {
if (l1.equals(l2))
return;
JenrlConstraint jenrl = l1.jenrlConstraint(l2);
if (jenrl == null) {
jenrl = new JenrlConstraint();
jenrl.addVariable(l1);
jenrl.addVariable(l2);
iModel.addConstraint(jenrl);
}
jenrl.incJenrl(assignment, student);
}
use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.
the class StudentConflict method getValue.
@Override
public double getValue(Assignment<Lecture, Placement> assignment, Collection<Lecture> variables) {
double ret = 0.0;
Set<JenrlConstraint> constraints = new HashSet<JenrlConstraint>();
for (Lecture lect : variables) {
Placement plac = assignment.getValue(lect);
if (plac == null)
continue;
for (JenrlConstraint jenrl : lect.jenrlConstraints()) {
if (!constraints.add(jenrl))
continue;
Lecture other = jenrl.another(lect);
if (!other.isCommitted() && !variables.contains(other))
continue;
if (!isApplicable(lect, other))
continue;
if (inConflict(plac, assignment.getValue(other)))
ret += jointEnrollment(jenrl);
}
}
return ret;
}
use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.
the class StudentConflict method getValue.
@Override
public double getValue(Assignment<Lecture, Placement> assignment, Placement value, Set<Placement> conflicts) {
double ret = 0.0;
for (JenrlConstraint jenrl : value.variable().jenrlConstraints()) {
Lecture other = jenrl.another(value.variable());
if (!isApplicable(value.variable(), other))
continue;
Placement another = assignment.getValue(other);
if (another == null)
continue;
if (conflicts != null && conflicts.contains(another))
continue;
if (inConflict(value, another))
ret += jointEnrollment(jenrl);
}
if (iIncludeConflicts && conflicts != null)
for (Placement conflict : conflicts) {
for (JenrlConstraint jenrl : conflict.variable().jenrlConstraints()) {
Lecture other = jenrl.another(conflict.variable());
if (!isApplicable(conflict.variable(), other))
continue;
Placement another = assignment.getValue(other);
if (another == null || another.variable().equals(value.variable()))
continue;
if (conflicts != null && conflicts.contains(another))
continue;
if (inConflict(conflict, another))
ret -= jointEnrollment(jenrl);
}
}
return ret;
}
Aggregations