Search in sources :

Example 16 with Request

use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.

the class BranchBoundSelection method selectNeighbour.

/**
     * Select neighbour. All students are taken, one by one in a random order.
     * For each student a branch & bound search is employed.
     */
@Override
public Neighbour<Request, Enrollment> selectNeighbour(Solution<Request, Enrollment> solution) {
    Student student = null;
    while ((student = nextStudent()) != null) {
        Progress.getInstance(solution.getModel()).incProgress();
        Neighbour<Request, Enrollment> neighbour = getSelection(solution.getAssignment(), student).select();
        if (neighbour != null)
            return neighbour;
    }
    return null;
}
Also used : FreeTimeRequest(org.cpsolver.studentsct.model.FreeTimeRequest) Request(org.cpsolver.studentsct.model.Request) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) Enrollment(org.cpsolver.studentsct.model.Enrollment) Student(org.cpsolver.studentsct.model.Student)

Example 17 with Request

use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.

the class OnlineSelection method setPenalties.

/**
     * Set online sectioning penalties to all sections of all courses of the
     * given student
     */
private static void setPenalties(Assignment<Request, Enrollment> assignment, Student student) {
    for (Request request : student.getRequests()) {
        if (!(request instanceof CourseRequest))
            continue;
        CourseRequest courseRequest = (CourseRequest) request;
        for (Course course : courseRequest.getCourses()) {
            for (Config config : course.getOffering().getConfigs()) {
                for (Subpart subpart : config.getSubparts()) {
                    for (Section section : subpart.getSections()) {
                        section.setPenalty(section.getOnlineSectioningPenalty(assignment));
                    }
                }
            }
        }
        courseRequest.clearCache();
    }
}
Also used : CourseRequest(org.cpsolver.studentsct.model.CourseRequest) Config(org.cpsolver.studentsct.model.Config) Subpart(org.cpsolver.studentsct.model.Subpart) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) Request(org.cpsolver.studentsct.model.Request) Course(org.cpsolver.studentsct.model.Course) Section(org.cpsolver.studentsct.model.Section)

Example 18 with Request

use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.

the class ResectionIncompleteStudentsSelection method selectNeighbour.

/**
     * Select neighbour. All students with an incomplete and non-empty schedule
     * are taken, one by one in a random order. For each student a branch &amp; 
     * bound search is employed.
     */
@Override
public Neighbour<Request, Enrollment> selectNeighbour(Solution<Request, Enrollment> solution) {
    Student student = null;
    while ((student = nextStudent()) != null) {
        Progress.getInstance(solution.getModel()).incProgress();
        if (student.nrAssignedRequests(solution.getAssignment()) == 0 || student.isComplete(solution.getAssignment()))
            continue;
        Neighbour<Request, Enrollment> neighbour = getSelection(solution.getAssignment(), student).select();
        if (neighbour != null)
            return neighbour;
    }
    return null;
}
Also used : Request(org.cpsolver.studentsct.model.Request) Enrollment(org.cpsolver.studentsct.model.Enrollment) Student(org.cpsolver.studentsct.model.Student)

Example 19 with Request

use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.

the class StudentConflict method computeConflicts.

/**
     * A given enrollment is conflicting when the student is enrolled into
     * another course / free time request that has an assignment that is
     * overlapping with one or more assignments of the given section. See
     * {@link Enrollment#isOverlapping(Enrollment)} for more details. All such
     * overlapping enrollments are added into the provided set of conflicts.
     * 
     * @param enrollment
     *            {@link Enrollment} that is being considered
     * @param conflicts
     *            resultant list of conflicting enrollments
     */
@Override
public void computeConflicts(Assignment<Request, Enrollment> assignment, Enrollment enrollment, Set<Enrollment> conflicts) {
    // enrollment -> conflict
    for (Request request : variables()) {
        if (request.equals(enrollment.getRequest()))
            continue;
        Enrollment e = assignment.getValue(request);
        if (e == null)
            continue;
        if (enrollment.isOverlapping(e))
            conflicts.add(e);
    }
    // schedule) -> unassignd a lowest priority request
    if (!enrollment.getAssignments().isEmpty() && !enrollment.getStudent().canAssign(assignment, enrollment.getRequest())) {
        Enrollment lowestPriorityEnrollment = null;
        int lowestPriority = -1;
        for (Request request : variables()) {
            if (request.equals(enrollment.getRequest()))
                continue;
            Enrollment e = assignment.getValue(request);
            if (e == null)
                continue;
            if (lowestPriority < request.getPriority()) {
                lowestPriority = request.getPriority();
                lowestPriorityEnrollment = e;
            }
        }
        if (lowestPriorityEnrollment != null)
            conflicts.add(lowestPriorityEnrollment);
    }
}
Also used : Request(org.cpsolver.studentsct.model.Request) Enrollment(org.cpsolver.studentsct.model.Enrollment) Constraint(org.cpsolver.ifs.model.Constraint)

Example 20 with Request

use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.

the class DistanceConflict method countTotalNrConflicts.

/**
     * Compute the actual number of all distance conflicts. Should be equal to
     * {@link DistanceConflict#getTotalNrConflicts(Assignment)}.
     * @param assignment current assignment
     * @return computed number of all distance conflicts
     */
public int countTotalNrConflicts(Assignment<Request, Enrollment> assignment) {
    int total = 0;
    for (Request r1 : getModel().variables()) {
        if (assignment.getValue(r1) == null || !(r1 instanceof CourseRequest))
            continue;
        Enrollment e1 = assignment.getValue(r1);
        total += nrConflicts(e1);
        for (Request r2 : r1.getStudent().getRequests()) {
            Enrollment e2 = assignment.getValue(r2);
            if (e2 == null || r1.getId() >= r2.getId() || !(r2 instanceof CourseRequest))
                continue;
            total += nrConflicts(e1, e2);
        }
    }
    return total;
}
Also used : CourseRequest(org.cpsolver.studentsct.model.CourseRequest) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) Request(org.cpsolver.studentsct.model.Request) Enrollment(org.cpsolver.studentsct.model.Enrollment)

Aggregations

Request (org.cpsolver.studentsct.model.Request)65 CourseRequest (org.cpsolver.studentsct.model.CourseRequest)51 Enrollment (org.cpsolver.studentsct.model.Enrollment)47 FreeTimeRequest (org.cpsolver.studentsct.model.FreeTimeRequest)23 Section (org.cpsolver.studentsct.model.Section)22 ArrayList (java.util.ArrayList)21 Student (org.cpsolver.studentsct.model.Student)21 Course (org.cpsolver.studentsct.model.Course)20 HashSet (java.util.HashSet)18 HashMap (java.util.HashMap)14 Subpart (org.cpsolver.studentsct.model.Subpart)10 Map (java.util.Map)9 DataProperties (org.cpsolver.ifs.util.DataProperties)9 Config (org.cpsolver.studentsct.model.Config)8 Offering (org.cpsolver.studentsct.model.Offering)8 Set (java.util.Set)7 DefaultSingleAssignment (org.cpsolver.ifs.assignment.DefaultSingleAssignment)7 File (java.io.File)6 IOException (java.io.IOException)6 TreeSet (java.util.TreeSet)6