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.constraint.JenrlConstraint;
007 import net.sf.cpsolver.coursett.model.Lecture;
008 import net.sf.cpsolver.coursett.model.Student;
009 import net.sf.cpsolver.ifs.util.DataProperties;
010
011 /**
012 * Instructor student conflicts. This criterion penalizes cases when an instructor (of a class) is attending some
013 * other class as a student and there is a conflict between the two classes. Also, there is no alternative for the
014 * student class (the conflict cannot be sectioned away).
015 * <br>
016 * To enable instructor student conflicts, set solver parameter Global.LoadStudentInstructorConflicts to true. Also
017 * student course requests should be used in this case (to be able to match an instructor external id to a student
018 * external id).
019 * <br>
020 * Hard instructor student conflicts are weighted by Comparator.InstructorHardStudentConflictWeight.
021 * <br>
022 *
023 * @version CourseTT 1.2 (University Course Timetabling)<br>
024 * Copyright (C) 2006 - 2011 Tomas Muller<br>
025 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
026 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
027 * <br>
028 * This library is free software; you can redistribute it and/or modify
029 * it under the terms of the GNU Lesser General Public License as
030 * published by the Free Software Foundation; either version 3 of the
031 * License, or (at your option) any later version. <br>
032 * <br>
033 * This library is distributed in the hope that it will be useful, but
034 * WITHOUT ANY WARRANTY; without even the implied warranty of
035 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
036 * Lesser General Public License for more details. <br>
037 * <br>
038 * You should have received a copy of the GNU Lesser General Public
039 * License along with this library; if not see
040 * <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
041 */
042 public class InstructorStudentHardConflict extends InstructorStudentConflict {
043
044 @Override
045 public boolean isApplicable(Lecture l1, Lecture l2) {
046 return super.isApplicable(l1, l2) && oneInstructorOtherHard(l1, l2);
047 }
048
049 /**
050 * One of the lectures is hard, there is a joint enrollment constraint between them, and
051 * there is at least one student that is instructor for one lecture and the other lecture
052 * is singleton.
053 */
054 public static boolean oneInstructorOtherHard(Lecture l1, Lecture l2) {
055 if (!hard(l1, l2)) return false;
056 JenrlConstraint jenrl = l1.jenrlConstraint(l2);
057 if (jenrl == null) return false;
058 for (Student student: jenrl.getInstructors()) {
059 if ((l1.isSingleSection() || student.getInstructor().variables().contains(jenrl.second())) &&
060 (l2.isSingleSection() || student.getInstructor().variables().contains(jenrl.first())))
061 return true;
062 }
063 return false;
064 }
065
066 @Override
067 public double getWeightDefault(DataProperties config) {
068 return config.getPropertyDouble("Comparator.InstructorHardStudentConflictWeight", 10.0 * config.getPropertyDouble("Comparator.HardStudentConflictWeight", 5.0));
069 }
070
071 @Override
072 public String getPlacementSelectionWeightName() {
073 return "Placement.NrInstructorHardStudConfsWeight";
074 }
075
076 @Override
077 public void getInfo(Map<String, String> info) {
078 }
079
080 @Override
081 public void getInfo(Map<String, String> info, Collection<Lecture> variables) {
082 }
083
084 }