com.epochx.core
Class GPElitism<TYPE>

java.lang.Object
  extended by com.epochx.core.GPElitism<TYPE>
All Implemented Interfaces:
GenerationListener

public class GPElitism<TYPE>
extends java.lang.Object
implements GenerationListener

This class has the task of retrieving the set of elites from a population.


Constructor Summary
GPElitism(GPModel<TYPE> model)
          Constructs an instance of GPElitism which will perform the elitism operation.
 
Method Summary
 java.util.List<CandidateProgram<TYPE>> getElites(java.util.List<CandidateProgram<TYPE>> pop)
          Gets the best CandidatePrograms from the given population and returns them.
 void onGenerationStart()
          Called after each generation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GPElitism

public GPElitism(GPModel<TYPE> model)
Constructs an instance of GPElitism which will perform the elitism operation.

Parameters:
model - the GPModel which defines the run parameters and life cycle listeners.
Method Detail

getElites

public java.util.List<CandidateProgram<TYPE>> getElites(java.util.List<CandidateProgram<TYPE>> pop)
Gets the best CandidatePrograms from the given population and returns them. The number of programs returned will be determined by a call to the model's getNoElites() method. If this method returns a value greater than the allowable population size then the population size will be used. Elites in EpochX are defined as the very best programs in a population.

After selection and before returning, the model's life cycle listener will be informed of the elitism operation with a call to onElitism(). Unlike many of the other life cycle methods, it is not possible to 'revert' an elitism event by returning null. This is because elitism is a deterministic operation, and so re-running would lead to the same result.

Parameters:
pop - the population from which elites need to be retrieved.
Returns:
a list containing the best CandidatePrograms determined by fitness. If the models required number of elites is equal to or greater than the population size then the returned list will contain all CandidatePrograms from the population sorted.

onGenerationStart

public void onGenerationStart()
Called after each generation. For each generation we should reset all parameters taken from the model incase they've changed. The generation event is then CONFIRMed.

Specified by:
onGenerationStart in interface GenerationListener