org.encog.ml.prg.opp

## Class SubtreeMutation

- java.lang.Object
- - org.encog.ml.prg.opp.SubtreeMutation

- All Implemented Interfaces:
    EvolutionaryOperator

      public class SubtreeMutation
      extends Object
      implements EvolutionaryOperator

  Perform a type-safe subtree mutation. The mutation point is chosen randomly, but the new tree will be generated with compatible types to the parent.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SubtreeMutation(EncogProgramContext theContext, int theMaxDepth)` Construct the subtree mutation object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `PrgGenerator` | `getGenerator()`
    `void` | `init(EvolutionaryAlgorithm theOwner)` Called to setup the evolutionary operator.
    `int` | `offspringProduced()`
    `int` | `parentsNeeded()`
    `void` | `performOperation(Random rnd, Genome[] parents, int parentIndex, Genome[] offspring, int offspringIndex)` Perform the evolutionary operation.
    `void` | `setGenerator(PrgGenerator generator)` Set the random tree generator to use.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SubtreeMutation

          public SubtreeMutation(EncogProgramContext theContext,
                         int theMaxDepth)

      Construct the subtree mutation object.
      Parameters:
        `theContext` - The program context.
        `theMaxDepth` - The maximum depth.

  - ### Method Detail

    - #### getGenerator

          public PrgGenerator getGenerator()

      Returns:
        The random tree generator to use.

    - #### init

          public void init(EvolutionaryAlgorithm theOwner)

      Called to setup the evolutionary operator.
      Specified by:
        `init` in interface `EvolutionaryOperator`
      Parameters:
        `theOwner` - The evolutionary algorithm used with this operator.

    - #### offspringProduced

          public int offspringProduced()

      Specified by:
        `offspringProduced` in interface `EvolutionaryOperator`
      Returns:
        Returns the number of offspring produced. In this case, one.

    - #### parentsNeeded

          public int parentsNeeded()

      Specified by:
        `parentsNeeded` in interface `EvolutionaryOperator`
      Returns:
        Returns the number of parents needed. In this case, one.

    - #### performOperation

          public void performOperation(Random rnd,
                              Genome[] parents,
                              int parentIndex,
                              Genome[] offspring,
                              int offspringIndex)

      Perform the evolutionary operation.
      Specified by:
        `performOperation` in interface `EvolutionaryOperator`
      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.

    - #### setGenerator

          public void setGenerator(PrgGenerator generator)

      Set the random tree generator to use.
      Parameters:
        `generator` - The random tree generator.

Copyright © 2014. All Rights Reserved.