Module io.jenetics.ext
Package io.jenetics.ext
Class WeaselSelector<G extends Gene<?,G>,C extends Comparable<? super C>>
java.lang.Object
io.jenetics.ext.WeaselSelector<G,C>
- Type Parameters:
G
- the gene typeC
- the fitness result type
- All Implemented Interfaces:
Selector<G,
C>
public class WeaselSelector<G extends Gene<?,G>,C extends Comparable<? super C>>
extends Object
implements Selector<G,C>
Selector implementation which is part of the
Weasel program
algorithm. The Weasel program is a thought experiment by Richard
Dawkins to illustrate the functioning of the evolution: random mutation
combined with non-random cumulative selection.
The selector always returns populations which only contains "count
"
instances of the best Phenotype
.
Engine
setup for the Weasel program:
final Engine<CharacterGene, Integer> engine = Engine.builder(problem)
// Set the 'WeaselSelector'.
.selector(new WeaselSelector<>())
// Disable survivors selector.
.offspringFraction(1)
// Set the 'WeaselMutator'.
.alterers(new WeaselMutator<>(0.05))
.build();
- Since:
- 3.5
- Version:
- 5.0
- See Also:
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
WeaselSelector
public WeaselSelector()
-
-
Method Details
-
select
Description copied from interface:Selector
Select phenotypes from the Population.- Specified by:
select
in interfaceSelector<G extends Gene<?,
G>, C extends Comparable<? super C>> - Parameters:
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.- Returns:
- The selected phenotypes (a new Population).
-
toString
-