com.epochx.op.mutation
Class SubtreeMutation<TYPE>

java.lang.Object
  extended by com.epochx.op.mutation.SubtreeMutation<TYPE>
All Implemented Interfaces:
Mutation<TYPE>

public class SubtreeMutation<TYPE>
extends java.lang.Object
implements Mutation<TYPE>

This class performs a subtree mutation on a CandidateProgram.

A mutation point is randomly selected anywhere in the program tree. Then the node at that point is replaced with a newly generated program tree, which is created using a grow strategy.


Constructor Summary
SubtreeMutation(GPModel<TYPE> model)
          Simple constructor for subtree mutation using a default maximum depth of 4 for new subtrees.
SubtreeMutation(GPModel<TYPE> model, int maxSubtreeDepth)
          Subtree mutation constructor with control for the maximum depth of new subtrees.
 
Method Summary
 CandidateProgram<TYPE> mutate(CandidateProgram<TYPE> program)
          Perform subtree mutation on the given CandidateProgram.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubtreeMutation

public SubtreeMutation(GPModel<TYPE> model)
Simple constructor for subtree mutation using a default maximum depth of 4 for new subtrees.

Parameters:
model - The controlling model which provides any configuration parameters for the run.

SubtreeMutation

public SubtreeMutation(GPModel<TYPE> model,
                       int maxSubtreeDepth)
Subtree mutation constructor with control for the maximum depth of new subtrees.

Parameters:
model - The controlling model which provides any configuration parameters for the run.
maxSubtreeDepth - The maximum depth of the inserted subtree.
Method Detail

mutate

public CandidateProgram<TYPE> mutate(CandidateProgram<TYPE> program)
Perform subtree mutation on the given CandidateProgram. A mutation point is randomly selected anywhere in the program tree. Then the node at that point is replaced with a newly generated program tree, which is created using a grow strategy.

Specified by:
mutate in interface Mutation<TYPE>
Parameters:
program - The CandidateProgram selected to undergo this mutation operation.
Returns:
A CandidateProgram that was the result of a point mutation on the provided CandidateProgram.