jenes.stage.operator
Class Selector<T extends Chromosome>

java.lang.Object
  extended by jenes.stage.AbstractStage<T>
      extended by jenes.stage.operator.Operator<T>
          extended by jenes.stage.operator.Selector<T>
Type Parameters:
T - The class of chromosomes to work with.
Direct Known Subclasses:
RouletteWheelSelector, TournamentSelector

public abstract class Selector<T extends Chromosome>
extends Operator<T>

A class representing a generic selection operator.

The actual selector is implemented by subclassing this abstract class and providing the select(Population) and preSelect(Population) method implementations: the former is required to select individuals from the specified Population; the latter is required to set up the selector state when a new selection begins.

A maxIllegalRate is specified to obtain a population with a max number of illegal individuals selected. When this threshould is reached, the new illegal selected individuals are not added at the output population, and the selection process is repeated.

At the start selection time the output population has already the individuals; the individuals selected from the input population have not to be added at the output population: each output population individual is set as the one selected by the input population.

The output population size will be equal to the input population one; automatically new individuals are added or old ones are deleted to make the sizes equal.

A Selector.Statistics is associated to each selector operator.

Since:
1.0
Version:
1.2
Author:
Luigi Troiano, Pierpaolo Lombardi, Giuseppe Pascale, Thierry Bodhuin
See Also:
Individual, Population

Nested Class Summary
 class Selector.Statistics
          A statistics object holding the number of selection performed and the time spent to execute them.
 
Field Summary
static double DEFAULT_MAX_ILLEGAL_RATE
          The default percentage of allowed illegal individuals
 
Fields inherited from class jenes.stage.operator.Operator
random, statistics
 
Fields inherited from class jenes.stage.AbstractStage
biggerIsBetter, ga
 
Constructor Summary
Selector()
          Constructs a new SelectorOperator with the specified sample individual
 
Method Summary
 double getMaxIllegalRate()
          Returns the max number of illegal individuals this selector operator can select.
protected  void preSelect(Population<T> pop)
          Sets up the selection state according a population's state.
 void process(Population<T> in, Population<T> out)
          Sets the individuals in the output population like the selected ones
protected abstract  Individual<T> select(Population<T> pop)
          Selects a population according to a politics of selection.
 void setMaxIllegalRate(double rate)
          Sets the max number of illegal individuals this selector operator can select.
 
Methods inherited from class jenes.stage.operator.Operator
getStatistics, updateStatistics
 
Methods inherited from class jenes.stage.AbstractStage
dispose, init, isBiggerBetter, setBiggerIsBetter, setBiggerIsBetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_ILLEGAL_RATE

public static final double DEFAULT_MAX_ILLEGAL_RATE
The default percentage of allowed illegal individuals

See Also:
Constant Field Values
Constructor Detail

Selector

public Selector()
Constructs a new SelectorOperator with the specified sample individual

Method Detail

getMaxIllegalRate

public double getMaxIllegalRate()
Returns the max number of illegal individuals this selector operator can select.

Returns:
the max illegal rate

setMaxIllegalRate

public void setMaxIllegalRate(double rate)
Sets the max number of illegal individuals this selector operator can select.

Parameters:
rate - the max illegal rate

process

public final void process(Population<T> in,
                          Population<T> out)
                   throws StageException
Sets the individuals in the output population like the selected ones

Specified by:
process in class AbstractStage<T extends Chromosome>
Parameters:
in - the input population
out - the output population
Throws:
StageException

preSelect

protected void preSelect(Population<T> pop)
Sets up the selection state according a population's state. It's invoked at the start of individuals selection of the specified population.

Parameters:
pop - the population to process by the stage

select

protected abstract Individual<T> select(Population<T> pop)
Selects a population according to a politics of selection.

Parameters:
pop - the population in which to choose the individual
Returns:
the position selected