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