net.sourceforge.cilib.util.selection.recipes
Class RankBasedSelection<E extends Comparable>

java.lang.Object
  extended by net.sourceforge.cilib.util.selection.recipes.RankBasedSelection<E>
Type Parameters:
E -
All Implemented Interfaces:
Serializable, Cloneable, SelectionRecipe<E>

public class RankBasedSelection<E extends Comparable>
extends Object
implements SelectionRecipe<E>

A recipe for Rank based selection.

Rank based selection is performed by:

  1. Sorting the list of elements in a natural ordering.
  2. Selecting protion of the elements that are better than the majority.
  3. Randomizing the sub list of elements and selecting an element from the randomized list.
  4. Return the result.

Author:
Wiehann Matthysen
See Also:
Serialized Form

Constructor Summary
RankBasedSelection()
          Create a new instance.
RankBasedSelection(Comparator<Selection.Entry<E>> comparator)
          Create a new instance with the provided Comparator.
RankBasedSelection(RankBasedSelection copy)
          Create a copy of the provided instance.
 
Method Summary
 RankBasedSelection getClone()
          Create a cloned copy of the current object and return it.
 Comparator<Selection.Entry<E>> getComparator()
          Get the comparator.
 Random getRandom()
          Get the current random number generator.
 E select(List<? extends E> elements)
          Perform the selection process.
 void setComparator(Comparator<Selection.Entry<E>> comparator)
          Set the comparator to use.
 void setRandom(Random random)
          Set the random number generator to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RankBasedSelection

public RankBasedSelection()
Create a new instance.


RankBasedSelection

public RankBasedSelection(Comparator<Selection.Entry<E>> comparator)
Create a new instance with the provided Comparator.

Parameters:
comparator - The comparator to use.

RankBasedSelection

public RankBasedSelection(RankBasedSelection copy)
Create a copy of the provided instance.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public RankBasedSelection getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Cloneable
Specified by:
getClone in interface SelectionRecipe<E extends Comparable>
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

setComparator

public void setComparator(Comparator<Selection.Entry<E>> comparator)
Set the comparator to use.

Parameters:
comparator - The value to set.

getComparator

public Comparator<Selection.Entry<E>> getComparator()
Get the comparator.

Returns:
The current comparator.

getRandom

public Random getRandom()
Get the current random number generator.

Returns:
The current random number generator.

setRandom

public void setRandom(Random random)
Set the random number generator to use.

Parameters:
random - The value to set.

select

public E select(List<? extends E> elements)
Perform the selection process.

Specified by:
select in interface SelectionRecipe<E extends Comparable>
Parameters:
elements - The elements to perfrom the selection on.
Returns:
The selected element.


Copyright © 2009 CIRG. All Rights Reserved.