simAuxLibrary
Class Roulettewheel

java.lang.Object
  extended bysimAuxLibrary.Roulettewheel

public class Roulettewheel
extends java.lang.Object

Libaray simAuxLibrary, Class Roulettewheel

Copyright by Klaus Hufschlag 2004, 2005, 2006

This file is part of the Generic Classifier Library. The Generic Classifier Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The Generic Classifier 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 General Public License for more details. You should have received a copy of the GNU General Public License along with the Generic Classifier Library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Version:
1.4
Author:
Klaus Hufschlag

Constructor Summary
Roulettewheel()
          Standardconstructor, creates an empty Instance.
 
Method Summary
 void add(double value, java.lang.Object anObject)
          add is for adding an Object to the instances List of Objects for choice.
 java.lang.Object choice()
          choice performs an roulettewheel-choice with the elements of the instances list.
 void debug_out()
          debug_out Output for debugging purposes.
 void empty_wheel()
          removes all entries from Roulettewheel.
 double getWeight(java.lang.Object anObject)
          getWeight returns the relative weight / the probability of the object in the Roulettewheel.
 java.util.Iterator pointers_iterator()
          pointers_iterator returns an Iterator of all objects contained in Roulettewheel
 void remove(java.lang.Object AnObject)
          remove removes an object from the instances internal list of objects.
 double sum_values()
          sum_values calculates the sum of absolute wheigths of elements contained in the instances list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Roulettewheel

public Roulettewheel()
Standardconstructor, creates an empty Instance.

Method Detail

add

public void add(double value,
                java.lang.Object anObject)
add is for adding an Object to the instances List of Objects for choice.

Parameters:
value - absolute Weight of the Object
anObject - Object to add

remove

public void remove(java.lang.Object AnObject)
remove removes an object from the instances internal list of objects.

Parameters:
AnObject - the object to remove

sum_values

public double sum_values()
sum_values calculates the sum of absolute wheigths of elements contained in the instances list.

Returns:
sum of the weights

choice

public java.lang.Object choice()
choice performs an roulettewheel-choice with the elements of the instances list.

Returns:
chosen Object

pointers_iterator

public java.util.Iterator pointers_iterator()
pointers_iterator returns an Iterator of all objects contained in Roulettewheel

Returns:
Iterator

getWeight

public double getWeight(java.lang.Object anObject)
getWeight returns the relative weight / the probability of the object in the Roulettewheel.

Parameters:
anObject - Object to get weight for
Returns:
relative weight of the object

empty_wheel

public void empty_wheel()
removes all entries from Roulettewheel.


debug_out

public void debug_out()
debug_out Output for debugging purposes.