001package org.cpsolver.coursett.criteria;
002
003import org.cpsolver.coursett.constraint.JenrlConstraint;
004import org.cpsolver.coursett.model.Lecture;
005import org.cpsolver.coursett.model.Placement;
006import org.cpsolver.coursett.model.TimeLocation;
007import org.cpsolver.ifs.util.DataProperties;
008import org.cpsolver.ifs.util.DistanceMetric;
009
010/**
011 * Student distance conflicts. This criterion counts student distance conflicts between classes.
012 * A distance conflict occurs when two classes that are attended by the same student (or students)
013 * are placed back-to-back in rooms that are too far a part. The combinations of classes
014 * that share students are maintained by {@link JenrlConstraint}. The critical distance is measured
015 * by {@link DistanceMetric#getDistanceInMinutes(Long, Double, Double, Long, Double, Double)} and compared
016 * witch class break time {@link TimeLocation#getBreakTime()}.
017 * <br>
018 * 
019 * @author  Tomáš Müller
020 * @version CourseTT 1.3 (University Course Timetabling)<br>
021 *          Copyright (C) 2006 - 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 StudentDistanceConflict extends StudentConflict {
040
041    @Override
042    public boolean inConflict(Placement p1, Placement p2) {
043        return distance(getMetrics(), p1, p2);
044    }
045    
046    @Override
047    public boolean isApplicable(Lecture l1, Lecture l2) {
048        return l1 != null && l2 != null && !ignore(l1, l2) && applicable(l1, l2); // all student conflicts (including committed)
049    }
050    
051    @Override
052    public double getWeightDefault(DataProperties config) {
053        return config.getPropertyDouble("Comparator.DistStudentConflictWeight", 0.2);
054    }
055    
056    @Override
057    public String getPlacementSelectionWeightName() {
058        return "Placement.NrDistStudConfsWeight";
059    }
060
061    
062}