001package net.sf.cpsolver.coursett.criteria.additional;
002
003import net.sf.cpsolver.coursett.constraint.JenrlConstraint;
004import net.sf.cpsolver.coursett.criteria.StudentConflict;
005import net.sf.cpsolver.coursett.model.Lecture;
006import net.sf.cpsolver.coursett.model.Student;
007import net.sf.cpsolver.ifs.util.DataProperties;
008
009/**
010 * Quadratic student conflicts. Same as {@link StudentConflict}, however,
011 * student joint enrollments are squared (1 conflict counts as 1, 2 as 4, 3 as 9, etc.).
012 * 
013 * <br>
014 * 
015 * @version CourseTT 1.2 (University Course Timetabling)<br>
016 *          Copyright (C) 2006 - 2011 Tomáš Müller<br>
017 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
018 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
019 * <br>
020 *          This library is free software; you can redistribute it and/or modify
021 *          it under the terms of the GNU Lesser General Public License as
022 *          published by the Free Software Foundation; either version 3 of the
023 *          License, or (at your option) any later version. <br>
024 * <br>
025 *          This library is distributed in the hope that it will be useful, but
026 *          WITHOUT ANY WARRANTY; without even the implied warranty of
027 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
028 *          Lesser General Public License for more details. <br>
029 * <br>
030 *          You should have received a copy of the GNU Lesser General Public
031 *          License along with this library; if not see
032 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
033 */
034
035public class QuadraticStudentConflict extends StudentConflict {
036    
037    @Override
038    public boolean isApplicable(Lecture l1, Lecture l2) {
039        return applicable(l1, l2);
040    }
041
042    @Override
043    public double getWeightDefault(DataProperties config) {
044        return config.getPropertyDouble("Comparator.StudentConflictWeight", 1.0);
045    }
046    
047    @Override
048    public String getPlacementSelectionWeightName() {
049        return "Placement.NrStudConfsWeight";
050    }
051
052    @Override
053    protected double jointEnrollment(JenrlConstraint jenrl) {
054        return jenrl.jenrl() * jenrl.jenrl();
055    }
056    
057    @Override
058    public void incJenrl(JenrlConstraint jenrl, double studentWeight, Double conflictPriority, Student student) {
059        if (inConflict(jenrl.first().getAssignment(), jenrl.second().getAssignment())) {
060            iValue += (jenrl.jenrl() * jenrl.jenrl()) - (jenrl.jenrl() - studentWeight) * (jenrl.jenrl() - studentWeight);
061        }
062    }
063    
064}