Search in sources :

Example 6 with StudentSectioningModel

use of org.cpsolver.studentsct.StudentSectioningModel in project cpsolver by UniTime.

the class EnrollmentSelection method isAllowed.

/** true, if it is allowed to assign given value 
     * @param assignment current assignment
     * @param value given value
     * @param conflicts conflicting assignments
     * @return true if it is allowed
     **/
public boolean isAllowed(Assignment<Request, Enrollment> assignment, Enrollment value, Set<Enrollment> conflicts) {
    if (value == null)
        return true;
    StudentSectioningModel model = (StudentSectioningModel) value.variable().getModel();
    if (model.getNrLastLikeRequests(false) == 0 || model.getNrRealRequests(false) == 0)
        return true;
    Request request = value.variable();
    if (request.getStudent().isDummy()) {
        if (conflicts == null)
            conflicts = value.variable().getModel().conflictValues(assignment, value);
        for (Enrollment conflict : conflicts) {
            if (!conflict.getRequest().getStudent().isDummy())
                return false;
        }
    } else {
        if (conflicts == null)
            conflicts = value.variable().getModel().conflictValues(assignment, value);
        if (conflicts.size() > (assignment.getValue(request) == null ? 1 : 0))
            return false;
    }
    return true;
}
Also used : Request(org.cpsolver.studentsct.model.Request) Enrollment(org.cpsolver.studentsct.model.Enrollment) StudentSectioningModel(org.cpsolver.studentsct.StudentSectioningModel)

Example 7 with StudentSectioningModel

use of org.cpsolver.studentsct.StudentSectioningModel in project cpsolver by UniTime.

the class PriorityConstructionSelection method nextCycle.

/** Increment cycle 
     * @param solution current solution
     **/
protected void nextCycle(Solution<Request, Enrollment> solution) {
    iCycle++;
    iImproved = false;
    sLog.debug("Assigning up to " + iCycle + " requests...");
    StudentSectioningModel m = (StudentSectioningModel) solution.getModel();
    double tv = m.getTotalValue(solution.getAssignment(), true);
    sLog.debug("**CURR** " + solution.getModel().toString() + ", TM:" + sDF.format(solution.getTime() / 3600.0) + "h, " + "TV:" + sDF.format(-tv) + " (" + sDF.format(-100.0 * tv / m.getStudents().size()) + "%)");
    iStudentsEnumeration = iStudents.iterator();
    Progress.getInstance(solution.getModel()).setPhase("Construction[" + iCycle + "]...", iStudents.size());
}
Also used : StudentSectioningModel(org.cpsolver.studentsct.StudentSectioningModel)

Aggregations

StudentSectioningModel (org.cpsolver.studentsct.StudentSectioningModel)7 Enrollment (org.cpsolver.studentsct.model.Enrollment)3 Request (org.cpsolver.studentsct.model.Request)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 CourseRequest (org.cpsolver.studentsct.model.CourseRequest)2 Student (org.cpsolver.studentsct.model.Student)2 HashMap (java.util.HashMap)1 TimeLocation (org.cpsolver.coursett.model.TimeLocation)1 RouletteWheelSelection (org.cpsolver.ifs.heuristics.RouletteWheelSelection)1 Course (org.cpsolver.studentsct.model.Course)1 Offering (org.cpsolver.studentsct.model.Offering)1 RequestGroup (org.cpsolver.studentsct.model.RequestGroup)1 Section (org.cpsolver.studentsct.model.Section)1 Subpart (org.cpsolver.studentsct.model.Subpart)1 Reservation (org.cpsolver.studentsct.reservation.Reservation)1