    001package org.cpsolver.studentsct.extension;
    002
    003import org.cpsolver.ifs.extension.ConflictStatistics;
    004import org.cpsolver.ifs.solver.Solver;
    005import org.cpsolver.ifs.util.DataProperties;
    006import org.cpsolver.studentsct.model.Enrollment;
    007import org.cpsolver.studentsct.model.Request;
    008import org.cpsolver.studentsct.model.Student;
    009
    010/**
    011 * Same as {@link ConflictStatistics}, however, conflict with real students can
    012 * be weighted differently than with last-like students.
    013 *
    014 * <br>
    015 * <br>
    016 * Parameters: <br>
    017 * <table border='1'><caption>Related Solver Parameters</caption>
    018 * <tr>
    019 * <th>Parameter</th>
    020 * <th>Type</th>
    021 * <th>Comment</th>
    022 * </tr>
    023 * <tr>
    024 * <td>StudentConflictStatistics.RealStudentWeight</td>
    025 * <td>{@link Double}</td>
    026 * <td>
    027 * Weight of a conflict with a real student ({@link Student#isDummy()} is
    028 * false).</td>
    029 * </tr>
    030 * <tr>
    031 * <td>StudentConflictStatistics.RealStudentWeight</td>
    032 * <td>{@link Double}</td>
    033 * <td>
    034 * Weight of a conflict with a last-like student ({@link Student#isDummy()} is
    035 * true).</td>
    036 * </tr>
    037 * </table>
    038 *
    039 * @author  Tomáš Müller
    040 * @version StudentSct 1.3 (Student Sectioning)<br>
    041 *          Copyright (C) 2007 - 2014 Tomáš Müller<br>
    042 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    043 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    044 * <br>
    045 *          This library is free software; you can redistribute it and/or modify
    046 *          it under the terms of the GNU Lesser General Public License as
    047 *          published by the Free Software Foundation; either version 3 of the
    048 *          License, or (at your option) any later version. <br>
    049 * <br>
    050 *          This library is distributed in the hope that it will be useful, but
    051 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    052 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    053 *          Lesser General Public License for more details. <br>
    054 * <br>
    055 *          You should have received a copy of the GNU Lesser General Public
    056 *          License along with this library; if not see
    057 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    058 */
    059public class StudentConflictStatistics extends ConflictStatistics<Request, Enrollment> {
    060    public double iRealStudentWeight = 2.0;
    061    public double iDummyStudentWeight = 0.5;
    062
    063    public StudentConflictStatistics(Solver<Request, Enrollment> solver, DataProperties properties) {
    064        super(solver, properties);
    065        iRealStudentWeight = properties.getPropertyDouble("StudentConflictStatistics.RealStudentWeight",
    066                iRealStudentWeight);
    067        iDummyStudentWeight = properties.getPropertyDouble("StudentConflictStatistics.DummyStudentWeight",
    068                iDummyStudentWeight);
    069    }
    070
    071    @Override
    072    public double countRemovals(long iteration, Enrollment conflictValue, Enrollment value) {
    073        double ret = super.countRemovals(iteration, conflictValue, value);
    074        if (ret == 0.0)
    075            return ret;
    076        Enrollment conflict = conflictValue;
    077        /*
    078         * Enrollment enrollment = (Enrollment)value; if
    079         * (enrollment.getRequest()
    080         * .getStudent().isDummy()==conflict.getRequest()
    081         * .getStudent().isDummy()) return ret;
    082         */
    083        return ret * (conflict.getRequest().getStudent().isDummy() ? iDummyStudentWeight : iRealStudentWeight);
    084    }
    085}