Search in sources :

Example 26 with TimetableModel

use of org.cpsolver.coursett.model.TimetableModel in project cpsolver by UniTime.

the class FlexibleConstraintCriterion method getInfo.

@Override
public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) {
    TimetableModel m = (TimetableModel) getModel();
    if (m.getFlexibleConstraints().isEmpty())
        return;
    for (FlexibleConstraintType type : FlexibleConstraintType.values()) {
        StringBuilder debug = null;
        int violated = 0, constraints = 0;
        for (FlexibleConstraint c : m.getFlexibleConstraints()) {
            if (type.equals(c.getType())) {
                constraints++;
                if (c.getContext(assignment).getPreference() > 0) {
                    violated++;
                    if (iDebug) {
                        if (debug == null)
                            debug = new StringBuilder(c.getOwner() + " (" + sDoubleFormat.format(c.getNrViolations(assignment, new HashSet<Placement>(), null)) + ")");
                        else
                            debug.append("; " + c.getOwner() + " (" + sDoubleFormat.format(c.getNrViolations(assignment, new HashSet<Placement>(), null)) + ")");
                    }
                }
            }
        }
        if (constraints > 0) {
            info.put(type.getName() + " Constraints", getPerc(violated, 0, constraints) + "% (" + violated + ")");
            if (iDebug && violated > 0)
                info.put(type.getName() + " Violations", debug.toString());
        }
    }
}
Also used : FlexibleConstraint(org.cpsolver.coursett.constraint.FlexibleConstraint) Placement(org.cpsolver.coursett.model.Placement) FlexibleConstraintType(org.cpsolver.coursett.constraint.FlexibleConstraint.FlexibleConstraintType) TimetableModel(org.cpsolver.coursett.model.TimetableModel) FlexibleConstraint(org.cpsolver.coursett.constraint.FlexibleConstraint) HashSet(java.util.HashSet)

Aggregations

TimetableModel (org.cpsolver.coursett.model.TimetableModel)26 Placement (org.cpsolver.coursett.model.Placement)18 Lecture (org.cpsolver.coursett.model.Lecture)17 HashMap (java.util.HashMap)7 Constraint (org.cpsolver.ifs.model.Constraint)7 HashSet (java.util.HashSet)6 BitSet (java.util.BitSet)5 JenrlConstraint (org.cpsolver.coursett.constraint.JenrlConstraint)5 ArrayList (java.util.ArrayList)4 InstructorConstraint (org.cpsolver.coursett.constraint.InstructorConstraint)4 StudentConflict (org.cpsolver.coursett.criteria.StudentConflict)4 GlobalConstraint (org.cpsolver.ifs.model.GlobalConstraint)4 SimpleNeighbour (org.cpsolver.ifs.model.SimpleNeighbour)4 WeakeningConstraint (org.cpsolver.ifs.model.WeakeningConstraint)4 DataProperties (org.cpsolver.ifs.util.DataProperties)4 File (java.io.File)3 TreeSet (java.util.TreeSet)3 DepartmentSpreadConstraint (org.cpsolver.coursett.constraint.DepartmentSpreadConstraint)3 GroupConstraint (org.cpsolver.coursett.constraint.GroupConstraint)3 RoomConstraint (org.cpsolver.coursett.constraint.RoomConstraint)3