if (person.getEvents().size() == 0)
continue;
Set<Assignment> set = FastSet.newInstance();
for (Event event : person.getEvents()) {
Assignment ass = eventToAss.get(event);
if (ass == null) {
ass = new Assignment(event);
eventToAss.put(event, ass);
}
set.add(ass);
}
personToAssignments.put(person, set);
}
for (Person person : persons) {
for (Constraint c : person.getConstraints()) {
c.transformEvents(eventToAss);
}
}
conflictMatrix = new ConflictMatrix(dataPoolSettings.getTimeslotsPerWeek(), dataPoolSettings.getTimeslotsPerDay());
// TODO LATER: use only as many assignment as it should (e.g. if a course is splitted into several sections)
List<Assignment> allAssignments = new ArrayList<Assignment>(conflictMatrix.initFromResources(personToAssignments));
doIntegrityChecks(allAssignments, allLocations);
logger.info("Start Algorithm - number of slots per week:" + dataPoolSettings.getTimeslotsPerWeek()
+ "; number of slots per day:" + dataPoolSettings.getTimeslotsPerDay()
+ "; events:" + allAssignments.size()
+ "; persons:" + personToAssignments.size()
+ "; locations:" + allLocations.size());
Map<Assignment, Set<Assignment>> followers = FastMap.newInstance();
Map<Assignment, Set<Assignment>> befores = FastMap.newInstance();
for (Assignment ass : allAssignments) {
if (ass.getEvent().getPersons().size() == 0)
logger.fatal("relationship events to persons has to be bidirectional!" + ass);
// TODO put this 'calculation' into OrderConstraint class
befores.put(ass, createBeforesAssignments(ass, allAssignments));
followers.put(ass, createFollowsAssignments(ass, allAssignments));
for (Constraint constr : ass.getEvent().getConstraints()) {
if (constr instanceof DifferentDayConstraint
|| constr instanceof MinGapsConstraint) {
constr.transformEvents(eventToAss);
}
}
}
Period currentWeek = new Period(dataPoolSettings.getTimeslotsPerWeek(),
allAssignments, befores, followers,
allLocations, personToAssignments, conflictMatrix);
currentWeek.setRandom(random);
if (initialize) {
for (Assignment ass : allAssignments) {
if (ass.getStart() >= 0) {
if (!currentWeek.add(ass, ass.getStart())) {
currentWeek.add(ass, -1);
}
} else
currentWeek.add(ass, -1);
}