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' summary='Related Solver Parameters'> 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 * @version StudentSct 1.3 (Student Sectioning)<br> 040 * Copyright (C) 2007 - 2014 Tomáš Müller<br> 041 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 042 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br> 043 * <br> 044 * This library is free software; you can redistribute it and/or modify 045 * it under the terms of the GNU Lesser General Public License as 046 * published by the Free Software Foundation; either version 3 of the 047 * License, or (at your option) any later version. <br> 048 * <br> 049 * This library is distributed in the hope that it will be useful, but 050 * WITHOUT ANY WARRANTY; without even the implied warranty of 051 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 052 * Lesser General Public License for more details. <br> 053 * <br> 054 * You should have received a copy of the GNU Lesser General Public 055 * License along with this library; if not see 056 * <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>. 057 */ 058public class StudentConflictStatistics extends ConflictStatistics<Request, Enrollment> { 059 public double iRealStudentWeight = 2.0; 060 public double iDummyStudentWeight = 0.5; 061 062 public StudentConflictStatistics(Solver<Request, Enrollment> solver, DataProperties properties) { 063 super(solver, properties); 064 iRealStudentWeight = properties.getPropertyDouble("StudentConflictStatistics.RealStudentWeight", 065 iRealStudentWeight); 066 iDummyStudentWeight = properties.getPropertyDouble("StudentConflictStatistics.DummyStudentWeight", 067 iDummyStudentWeight); 068 } 069 070 @Override 071 public double countRemovals(long iteration, Enrollment conflictValue, Enrollment value) { 072 double ret = super.countRemovals(iteration, conflictValue, value); 073 if (ret == 0.0) 074 return ret; 075 Enrollment conflict = conflictValue; 076 /* 077 * Enrollment enrollment = (Enrollment)value; if 078 * (enrollment.getRequest() 079 * .getStudent().isDummy()==conflict.getRequest() 080 * .getStudent().isDummy()) return ret; 081 */ 082 return ret * (conflict.getRequest().getStudent().isDummy() ? iDummyStudentWeight : iRealStudentWeight); 083 } 084}