001 package net.sf.cpsolver.studentsct.heuristics.studentord; 002 003 import java.util.Collections; 004 import java.util.Enumeration; 005 import java.util.Vector; 006 007 import net.sf.cpsolver.ifs.util.DataProperties; 008 import net.sf.cpsolver.studentsct.model.Student; 009 010 /** 011 * Return the given set of students in a random order, however, 012 * all real students before last-like students. 013 * 014 * @version 015 * StudentSct 1.1 (Student Sectioning)<br> 016 * Copyright (C) 2007 Tomáš Müller<br> 017 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 018 * Lazenska 391, 76314 Zlin, Czech Republic<br> 019 * <br> 020 * This library is free software; you can redistribute it and/or 021 * modify it under the terms of the GNU Lesser General Public 022 * License as published by the Free Software Foundation; either 023 * version 2.1 of the License, or (at your option) any later version. 024 * <br><br> 025 * This library is distributed in the hope that it will be useful, 026 * but WITHOUT ANY WARRANTY; without even the implied warranty of 027 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 028 * Lesser General Public License for more details. 029 * <br><br> 030 * You should have received a copy of the GNU Lesser General Public 031 * License along with this library; if not, write to the Free Software 032 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 033 */ 034 public class StudentRandomRealFirstOrder implements StudentOrder { 035 036 public StudentRandomRealFirstOrder(DataProperties config) { 037 } 038 039 public StudentRandomRealFirstOrder() { 040 } 041 042 /** 043 * Return the given set of students in a random order, however, 044 * all real students before last-like ({@link Student#isDummy()} 045 * is true) students. 046 **/ 047 public Vector order(Vector students) { 048 Vector real = new Vector(students.size()); 049 Vector dummy = new Vector(students.size()); 050 for (Enumeration e=students.elements();e.hasMoreElements();) { 051 Student student = (Student)e.nextElement(); 052 if (student.isDummy()) 053 dummy.add(student); 054 else 055 real.add(student); 056 } 057 Collections.shuffle(dummy); 058 Collections.shuffle(real); 059 dummy.addAll(real); 060 return dummy; 061 } 062 063 }