Class AbstractCrossover<T>
- java.lang.Object
-
- org.uncommons.watchmaker.framework.operators.AbstractCrossover<T>
-
- Type Parameters:
T
- The type of evolved candidates that are operated on by this cross-over implementation.
- All Implemented Interfaces:
EvolutionaryOperator<T>
- Direct Known Subclasses:
BitStringCrossover
,ByteArrayCrossover
,CharArrayCrossover
,DoubleArrayCrossover
,IntArrayCrossover
,ListCrossover
,ListOrderCrossover
,ObjectArrayCrossover
,StringCrossover
public abstract class AbstractCrossover<T> extends Object implements EvolutionaryOperator<T>
Generic base class for cross-over implementations. Supports all cross-over processes that operate on a pair of parent candidates.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCrossover(int crossoverPoints)
Sets up a fixed-point cross-over implementation.protected
AbstractCrossover(int crossoverPoints, Probability crossoverProbability)
Sets up a cross-over implementation that uses a fixed number of cross-over points.protected
AbstractCrossover(NumberGenerator<Integer> crossoverPointsVariable)
Sets up a cross-over implementation that uses a variable number of cross-over points.protected
AbstractCrossover(NumberGenerator<Integer> crossoverPointsVariable, NumberGenerator<Probability> crossoverProbabilityVariable)
Sets up a cross-over implementation that uses a variable number of cross-over points.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description List<T>
apply(List<T> selectedCandidates, Random rng)
Applies the cross-over operation to the selected candidates.protected abstract List<T>
mate(T parent1, T parent2, int numberOfCrossoverPoints, Random rng)
Perform cross-over on a pair of parents to generate a pair of offspring.
-
-
-
Constructor Detail
-
AbstractCrossover
protected AbstractCrossover(int crossoverPoints)
Sets up a fixed-point cross-over implementation. Cross-over is applied to all pairs of parents. To apply cross-over only to a proportion of parent pairs, use theAbstractCrossover(int, Probability)
constructor.- Parameters:
crossoverPoints
- The constant number of cross-over points to use for all cross-over operations.
-
AbstractCrossover
protected AbstractCrossover(int crossoverPoints, Probability crossoverProbability)
Sets up a cross-over implementation that uses a fixed number of cross-over points. Cross-over is applied to a proportion of selected parent pairs, with the remainder copied unchanged into the output population. The size of this evolved proportion is controlled by thecrossoverProbability
parameter.- Parameters:
crossoverPoints
- The constant number of cross-over points to use for all cross-over operations.crossoverProbability
- The probability that, once selected, a pair of parents will be subjected to cross-over rather than being copied, unchanged, into the output population. Must be in the range 0 < crossoverProbability <= 1
-
AbstractCrossover
protected AbstractCrossover(NumberGenerator<Integer> crossoverPointsVariable)
Sets up a cross-over implementation that uses a variable number of cross-over points. Cross-over is applied to all pairs of parents. To apply cross-over only to a proportion of parent pairs, use theAbstractCrossover(NumberGenerator, NumberGenerator)
constructor.- Parameters:
crossoverPointsVariable
- A random variable that provides a number of cross-over points for each cross-over operation.
-
AbstractCrossover
protected AbstractCrossover(NumberGenerator<Integer> crossoverPointsVariable, NumberGenerator<Probability> crossoverProbabilityVariable)
Sets up a cross-over implementation that uses a variable number of cross-over points. Cross-over is applied to a proportion of selected parent pairs, with the remainder copied unchanged into the output population. The size of this evolved proportion is controlled by thecrossoverProbabilityVariable
parameter.- Parameters:
crossoverPointsVariable
- A variable that provides a (possibly constant, possibly random) number of cross-over points for each cross-over operation.crossoverProbabilityVariable
- A variable that controls the probability that, once selected, a pair of parents will be subjected to cross-over rather than being copied, unchanged, into the output population.
-
-
Method Detail
-
apply
public List<T> apply(List<T> selectedCandidates, Random rng)
Applies the cross-over operation to the selected candidates. Pairs of candidates are chosen randomly and subjected to cross-over to produce a pair of offspring candidates.- Specified by:
apply
in interfaceEvolutionaryOperator<T>
- Parameters:
selectedCandidates
- The evolved individuals that have survived to be eligible to reproduce.rng
- A source of randomness used to determine the location of cross-over points.- Returns:
- The combined set of evolved offspring generated by applying cross-over to the the selected candidates.
-
mate
protected abstract List<T> mate(T parent1, T parent2, int numberOfCrossoverPoints, Random rng)
Perform cross-over on a pair of parents to generate a pair of offspring.- Parameters:
parent1
- One of two individuals that provides the source material for generating offspring.parent2
- One of two individuals that provides the source material for generating offspring.numberOfCrossoverPoints
- The number of cross-overs performed on the two parents.rng
- A source of randomness used to determine the location of cross-over points.- Returns:
- A list containing two evolved offspring.
-
-