org.encog.ml.prg.opp
Class SubtreeCrossover
- java.lang.Object
-
- org.encog.ml.prg.opp.SubtreeCrossover
-
- All Implemented Interfaces:
- EvolutionaryOperator
public class SubtreeCrossover extends java.lang.Object implements EvolutionaryOperator
Perform a type-safe subtree crossover. The crossover points will be chosen randomly but must be type-safe. The first parent will be cloned to produce the child. The tree formed from the crossover point of the second child will be copied and grafted into the parent's clone and its crossover point.
-
-
Constructor Summary
Constructors Constructor and Description SubtreeCrossover()Construct the operator with 1 crossover point.SubtreeCrossover(int thePoints)Construct the operator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidinit(EvolutionaryAlgorithm theOwner)Called to setup the evolutionary operator.intoffspringProduced()intparentsNeeded()voidperformOperation(java.util.Random rnd, Genome[] parents, int parentIndex, Genome[] offspring, int offspringIndex)Perform the evolutionary operation.
-
-
-
Constructor Detail
-
SubtreeCrossover
public SubtreeCrossover(int thePoints)
Construct the operator.- Parameters:
thePoints- The number of points.
-
SubtreeCrossover
public SubtreeCrossover()
Construct the operator with 1 crossover point.
-
-
Method Detail
-
init
public void init(EvolutionaryAlgorithm theOwner)
Called to setup the evolutionary operator.- Specified by:
initin interfaceEvolutionaryOperator- Parameters:
theOwner- The evolutionary algorithm used with this operator.
-
offspringProduced
public int offspringProduced()
- Specified by:
offspringProducedin interfaceEvolutionaryOperator- Returns:
- Returns the number of offspring produced. In this case, one.
-
parentsNeeded
public int parentsNeeded()
- Specified by:
parentsNeededin interfaceEvolutionaryOperator- Returns:
- Returns the number of parents needed. In this case, two.
-
performOperation
public void performOperation(java.util.Random rnd, Genome[] parents, int parentIndex, Genome[] offspring, int offspringIndex)Perform the evolutionary operation.- Specified by:
performOperationin interfaceEvolutionaryOperator- Parameters:
rnd- A random number generator.parents- The parents.parentIndex- The index into the parents array.offspring- The offspring.offspringIndex- An index into the offspring array.
-
-
DMelt 3.0 © DataMelt by jWork.ORG