use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class TimePreferences method getBounds.
@Override
public double[] getBounds(Assignment<Lecture, Placement> assignment, Collection<Lecture> variables) {
double[] bounds = new double[] { 0.0, 0.0 };
for (Lecture lect : variables) {
if (lect.isCommitted())
continue;
double[] p = lect.getMinMaxTimePreference();
bounds[1] += lect.getWeight() * (p[1] - p[0]);
}
return bounds;
}
use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class BrokenTimePatterns method getValue.
@Override
public double getValue(Assignment<Lecture, Placement> assignment, Collection<Lecture> variables) {
double ret = 0;
Set<RoomConstraint> constraints = new HashSet<RoomConstraint>();
for (Lecture lect : variables) {
Placement placement = assignment.getValue(lect);
if (placement == null)
continue;
if (placement.isMultiRoom()) {
for (RoomLocation r : placement.getRoomLocations()) {
if (r.getRoomConstraint() != null && constraints.add(r.getRoomConstraint()))
ret += penalty(r.getRoomConstraint().getContext(assignment));
}
} else if (placement.getRoomLocation().getRoomConstraint() != null && constraints.add(placement.getRoomLocation().getRoomConstraint())) {
ret += penalty(placement.getRoomLocation().getRoomConstraint().getContext(assignment));
}
}
return ret;
}
use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class DistributionPreferences method getBounds.
@Override
public double[] getBounds(Assignment<Lecture, Placement> assignment, Collection<Lecture> variables) {
double[] bounds = new double[] { 0.0, 0.0 };
Set<GroupConstraint> constraints = new HashSet<GroupConstraint>();
for (Lecture lect : variables) {
for (GroupConstraint gc : lect.groupConstraints()) {
if (!gc.isHard() && constraints.add(gc)) {
bounds[1] += Math.abs(gc.getPreference()) * (1 + (gc.variables().size() * (gc.variables().size() - 1)) / 2);
}
}
}
return bounds;
}
use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class IgnoredCommittedStudentConflict method countCommittedConflicts.
public double countCommittedConflicts(Placement placement) {
double ret = 0;
Lecture lecture = placement.variable();
for (Student student : lecture.students()) {
ret += countCommittedConflicts(student, placement);
}
return ret;
}
use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class FlexibleConstraintCriterion method getValue.
@Override
public double getValue(Assignment<Lecture, Placement> assignment, Placement value, Set<Placement> conflicts) {
HashMap<Lecture, Placement> assignments = new HashMap<Lecture, Placement>();
assignments.put(value.variable(), value);
double ret = 0.0;
for (FlexibleConstraint gc : value.variable().getFlexibleGroupConstraints()) ret += gc.getCurrentPreference(assignment, conflicts, assignments);
assignments.put(value.variable(), null);
for (FlexibleConstraint gc : value.variable().getFlexibleGroupConstraints()) ret -= gc.getCurrentPreference(assignment, conflicts, assignments);
return ret;
}
Aggregations