net.sf.cpsolver.ifs.heuristics
Class RouletteWheelSelection

java.lang.Object
  extended by net.sf.cpsolver.ifs.heuristics.RouletteWheelSelection
All Implemented Interfaces:
Enumeration

public class RouletteWheelSelection
extends Object
implements Enumeration

A general roulette wheel selection. An object is selected randomly, proportionaly to the provided weight. This class also supports multiple selections (it implements Enumeration interface).

Version:
StudentSct 1.1 (Student Sectioning)
Copyright (C) 2007 Tomáš Müller
muller@unitime.org
Lazenska 391, 76314 Zlin, Czech Republic

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Constructor Summary
RouletteWheelSelection()
           
 
Method Summary
 void add(Object adept, double points)
          Add an adept to the selection
 double getRemainingPoints()
          Total value of objects that are still in the selection.
 double getTotalPoints()
          Total value of objects that were added into the selection.
 double getUsedPoints()
          Total value of objects that were already returned by the selection.
 boolean hasMoreElements()
          Are there still some adepts that have not been yet selected
 Object nextElement()
          Perform selection.
 int size()
          Number of objects in the set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RouletteWheelSelection

public RouletteWheelSelection()
Method Detail

add

public void add(Object adept,
                double points)
Add an adept to the selection

Parameters:
adept - an object
points - object weight (more points, better chance to be selected)

hasMoreElements

public boolean hasMoreElements()
Are there still some adepts that have not been yet selected

Specified by:
hasMoreElements in interface Enumeration

nextElement

public Object nextElement()
Perform selection. An object is selected randomly with the probability proportional to the provided weight. Each object can be selected only once.

Specified by:
nextElement in interface Enumeration

size

public int size()
Number of objects in the set


getUsedPoints

public double getUsedPoints()
Total value of objects that were already returned by the selection.


getRemainingPoints

public double getRemainingPoints()
Total value of objects that are still in the selection.


getTotalPoints

public double getTotalPoints()
Total value of objects that were added into the selection.