001 package net.sf.cpsolver.exam.criteria;
002
003 import java.util.Map;
004 import java.util.Set;
005
006 import net.sf.cpsolver.exam.model.Exam;
007 import net.sf.cpsolver.exam.model.ExamPlacement;
008 import net.sf.cpsolver.exam.model.ExamStudent;
009
010 /**
011 * Number of direct student conflicts caused by the fact that a student is
012 * not available.
013 * <br><br>
014 * Direct student conflict weight can be set by problem property
015 * Exams.DirectConflictWeight, or in the input xml file, property
016 * directConflictWeight.
017 *
018 * <br>
019 *
020 * @version ExamTT 1.2 (Examination Timetabling)<br>
021 * Copyright (C) 2008 - 2012 Tomas Muller<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 */
039 public class StudentNotAvailableConflicts extends StudentDirectConflicts {
040
041 @Override
042 public double getValue(ExamPlacement value, Set<ExamPlacement> conflicts) {
043 Exam exam = value.variable();
044 int penalty = 0;
045 for (ExamStudent s : exam.getStudents()) {
046 if (!s.isAvailable(value.getPeriod()))
047 penalty++;
048 }
049 return penalty;
050 }
051
052 @Override
053 public String getName() {
054 return "Not Available Conflicts";
055 }
056
057 @Override
058 public void getInfo(Map<String, String> info) {
059 }
060
061 @Override
062 public String toString() {
063 return (getValue() <= 0.0 ? "" : "NA:" + sDoubleFormat.format(getValue()));
064 }
065
066 }