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