Search in sources :

Example 16 with JenrlConstraint

use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.

the class StudentSwap method incJenrl.

/**
     * Increment {@link JenrlConstraint} between the given two classes by the given student
     */
protected void incJenrl(Assignment<Lecture, Placement> assignment, Student student, Lecture l1, Lecture l2) {
    if (l1.equals(l2))
        return;
    JenrlConstraint jenrl = l1.jenrlConstraint(l2);
    if (jenrl == null) {
        jenrl = new JenrlConstraint();
        jenrl.addVariable(l1);
        jenrl.addVariable(l2);
        iModel.addConstraint(jenrl);
    }
    jenrl.incJenrl(assignment, student);
}
Also used : JenrlConstraint(org.cpsolver.coursett.constraint.JenrlConstraint)

Example 17 with JenrlConstraint

use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.

the class StudentConflict method getValue.

@Override
public double getValue(Assignment<Lecture, Placement> assignment, Collection<Lecture> variables) {
    double ret = 0.0;
    Set<JenrlConstraint> constraints = new HashSet<JenrlConstraint>();
    for (Lecture lect : variables) {
        Placement plac = assignment.getValue(lect);
        if (plac == null)
            continue;
        for (JenrlConstraint jenrl : lect.jenrlConstraints()) {
            if (!constraints.add(jenrl))
                continue;
            Lecture other = jenrl.another(lect);
            if (!other.isCommitted() && !variables.contains(other))
                continue;
            if (!isApplicable(lect, other))
                continue;
            if (inConflict(plac, assignment.getValue(other)))
                ret += jointEnrollment(jenrl);
        }
    }
    return ret;
}
Also used : JenrlConstraint(org.cpsolver.coursett.constraint.JenrlConstraint) Lecture(org.cpsolver.coursett.model.Lecture) Placement(org.cpsolver.coursett.model.Placement) HashSet(java.util.HashSet)

Example 18 with JenrlConstraint

use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.

the class StudentConflict method getValue.

@Override
public double getValue(Assignment<Lecture, Placement> assignment, Placement value, Set<Placement> conflicts) {
    double ret = 0.0;
    for (JenrlConstraint jenrl : value.variable().jenrlConstraints()) {
        Lecture other = jenrl.another(value.variable());
        if (!isApplicable(value.variable(), other))
            continue;
        Placement another = assignment.getValue(other);
        if (another == null)
            continue;
        if (conflicts != null && conflicts.contains(another))
            continue;
        if (inConflict(value, another))
            ret += jointEnrollment(jenrl);
    }
    if (iIncludeConflicts && conflicts != null)
        for (Placement conflict : conflicts) {
            for (JenrlConstraint jenrl : conflict.variable().jenrlConstraints()) {
                Lecture other = jenrl.another(conflict.variable());
                if (!isApplicable(conflict.variable(), other))
                    continue;
                Placement another = assignment.getValue(other);
                if (another == null || another.variable().equals(value.variable()))
                    continue;
                if (conflicts != null && conflicts.contains(another))
                    continue;
                if (inConflict(conflict, another))
                    ret -= jointEnrollment(jenrl);
            }
        }
    return ret;
}
Also used : JenrlConstraint(org.cpsolver.coursett.constraint.JenrlConstraint) Lecture(org.cpsolver.coursett.model.Lecture) Placement(org.cpsolver.coursett.model.Placement)

Aggregations

JenrlConstraint (org.cpsolver.coursett.constraint.JenrlConstraint)18 HashSet (java.util.HashSet)8 DepartmentSpreadConstraint (org.cpsolver.coursett.constraint.DepartmentSpreadConstraint)7 GroupConstraint (org.cpsolver.coursett.constraint.GroupConstraint)7 InstructorConstraint (org.cpsolver.coursett.constraint.InstructorConstraint)7 SpreadConstraint (org.cpsolver.coursett.constraint.SpreadConstraint)7 Lecture (org.cpsolver.coursett.model.Lecture)6 ClassLimitConstraint (org.cpsolver.coursett.constraint.ClassLimitConstraint)5 RoomConstraint (org.cpsolver.coursett.constraint.RoomConstraint)5 Placement (org.cpsolver.coursett.model.Placement)5 Constraint (org.cpsolver.ifs.model.Constraint)5 HashMap (java.util.HashMap)4 FlexibleConstraint (org.cpsolver.coursett.constraint.FlexibleConstraint)4 TimetableModel (org.cpsolver.coursett.model.TimetableModel)4 WeakeningConstraint (org.cpsolver.ifs.model.WeakeningConstraint)4 ArrayList (java.util.ArrayList)3 StudentConflict (org.cpsolver.coursett.criteria.StudentConflict)3 Student (org.cpsolver.coursett.model.Student)3 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2