Class SplitEvolution<T>
- java.lang.Object
-
- org.uncommons.watchmaker.framework.operators.SplitEvolution<T>
-
- Type Parameters:
T
- The type of evolved entity dealt with by this operator.
- All Implemented Interfaces:
EvolutionaryOperator<T>
public class SplitEvolution<T> extends Object implements EvolutionaryOperator<T>
Compound evolutionary operator that allows the evolution of a population to be split into two separate streams. A percentage of the population will be evolved according to one specified operator and the remainder according to another operator. When both streams have been executed, the resulting offspring will be returned as a single combined population.
This kind of separation is common in a genetic programming context where, for example, 10% of the population is mutated and the remaining 90% undergoes cross-over independently.
To split evolution into more than two streams, multiple SplitEvolution operators can be combined. By combining SplitEvolution operators with
EvolutionPipeline
operators, elaborate evolutionary schemes can be constructed.
-
-
Constructor Summary
Constructors Constructor Description SplitEvolution(EvolutionaryOperator<T> operator1, EvolutionaryOperator<T> operator2, double weight)
SplitEvolution(EvolutionaryOperator<T> operator1, EvolutionaryOperator<T> operator2, NumberGenerator<Double> weightVariable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<T>
apply(List<T> selectedCandidates, Random rng)
Applies one evolutionary operator to part of the population and another to the remainder.
-
-
-
Constructor Detail
-
SplitEvolution
public SplitEvolution(EvolutionaryOperator<T> operator1, EvolutionaryOperator<T> operator2, double weight)
- Parameters:
operator1
- The operator that will apply to the first part of the population (as determined by theweight
parameter).operator2
- The operator that will apply to the second part of the population (as determined by theweight
parameter).weight
- The proportion (as a real number between zero and 1 exclusive) of the population that will be evolved byoperator1
. The remainder will be evolved byoperator2
.
-
SplitEvolution
public SplitEvolution(EvolutionaryOperator<T> operator1, EvolutionaryOperator<T> operator2, NumberGenerator<Double> weightVariable)
- Parameters:
operator1
- The operator that will apply to the first part of the population (as determined by theweightVariable
parameter).operator2
- The operator that will apply to the second part of the population (as determined by theweightVariable
parameter).weightVariable
- A random variable that provides the ratio for dividing the population between the two evolutionary streams. Must only generate values in the range 0 < ratio < 1.
-
-
Method Detail
-
apply
public List<T> apply(List<T> selectedCandidates, Random rng)
Applies one evolutionary operator to part of the population and another to the remainder. Returns a list combining the output of both. Which candidates are submitted to which stream is determined randomly.- Specified by:
apply
in interfaceEvolutionaryOperator<T>
- Parameters:
selectedCandidates
- A list of the candidates that survived to be eligible for evolution.rng
- A source of randomness passed to each of the two delegate evolutionary operators.- Returns:
- The combined results from the two streams of evolution.
-
-