use of org.cpsolver.coursett.model.StudentGroup 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;
}
use of org.cpsolver.coursett.model.StudentGroup in project cpsolver by UniTime.
the class StudentSwapSectioning method gp.
/**
* Student group percentage of a solution subset
*/
public static double gp(TimetableModel model, Collection<Lecture> variables) {
if (model.getStudentGroups().isEmpty())
return 0.0;
double ret = 0;
int count = 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()) {
if (variables != null && !variables.contains(lecture))
continue;
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);
}
if (match.isEmpty())
continue;
double value = 0.0;
for (Match m : match.values()) value += m.value();
ret += value / offeringIds.size();
count++;
}
return 100.0 * ret / count;
}
use of org.cpsolver.coursett.model.StudentGroup in project cpsolver by UniTime.
the class SctModel method decEnrollment.
/**
* Decrement enrollment of all classes of the given classes
*/
private void decEnrollment(SctStudent student, SctEnrollment enrollment, Map<Long, Double> limits, Map<Long, Map<Long, Match>> matches) {
for (Lecture lecture : enrollment.getLectures()) incEnrollment(lecture, limits, -student.getOfferingWeight());
for (StudentGroup group : student.getStudent().getGroups()) {
Map<Long, Match> match = matches.get(group.getId());
if (match == null) {
match = new HashMap<Long, Match>();
matches.put(group.getId(), match);
}
for (Lecture lecture : enrollment.getLectures()) {
Match m = match.get(lecture.getSchedulingSubpartId());
if (m == null) {
m = new Match(group, lecture);
match.put(lecture.getSchedulingSubpartId(), m);
}
m.dec(lecture);
}
}
}
Aggregations