001 package net.sf.cpsolver.coursett.preference; 002 003 /** 004 * Average preference combination. 005 * <br> 006 * <ul> 007 * <li>If at least one preference is required -> required 008 * <li>If at least one preference is prohibited -> prohibited 009 * <li>Otherwise, mean value from the given preferences is returned 010 * </ul> 011 * 012 * @version 013 * CourseTT 1.1 (University Course Timetabling)<br> 014 * Copyright (C) 2006 Tomáš Müller<br> 015 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 016 * Lazenska 391, 76314 Zlin, Czech Republic<br> 017 * <br> 018 * This library is free software; you can redistribute it and/or 019 * modify it under the terms of the GNU Lesser General Public 020 * License as published by the Free Software Foundation; either 021 * version 2.1 of the License, or (at your option) any later version. 022 * <br><br> 023 * This library is distributed in the hope that it will be useful, 024 * but WITHOUT ANY WARRANTY; without even the implied warranty of 025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 026 * Lesser General Public License for more details. 027 * <br><br> 028 * You should have received a copy of the GNU Lesser General Public 029 * License along with this library; if not, write to the Free Software 030 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 031 */ 032 public class AveragePreferenceCombination extends PreferenceCombination { 033 int iPreference = 0; 034 int iCnt = 0; 035 036 public void addPreferenceInt(int intPref) { 037 super.addPreferenceInt(intPref); 038 iPreference += intPref; 039 iCnt ++; 040 } 041 042 public int getPreferenceInt() { 043 return Math.round(((float)iPreference)/((float)iCnt)); 044 } 045 }