public abstract class Crowder<T extends Chromosome> extends Operator<T>
Operator.Statistics
Modifier and Type | Field and Description |
---|---|
protected Sequence<T> |
body
Body
|
protected boolean |
elitist
Elitism
|
random, statistics
biggerIsBetter, fitness, ga
Constructor and Description |
---|
Crowder()
Creates a new crowder
|
Modifier and Type | Method and Description |
---|---|
Sequence<T> |
getBody()
Return the crowder body
|
void |
init(GeneticAlgorithm<T> ga)
Initializes this stage according to the genetic algorithm
that uses it
|
boolean |
isElitist()
Says if the crowder is elitist or not.
|
protected abstract void |
preselect(Population<T> in,
Population<T> out)
Preselection of individuals before processing.
|
void |
process(Population<T> in,
Population<T> out)
Performs crowding processing, according the the following scheme:
pre = preselect(in)
evo = body.process(pre)
out = replace(evo)
|
protected abstract void |
replace(Population<T> initial,
Population<T> preselected,
Population<T> evolved,
Population<T> out)
Implements the replacement policy.
|
void |
setBiggerIsBetter(boolean flag,
boolean recursively)
Deprecated.
|
void |
setElitist(boolean flag)
Sets the crowder elistism.
|
void |
setFitness(Fitness fit,
boolean recursively)
Change the
Fitness to this stage propagating the change recursively
according to the flag given as parameter |
double |
similarity(double[] diff)
Computes a degree of similarity given the genetic difference vector between two chromosomes.
|
getStatistics, updateStatistics
dispose, getFitness, isBiggerBetter, isFitnessChanged, setBiggerIsBetter, setFitness
protected Sequence<T extends Chromosome> body
protected boolean elitist
public final boolean isElitist()
public void setElitist(boolean flag)
flag
- public void init(GeneticAlgorithm<T> ga)
AbstractStage
init
in class AbstractStage<T extends Chromosome>
ga
- the Genetic Algorithm in wchic this stage runpublic void process(Population<T> in, Population<T> out) throws StageException
process
in class AbstractStage<T extends Chromosome>
in
- out
- StageException
protected abstract void preselect(Population<T> in, Population<T> out)
in
- input populationout
- output populationprotected abstract void replace(Population<T> initial, Population<T> preselected, Population<T> evolved, Population<T> out)
initial
- - the initial populationpreselected
- - the population resulting from preselectionevolved
- - the part of population that has evolvedout
- - the output populationpublic double similarity(double[] diff)
diff
- - the difference vector@Deprecated public void setBiggerIsBetter(boolean flag, boolean recursively)
setBiggerIsBetter
in class AbstractStage<T extends Chromosome>
flag
- true, if the best individual has the higher fitnessrecursively
- true, to propagate this setting down, otherwise false.public void setFitness(Fitness fit, boolean recursively)
AbstractStage
Fitness
to this stage propagating the change recursively
according to the flag given as parametersetFitness
in class AbstractStage<T extends Chromosome>