001package org.cpsolver.exam.criteria; 002 003import java.util.Map; 004import java.util.Set; 005 006import org.cpsolver.exam.model.Exam; 007import org.cpsolver.exam.model.ExamPlacement; 008import org.cpsolver.exam.model.ExamStudent; 009import org.cpsolver.ifs.assignment.Assignment; 010 011 012/** 013 * Number of direct student conflicts caused by the fact that a student is 014 * not available. 015 * <br><br> 016 * Direct student conflict weight can be set by problem property 017 * Exams.DirectConflictWeight, or in the input xml file, property 018 * directConflictWeight. 019 * 020 * <br> 021 * 022 * @version ExamTT 1.3 (Examination Timetabling)<br> 023 * Copyright (C) 2008 - 2014 Tomas Muller<br> 024 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 025 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br> 026 * <br> 027 * This library is free software; you can redistribute it and/or modify 028 * it under the terms of the GNU Lesser General Public License as 029 * published by the Free Software Foundation; either version 3 of the 030 * License, or (at your option) any later version. <br> 031 * <br> 032 * This library is distributed in the hope that it will be useful, but 033 * WITHOUT ANY WARRANTY; without even the implied warranty of 034 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 035 * Lesser General Public License for more details. <br> 036 * <br> 037 * You should have received a copy of the GNU Lesser General Public 038 * License along with this library; if not see 039 * <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>. 040 */ 041public class StudentNotAvailableConflicts extends StudentDirectConflicts { 042 043 @Override 044 public double getValue(Assignment<Exam, ExamPlacement> assignment, ExamPlacement value, Set<ExamPlacement> conflicts) { 045 Exam exam = value.variable(); 046 int penalty = 0; 047 for (ExamStudent s : exam.getStudents()) { 048 if (!s.isAvailable(value.getPeriod())) 049 penalty++; 050 } 051 return penalty; 052 } 053 054 @Override 055 public String getName() { 056 return "Not Available Conflicts"; 057 } 058 059 @Override 060 public void getInfo(Assignment<Exam, ExamPlacement> assignment, Map<String, String> info) { 061 } 062 063 @Override 064 public String toString(Assignment<Exam, ExamPlacement> assignment) { 065 return (getValue(assignment) <= 0.0 ? "" : "NA:" + sDoubleFormat.format(getValue(assignment))); 066 } 067 068}