Search in sources :

Example 6 with StudentGroup

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;
}
Also used : Lecture(org.cpsolver.coursett.model.Lecture) HashMap(java.util.HashMap) Student(org.cpsolver.coursett.model.Student) StudentGroup(org.cpsolver.coursett.model.StudentGroup) HashSet(java.util.HashSet)

Example 7 with StudentGroup

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;
}
Also used : Lecture(org.cpsolver.coursett.model.Lecture) HashMap(java.util.HashMap) Student(org.cpsolver.coursett.model.Student) JenrlConstraint(org.cpsolver.coursett.constraint.JenrlConstraint) StudentGroup(org.cpsolver.coursett.model.StudentGroup) HashSet(java.util.HashSet)

Example 8 with StudentGroup

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);
        }
    }
}
Also used : Lecture(org.cpsolver.coursett.model.Lecture) StudentGroup(org.cpsolver.coursett.model.StudentGroup)

Aggregations

StudentGroup (org.cpsolver.coursett.model.StudentGroup)8 Lecture (org.cpsolver.coursett.model.Lecture)7 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Student (org.cpsolver.coursett.model.Student)4 JenrlConstraint (org.cpsolver.coursett.constraint.JenrlConstraint)3 ArrayList (java.util.ArrayList)2 BitSet (java.util.BitSet)2 List (java.util.List)2 Set (java.util.Set)2 ClassLimitConstraint (org.cpsolver.coursett.constraint.ClassLimitConstraint)2 DiscouragedRoomConstraint (org.cpsolver.coursett.constraint.DiscouragedRoomConstraint)2 GroupConstraint (org.cpsolver.coursett.constraint.GroupConstraint)2 IgnoreStudentConflictsConstraint (org.cpsolver.coursett.constraint.IgnoreStudentConflictsConstraint)2 InstructorConstraint (org.cpsolver.coursett.constraint.InstructorConstraint)2 MinimizeNumberOfUsedGroupsOfTime (org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime)2 MinimizeNumberOfUsedRoomsConstraint (org.cpsolver.coursett.constraint.MinimizeNumberOfUsedRoomsConstraint)2 RoomConstraint (org.cpsolver.coursett.constraint.RoomConstraint)2 SpreadConstraint (org.cpsolver.coursett.constraint.SpreadConstraint)2