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

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

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

Linear rank selection chooses programs by fitness rank. All the programs in the population are ranked according to their fitness from lowest to highest. Each program is then assigned a probability according to their rank in a linear fashion with a gradient as given at construction.


Constructor Summary
LinearRankSelector(GPModel<TYPE> model, double gradient)
           
 
Method Summary
 java.util.List<CandidateProgram<TYPE>> getPool(java.util.List<CandidateProgram<TYPE>> pop, int poolSize)
          Constructs a pool of programs from the population, choosing each one with the program selection element of LinearRankSelector.
 CandidateProgram<TYPE> getProgram()
          Selects a candidate program from the population using the probabilities which were assigned based on fitness rank.
 void setSelectionPool(java.util.List<CandidateProgram<TYPE>> pop)
          Sets the population from which programs will be selected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearRankSelector

public LinearRankSelector(GPModel<TYPE> model,
                          double gradient)
Method Detail

setSelectionPool

public void setSelectionPool(java.util.List<CandidateProgram<TYPE>> pop)
Sets the population from which programs will be selected. The probabilities are calculated once at this point based upon the linear fitness rank.

Specified by:
setSelectionPool in interface ProgramSelector<TYPE>
Parameters:
pop - the population of candidate programs from which programs should be selected.

getProgram

public CandidateProgram<TYPE> getProgram()
Selects a candidate program from the population using the probabilities which were assigned based on fitness rank.

Specified by:
getProgram in interface ProgramSelector<TYPE>
Returns:
a program selected from the current population based on fitness rank.

getPool

public java.util.List<CandidateProgram<TYPE>> getPool(java.util.List<CandidateProgram<TYPE>> pop,
                                                      int poolSize)
Constructs a pool of programs from the population, choosing each one with the program selection element of LinearRankSelector. The size of the pool created will be equal to the poolSize argument. The generated pool may contain duplicate programs, and as such the pool size may 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 zero or less then no selection takes place and the given population is returned unaltered.
Returns:
the pool of candidate programs selected according to fitness rank.