public final class SubtreeCrossover extends Object implements GeneticOperator
A subtree is selected at random from each of the parents. The subtree of the first is replaced by the subtree of the second. The structure of the resulting tree can differ significantly from either of the trees that were combined to produce it.
Constructor and Description |
---|
SubtreeCrossover(Random random,
int maxDepth)
Creates a
SubtreeCrossover that uses the given Random to select subtrees from parents. |
Modifier and Type | Method and Description |
---|---|
Node |
evolve(NodeSelector selector)
Returns a new
Node evolved from existing instances. |
public SubtreeCrossover(Random random, int maxDepth)
SubtreeCrossover
that uses the given Random
to select subtrees from parents.random
- used to randomly select subtrees to replace and the subtrees to replace them withmaxDepth
- used to enforce a maximum depth of any offspringpublic Node evolve(NodeSelector selector)
GeneticOperator
Node
evolved from existing instances.evolve
in interface GeneticOperator
selector
- used to select the existing instances to use as a basis for evolving a new instanceNode
evolved from existing instances obtained from selector
OakGP Genetic Programming Framework