use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class BackToBackInstructorPreferences method getBounds.
@Override
public double[] getBounds(Assignment<Lecture, Placement> assignment, Collection<Lecture> variables) {
double[] bounds = new double[] { 0.0, 0.0 };
Set<InstructorConstraint> constraints = new HashSet<InstructorConstraint>();
for (Lecture lect : variables) {
for (InstructorConstraint ic : lect.getInstructorConstraints()) {
if (!constraints.add(ic))
continue;
bounds[1] += ic.getWorstPreference();
}
}
return bounds;
}
use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class BackToBackInstructorPreferences method getValue.
@Override
public double getValue(Assignment<Lecture, Placement> assignment, Collection<Lecture> variables) {
double ret = 0;
Set<InstructorConstraint> constraints = new HashSet<InstructorConstraint>();
for (Lecture lect : variables) {
for (InstructorConstraint ic : lect.getInstructorConstraints()) {
if (!constraints.add(ic))
continue;
ret += ic.getPreference(assignment);
}
}
return ret;
}
use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class RoomConstraint method computeConflicts.
@Override
public void computeConflicts(Assignment<Lecture, Placement> assignment, Placement placement, Set<Placement> conflicts) {
if (!getConstraint())
return;
if (!placement.hasRoomLocation(getResourceId()))
return;
Lecture lecture = placement.variable();
Placement current = assignment.getValue(lecture);
boolean canShareRoom = lecture.canShareRoom();
int size = lecture.maxRoomUse();
HashSet<Placement> skipPlacements = null;
BitSet weekCode = placement.getTimeLocation().getWeekCode();
RoomConstraintContext context = getContext(assignment);
for (Enumeration<Integer> e = placement.getTimeLocation().getSlots(); e.hasMoreElements(); ) {
int slot = e.nextElement();
for (Placement confPlacement : context.getPlacements(slot)) {
if (!confPlacement.getTimeLocation().shareWeeks(weekCode))
continue;
if (confPlacement.equals(current))
continue;
Lecture confLecture = confPlacement.variable();
if (skipPlacements != null && skipPlacements.contains(confPlacement))
continue;
if (canShareRoom && confPlacement.canShareRooms(placement) && confLecture.maxRoomUse() + size <= getCapacity()) {
size += confLecture.maxRoomUse();
if (skipPlacements == null)
skipPlacements = new HashSet<Placement>();
skipPlacements.add(confPlacement);
continue;
}
conflicts.add(confPlacement);
}
}
}
use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class MinimizeNumberOfUsedGroupsOfTime method estimateLimit.
public int estimateLimit() {
int nrSlotsUsed = 0;
int minSlotsUsed = 0;
boolean firstLecture = true;
for (Lecture lecture : variables()) {
boolean first = true;
int minSlotsUsedThisLecture = 0;
for (TimeLocation time : lecture.timeLocations()) {
int min = 0;
for (int i = 0; i < iGroupsOfTime.length; i++) {
if (iGroupsOfTime[i].overlap(time))
min++;
}
if (first) {
nrSlotsUsed += time.getLength() * time.getNrMeetings();
minSlotsUsedThisLecture = min;
first = false;
} else {
minSlotsUsedThisLecture = Math.min(minSlotsUsedThisLecture, min);
}
}
if (firstLecture) {
minSlotsUsed = minSlotsUsedThisLecture;
firstLecture = false;
} else {
minSlotsUsed = Math.min(minSlotsUsed, minSlotsUsedThisLecture);
}
}
return Math.max(Math.max(1, (int) Math.ceil(((double) nrSlotsUsed) / iGroupsOfTime[0].size())), minSlotsUsed);
}
use of org.cpsolver.coursett.model.Lecture in project cpsolver by UniTime.
the class StudentSwapSectioning method group.
/**
* Student group weight of a solution
*/
public static double group(TimetableModel model) {
double ret = 0;
for (StudentGroup group : model.getStudentGroups()) {
Map<Long, Match> match = new HashMap<Long, Match>();
Set<Long> offeringIds = new HashSet<Long>();
for (Student student : group.getStudents()) for (Lecture lecture : student.getLectures()) {
offeringIds.add(lecture.getConfiguration().getOfferingId());
Match m = match.get(lecture.getSchedulingSubpartId());
if (m == null) {
m = new Match(group, lecture.getConfiguration());
match.put(lecture.getSchedulingSubpartId(), m);
}
m.inc(lecture);
}
double value = 0.0;
for (Match m : match.values()) value += m.value();
ret += value / offeringIds.size();
}
return ret;
}
Aggregations