org.artoflife.gp
Class Selector

java.lang.Object
  |
  +--org.artoflife.gp.Selector
Direct Known Subclasses:
SimpleTournamentSelector

public abstract class Selector
extends java.lang.Object

Used to select Individuals from a Population on the basis of Individuals' Fitnesses. A Selector is initialised with a source Collection of Individuals from which to select, and can then select any number of Individuals at a time from that original population (by executing individual selections a number of times).

Author:
Steve Meyfroidt

Field Summary
protected  java.util.List individuals
          A list of source individuals to select from.
 
Constructor Summary
Selector()
           
 
Method Summary
 void initialise(java.util.Collection individuals)
          Initialise with the individuals to be selected from.
protected  java.util.Collection select(int numberToSelect, boolean chooseFittest)
          Select a number of Individuals from the pool according to some Fitness-based strategy, removing the selected individuals from the pool.
 Individual selectFittest()
          Select a single Individual from the fittest in the pool.
 java.util.Collection selectFittest(int numberToSelect)
          Select a number of Individuals from the fittest in the pool.
protected abstract  Individual selectOne(boolean chooseFittest)
          Override to select a single individual from the original pool according to some Fitness-based strategy, removing the selected Individual from the available pool.
 Individual selectWeakest()
          Select a single Individual from the weakest in the pool.
 java.util.Collection selectWeakest(int numberToSelect)
          Select a number of Individuals from the weakest in the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

individuals

protected java.util.List individuals
A list of source individuals to select from. This is depleted after every selectOne, and is initialised with initialise(java.util.Collection).

Constructor Detail

Selector

public Selector()
Method Detail

initialise

public void initialise(java.util.Collection individuals)
Initialise with the individuals to be selected from. Takes a copy of the Individuals so the original Collection can be changed without affecting future selections.


selectOne

protected abstract Individual selectOne(boolean chooseFittest)
Override to select a single individual from the original pool according to some Fitness-based strategy, removing the selected Individual from the available pool.

Parameters:
chooseFittest - true to choose from the fittest Individuals or false to choose from the weakest
Returns:
Individual selected, never null

select

protected java.util.Collection select(int numberToSelect,
                                      boolean chooseFittest)
Select a number of Individuals from the pool according to some Fitness-based strategy, removing the selected individuals from the pool.

Parameters:
numberToSelect - number of Individuals to select
chooseFittest - true to choose from the fittest Individuals or false to choose from the weakest
Returns:
Collection of numberToSelect Individuals, never null

selectFittest

public java.util.Collection selectFittest(int numberToSelect)
Select a number of Individuals from the fittest in the pool.

Returns:
Collection of Individuals selected, never null

selectWeakest

public java.util.Collection selectWeakest(int numberToSelect)
Select a number of Individuals from the weakest in the pool.

Returns:
Collection of Individuals selected, never null

selectFittest

public Individual selectFittest()
Select a single Individual from the fittest in the pool.

Returns:
Individual selected, never null

selectWeakest

public Individual selectWeakest()
Select a single Individual from the weakest in the pool.

Returns:
Individual selected, never null

artoflife pre0.1.0-dev

Copyright © 2002 the Art Of Life team. All Rights Reserved.