    001package org.cpsolver.coursett.heuristics;
    002
    003import org.cpsolver.coursett.model.Lecture;
    004import org.cpsolver.coursett.model.Placement;
    005import org.cpsolver.ifs.criteria.Criterion;
    006import org.cpsolver.ifs.model.Model;
    007import org.cpsolver.ifs.solution.GeneralSolutionComparator;
    008import org.cpsolver.ifs.solution.Solution;
    009import org.cpsolver.ifs.util.DataProperties;
    010
    011/**
    012 * Timetable (solution) comparator. <br>
    013 * <br>
    014 * The quality of a solution is expressed as a weighted sum combining soft time
    015 * and classroom preferences, satisfied soft group constrains and the total
    016 * number of student conflicts. This allows us to express the importance of
    017 * different types of soft constraints. <br>
    018 * <br>
    019 * The solution comparator prefers a more complete solution (with a smaller
    020 * number of unassigned variables) and a solution with a smaller number of
    021 * perturbations among solutions with the same number of unassigned variables.
    022 * If both solutions have the same number of unassigned variables and
    023 * perturbations, the solution of better quality is selected. <br>
    024 * <br>
    025 * Parameters:
    026 * <table border='1' summary='Related Solver Parameters'>
    027 * <tr>
    028 * <th>Parameter</th>
    029 * <th>Type</th>
    030 * <th>Comment</th>
    031 * </tr>
    032 * <tr>
    033 * <td>Comparator.HardStudentConflictWeight</td>
    034 * <td>{@link Double}</td>
    035 * <td>Weight of hard student conflict (conflict between single-section classes)
    036 * </td>
    037 * </tr>
    038 * <tr>
    039 * <td>Comparator.StudentConflictWeight</td>
    040 * <td>{@link Double}</td>
    041 * <td>Weight of student conflict</td>
    042 * </tr>
    043 * <tr>
    044 * <td>Comparator.TimePreferenceWeight</td>
    045 * <td>{@link Double}</td>
    046 * <td>Time preferences weight</td>
    047 * </tr>
    048 * <tr>
    049 * <td>Comparator.ContrPreferenceWeight</td>
    050 * <td>{@link Double}</td>
    051 * <td>Group constraint preferences weight</td>
    052 * </tr>
    053 * <tr>
    054 * <td>Comparator.RoomPreferenceWeight</td>
    055 * <td>{@link Double}</td>
    056 * <td>Room preferences weight</td>
    057 * </tr>
    058 * <tr>
    059 * <td>Comparator.UselessSlotWeight</td>
    060 * <td>{@link Double}</td>
    061 * <td>Useless slots weight</td>
    062 * </tr>
    063 * <tr>
    064 * <td>Comparator.TooBigRoomWeight</td>
    065 * <td>{@link Double}</td>
    066 * <td>Too big room weight</td>
    067 * </tr>
    068 * <tr>
    069 * <td>Comparator.DistanceInstructorPreferenceWeight</td>
    070 * <td>{@link Double}</td>
    071 * <td>Distance (of the rooms of the back-to-back classes) based instructor
    072 * preferences weight</td>
    073 * </tr>
    074 * <tr>
    075 * <td>Comparator.PerturbationPenaltyWeight</td>
    076 * <td>{@link Double}</td>
    077 * <td>Perturbation penalty (see {@link UniversalPerturbationsCounter})</td>
    078 * </tr>
    079 * <tr>
    080 * <td>Comparator.DeptSpreadPenaltyWeight</td>
    081 * <td>{@link Double}</td>
    082 * <td>Department balancing penalty (see
    083 * {@link org.cpsolver.coursett.constraint.DepartmentSpreadConstraint})</td>
    084 * </tr>
    085 * </table>
    086 *
    087 *
    088 * @version CourseTT 1.3 (University Course Timetabling)<br>
    089 *          Copyright (C) 2006 - 2014 Tomáš Müller<br>
    090 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    091 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    092 * <br>
    093 *          This library is free software; you can redistribute it and/or modify
    094 *          it under the terms of the GNU Lesser General Public License as
    095 *          published by the Free Software Foundation; either version 3 of the
    096 *          License, or (at your option) any later version. <br>
    097 * <br>
    098 *          This library is distributed in the hope that it will be useful, but
    099 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    100 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    101 *          Lesser General Public License for more details. <br>
    102 * <br>
    103 *          You should have received a copy of the GNU Lesser General Public
    104 *          License along with this library; if not see
    105 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    106 */
    107@Deprecated
    108public class TimetableComparator extends GeneralSolutionComparator<Lecture, Placement> {
    109
    110    public TimetableComparator(DataProperties properties) {
    111        super(properties);
    112    }
    113
    114    /**
    115     * Use {@link Model#getTotalValue()} instead.
    116     * @param currentSolution current solution
    117     * @return current value
    118     */
    119    @Deprecated
    120    public double currentValue(Solution<Lecture, Placement> currentSolution) {
    121        double ret = 0.0;
    122        for (Criterion<Lecture, Placement> criterion: currentSolution.getModel().getCriteria())
    123            ret += criterion.getWeightedValue();
    124        return ret;
    125    }
    126
    127    /**
    128     * Use {@link Solution#getBestValue()} instead.
    129     * @param currentSolution current solution
    130     * @return best value
    131     */
    132    @Deprecated
    133    public double getBest(Solution<Lecture, Placement> currentSolution) {
    134        double ret = 0.0;
    135        for (Criterion<Lecture, Placement> criterion: currentSolution.getModel().getCriteria())
    136            ret += criterion.getWeightedBest();
    137        return ret;
    138    }
    139}