    001package org.cpsolver.coursett.criteria.additional;
    002
    003import java.util.Collection;
    004import java.util.Map;
    005
    006import org.cpsolver.coursett.criteria.StudentConflict;
    007import org.cpsolver.coursett.model.Lecture;
    008import org.cpsolver.coursett.model.Placement;
    009import org.cpsolver.ifs.assignment.Assignment;
    010import org.cpsolver.ifs.criteria.Criterion;
    011import org.cpsolver.ifs.util.DataProperties;
    012
    013
    014/**
    015 * Ignored student conflicts. This criterion counts student conflicts (both overlapping and distance) between classes
    016 * which are connected by a {@link IgnoredStudentConflict} constraint. This criterion was created mostly for debugging
    017 * as these student conflicts are to be ignored.
    018 * <br>
    019 *
    020 * @version CourseTT 1.3 (University Course Timetabling)<br>
    021 *          Copyright (C) 2013 - 2014 Tomáš Müller<br>
    022 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    023 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    024 * <br>
    025 *          This library is free software; you can redistribute it and/or modify
    026 *          it under the terms of the GNU Lesser General Public License as
    027 *          published by the Free Software Foundation; either version 3 of the
    028 *          License, or (at your option) any later version. <br>
    029 * <br>
    030 *          This library is distributed in the hope that it will be useful, but
    031 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    032 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    033 *          Lesser General Public License for more details. <br>
    034 * <br>
    035 *          You should have received a copy of the GNU Lesser General Public
    036 *          License along with this library; if not see
    037 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    038 */
    039public class IgnoredStudentConflict extends StudentConflict {
    040
    041    @Override
    042    public boolean isApplicable(Lecture l1, Lecture l2) {
    043        return l1 != null && l2 != null && ignore(l1, l2) && applicable(l1, l2);
    044    }
    045
    046    @Override
    047    public double getWeightDefault(DataProperties config) {
    048        return config.getPropertyDouble("Comparator.IgnoredStudentConflictWeight", 0.0);
    049    }
    050
    051    @Override
    052    public String getPlacementSelectionWeightName() {
    053        return "Placement.NrIgnoredStudConfsWeight";
    054    }
    055
    056    @Override
    057    public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) {
    058        super.getInfo(assignment, info);
    059        double conf = getValue(assignment);
    060        if (conf > 0.0) {
    061            Criterion<Lecture, Placement> c = getModel().getCriterion(IgnoredCommittedStudentConflict.class);
    062            double committed = (c == null ? 0.0 : c.getValue(assignment));
    063            info.put("Ignored student conflicts", sDoubleFormat.format(conf) + (committed > 0.0 ? " [committed: " + sDoubleFormat.format(committed) + "]" : ""));
    064        }
    065    }
    066
    067    @Override
    068    public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info, Collection<Lecture> variables) {
    069        super.getInfo(assignment, info, variables);
    070        double conf = getValue(assignment, variables);
    071        if (conf > 0.0) {
    072            Criterion<Lecture, Placement> c = getModel().getCriterion(IgnoredCommittedStudentConflict.class);
    073            double committed = (c == null ? 0.0 : c.getValue(assignment, variables));
    074            info.put("Ignored student conflicts", sDoubleFormat.format(conf) + (committed > 0.0 ? " [committed: " + sDoubleFormat.format(committed) + "]" : ""));
    075        }
    076    }
    077}