public abstract class ProbabilitySelector<G extends Gene<?,G>,C extends Comparable<? super C>> extends Object implements Selector<G,C>
Modifier | Constructor and Description |
---|---|
protected |
ProbabilitySelector() |
Modifier and Type | Method and Description |
---|---|
protected abstract double[] |
probabilities(Population<G,C> population,
int count)
Return an Probability array, which corresponds to the given Population.
|
protected double[] |
probabilities(Population<G,C> population,
int count,
Optimize opt)
This method takes the probabilities from the
probabilities(Population, int) method and inverts it if needed. |
Population<G,C> |
select(Population<G,C> population,
int count,
Optimize opt)
Select phenotypes from the Population.
|
protected ProbabilitySelector()
public Population<G,C> select(Population<G,C> population, int count, Optimize opt)
Selector
select
in interface Selector<G extends Gene<?,G>,C extends Comparable<? super C>>
population
- The population to select from.count
- The number of phenotypes to select.opt
- Determines whether the individuals with higher fitness values
or lower fitness values must be selected. This parameter determines
whether the GA maximizes or minimizes the fitness function.protected final double[] probabilities(Population<G,C> population, int count, Optimize opt)
probabilities(Population, int)
method and inverts it if needed.population
- The population.count
- The number of phenotypes to select.opt
- Determines whether the individuals with higher fitness values
or lower fitness values must be selected. This parameter determines
whether the GA maximizes or minimizes the fitness function.protected abstract double[] probabilities(Population<G,C> population, int count)
Return an Probability array, which corresponds to the given Population. The probability array and the population must have the same size. The population is not sorted. If a subclass needs a sorted population, the subclass is responsible to sort the population.
The implementor always assumes that higher fitness values are better. The base class inverts the probabilities (p = 1.0 - p
) if the GA is
supposed to minimize the fitness function.population
- The unsorted population.count
- The number of phenotypes to select. This parameter is not
needed for most implementations.population.size()
and must sum to
one. The returned value is checked with
assert(Math.abs(math.sum(probabilities) - 1.0) < 0.0001)
in the base class.© 2007-2014 Franz Wilhelmstötter (2014-03-07 19:35)