001package org.cpsolver.coursett.criteria.additional; 002 003import java.util.Collection; 004import java.util.Map; 005 006import org.cpsolver.coursett.criteria.StudentConflict; 007import org.cpsolver.coursett.model.Lecture; 008import org.cpsolver.coursett.model.Placement; 009import org.cpsolver.ifs.assignment.Assignment; 010import org.cpsolver.ifs.criteria.Criterion; 011import org.cpsolver.ifs.util.DataProperties; 012 013 014/** 015 * Ignored student conflicts. This criterion counts student conflicts (both overlapping and distance) between classes 016 * which are connected by a {@link IgnoredStudentConflict} constraint. This criterion was created mostly for debugging 017 * as these student conflicts are to be ignored. 018 * <br> 019 * 020 * @author Tomáš Müller 021 * @version CourseTT 1.3 (University Course Timetabling)<br> 022 * Copyright (C) 2013 - 2014 Tomáš Müller<br> 023 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 024 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br> 025 * <br> 026 * This library is free software; you can redistribute it and/or modify 027 * it under the terms of the GNU Lesser General Public License as 028 * published by the Free Software Foundation; either version 3 of the 029 * License, or (at your option) any later version. <br> 030 * <br> 031 * This library is distributed in the hope that it will be useful, but 032 * WITHOUT ANY WARRANTY; without even the implied warranty of 033 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 034 * Lesser General Public License for more details. <br> 035 * <br> 036 * You should have received a copy of the GNU Lesser General Public 037 * License along with this library; if not see 038 * <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>. 039 */ 040public class IgnoredStudentConflict extends StudentConflict { 041 042 @Override 043 public boolean isApplicable(Lecture l1, Lecture l2) { 044 return l1 != null && l2 != null && ignore(l1, l2) && applicable(l1, l2); 045 } 046 047 @Override 048 public double getWeightDefault(DataProperties config) { 049 return config.getPropertyDouble("Comparator.IgnoredStudentConflictWeight", 0.0); 050 } 051 052 @Override 053 public String getPlacementSelectionWeightName() { 054 return "Placement.NrIgnoredStudConfsWeight"; 055 } 056 057 @Override 058 public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) { 059 super.getInfo(assignment, info); 060 double conf = getValue(assignment); 061 if (conf > 0.0) { 062 Criterion<Lecture, Placement> c = getModel().getCriterion(IgnoredCommittedStudentConflict.class); 063 double committed = (c == null ? 0.0 : c.getValue(assignment)); 064 info.put("Ignored student conflicts", sDoubleFormat.format(conf) + (committed > 0.0 ? " [committed: " + sDoubleFormat.format(committed) + "]" : "")); 065 } 066 } 067 068 @Override 069 public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info, Collection<Lecture> variables) { 070 super.getInfo(assignment, info, variables); 071 double conf = getValue(assignment, variables); 072 if (conf > 0.0) { 073 Criterion<Lecture, Placement> c = getModel().getCriterion(IgnoredCommittedStudentConflict.class); 074 double committed = (c == null ? 0.0 : c.getValue(assignment, variables)); 075 info.put("Ignored student conflicts", sDoubleFormat.format(conf) + (committed > 0.0 ? " [committed: " + sDoubleFormat.format(committed) + "]" : "")); 076 } 077 } 078}