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 * @version CourseTT 1.3 (University Course Timetabling)<br>
020 *          Copyright (C) 2006 - 2014 Tomáš Müller<br>
021 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
022 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
023 * <br>
024 *          This library is free software; you can redistribute it and/or modify
025 *          it under the terms of the GNU Lesser General Public License as
026 *          published by the Free Software Foundation; either version 3 of the
027 *          License, or (at your option) any later version. <br>
028 * <br>
029 *          This library is distributed in the hope that it will be useful, but
030 *          WITHOUT ANY WARRANTY; without even the implied warranty of
031 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
032 *          Lesser General Public License for more details. <br>
033 * <br>
034 *          You should have received a copy of the GNU Lesser General Public
035 *          License along with this library; if not see
036 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
037 */
038public class StudentDistanceConflict extends StudentConflict {
039
040    @Override
041    public boolean inConflict(Placement p1, Placement p2) {
042        return distance(getMetrics(), p1, p2);
043    }
044    
045    @Override
046    public boolean isApplicable(Lecture l1, Lecture l2) {
047        return l1 != null && l2 != null && !ignore(l1, l2) && applicable(l1, l2); // all student conflicts (including committed)
048    }
049    
050    @Override
051    public double getWeightDefault(DataProperties config) {
052        return config.getPropertyDouble("Comparator.DistStudentConflictWeight", 0.2);
053    }
054    
055    @Override
056    public String getPlacementSelectionWeightName() {
057        return "Placement.NrDistStudConfsWeight";
058    }
059
060    
061}