com.epochx.op.selection
Class RandomSelector<TYPE>

java.lang.Object
  extended by com.epochx.op.selection.RandomSelector<TYPE>
All Implemented Interfaces:
PoolSelector<TYPE>, ProgramSelector<TYPE>

public class RandomSelector<TYPE>
extends java.lang.Object
implements ProgramSelector<TYPE>, PoolSelector<TYPE>

A random selector is a program and pool selector which provides no selection pressure. No reference is made to the programs' fitness scores.


Constructor Summary
RandomSelector(GPModel<TYPE> model)
           
 
Method Summary
 java.util.List<CandidateProgram<TYPE>> getPool(java.util.List<CandidateProgram<TYPE>> pop, int poolSize)
          Randomly chooses programs from the given population up to a total of poolSize and returns them as a list.
 CandidateProgram<TYPE> getProgram()
          Randomly chooses and returns a program from the population with no bias.
 void setSelectionPool(java.util.List<CandidateProgram<TYPE>> pop)
          This method should only be called by the GP system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomSelector

public RandomSelector(GPModel<TYPE> model)
Method Detail

setSelectionPool

public void setSelectionPool(java.util.List<CandidateProgram<TYPE>> pop)
This method should only be called by the GP system. It is used to provide the population for the current generation.

Specified by:
setSelectionPool in interface ProgramSelector<TYPE>
Parameters:
pop - the current population for this generation.

getProgram

public CandidateProgram<TYPE> getProgram()
Randomly chooses and returns a program from the population with no bias.

Specified by:
getProgram in interface ProgramSelector<TYPE>
Returns:
a randomly selected program.

getPool

public java.util.List<CandidateProgram<TYPE>> getPool(java.util.List<CandidateProgram<TYPE>> pop,
                                                      int poolSize)
Randomly chooses programs from the given population up to a total of poolSize and returns them as a list. The generated pool may contain duplicate programs, and as such the pool size can be greater than the population size.

Specified by:
getPool in interface PoolSelector<TYPE>
Parameters:
pop - the population of CandidatePrograms from which the programs in the pool should be chosen.
poolSize - the number of programs that should be selected from the population to form the pool. If poolSize is less than zero then no selection takes place and the given population is returned unaltered.
Returns:
the randomly selected pool of candidate programs.