Search in sources :

Example 76 with Lecture

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

Example 77 with Lecture

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

Example 78 with Lecture

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

Example 79 with Lecture

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

Example 80 with Lecture

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;
}
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)

Aggregations

Lecture (org.cpsolver.coursett.model.Lecture)96 Placement (org.cpsolver.coursett.model.Placement)55 HashSet (java.util.HashSet)35 TimetableModel (org.cpsolver.coursett.model.TimetableModel)17 WeakeningConstraint (org.cpsolver.ifs.model.WeakeningConstraint)17 HashMap (java.util.HashMap)16 ArrayList (java.util.ArrayList)14 TimeLocation (org.cpsolver.coursett.model.TimeLocation)14 Constraint (org.cpsolver.ifs.model.Constraint)14 InstructorConstraint (org.cpsolver.coursett.constraint.InstructorConstraint)13 Student (org.cpsolver.coursett.model.Student)13 BitSet (java.util.BitSet)11 JenrlConstraint (org.cpsolver.coursett.constraint.JenrlConstraint)10 GlobalConstraint (org.cpsolver.ifs.model.GlobalConstraint)9 RoomLocation (org.cpsolver.coursett.model.RoomLocation)8 Set (java.util.Set)7 TreeSet (java.util.TreeSet)7 GroupConstraint (org.cpsolver.coursett.constraint.GroupConstraint)7 StudentGroup (org.cpsolver.coursett.model.StudentGroup)7 RoomConstraint (org.cpsolver.coursett.constraint.RoomConstraint)6