geneticWedge.gp
Class Mutation

java.lang.Object
  extended by geneticWedge.gp.Mutation

public class Mutation
extends java.lang.Object

Mutation mutates an Individual using a selection of mutation operators.


Nested Class Summary
static class Mutation.MutationOperator
          Mutation operators should be chosen with care.
 
Constructor Summary
Mutation(Mutation.MutationOperator[] ops)
          The constructor takes a list of mutation operations to be used.
 
Method Summary
 void collectTransmissionInfo(boolean collect)
          If set to true, collectTransmissionInfo saves information concerning the relationship between parent and offspring during mutation operations as well as the mutation operation that occurred.
 double getConstantMutationStepSize()
          The stepSize determines how far constant values move during CONSTANT mutation.
 int getMaximumExpandDepth()
          maximumExpandDepth is the maximum allowable depth of the subtree grown during an EXPAND mutation.
 int getMaximumReplacementDepth()
          maximumReplacementDepth is the maximum allowable depth of the subtree grown during a SUBTREE mutation.
 Mutation.MutationOperator[] getMutationOperators()
          Returns the array of mutationOperators used to perform mutation.
 java.util.Vector<double[]> getTransmissionInfo()
          Returns a vector containing information about the relationship between parent and offspring during mutation operations, provided collectTransmissionInfo has been set to true.
 Individual mutate(Individual ind, int maxLength, int maxDepth, PopulationDescriptor popDescriptor)
          Perform a random mutation on an Individual.
 void setConstantMutationStepSize(double stepSize)
          The stepSize determines how far constant values move during CONSTANT mutation.
 void setExpectedMutationDepth(double depth)
          This sets the 'expected' depth at which mutation will take place.
 void setMaximumExpandDepth(int maxDepth)
          When the EXPAND mutation takes place, a randomly chosen terminal is replaced by a subtree, grown with the GROW method.
 void setMaximumReplacementDepth(int maxDepth)
          When the SUBTREE_REPLACEMENT mutation takes place, a randomly chosen subtree is replaced by a random subtree, of similar size grown with the GROW method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mutation

public Mutation(Mutation.MutationOperator[] ops)
The constructor takes a list of mutation operations to be used. When mutation occurs one of these operators will be chosen at random. It is possible to have the same operator more than once, thereby increasing the frequency with which it occurs.

Method Detail

setExpectedMutationDepth

public void setExpectedMutationDepth(double depth)
This sets the 'expected' depth at which mutation will take place. A Poisson distribution is then created with this expected value in order to select the depth at which mutation takes place. If this method is not called, or it is called with depth outside the range 0.0-1.0 (exclusive), the mutation site will be selected randomly.


collectTransmissionInfo

public void collectTransmissionInfo(boolean collect)
If set to true, collectTransmissionInfo saves information concerning the relationship between parent and offspring during mutation operations as well as the mutation operation that occurred.


getTransmissionInfo

public java.util.Vector<double[]> getTransmissionInfo()
Returns a vector containing information about the relationship between parent and offspring during mutation operations, provided collectTransmissionInfo has been set to true.


mutate

public Individual mutate(Individual ind,
                         int maxLength,
                         int maxDepth,
                         PopulationDescriptor popDescriptor)
                  throws InvalidFractionException
Perform a random mutation on an Individual. The mutation operator is selected randomly from the array of mutation operators provided in the constructor.

Parameters:
maxLength - The maximum length (number of nodes) of the offspring
maxDepth - The maximum depth of the offspring
popDescriptor - This is needed in order to provide the available Components and growFunctionProportion (determining the proportion of components in a new subtree that are selected as Functions)
Throws:
InvalidFractionException

setConstantMutationStepSize

public void setConstantMutationStepSize(double stepSize)
The stepSize determines how far constant values move during CONSTANT mutation. The step size is equal to the standard deviation of the 'step' made.


getConstantMutationStepSize

public double getConstantMutationStepSize()
The stepSize determines how far constant values move during CONSTANT mutation. The step size is equal to the standard deviation of the 'step' made.


setMaximumExpandDepth

public void setMaximumExpandDepth(int maxDepth)
When the EXPAND mutation takes place, a randomly chosen terminal is replaced by a subtree, grown with the GROW method. The parameter maxDepth sets the maximum depth of the tree that is grown. If maxDepth is set to a high value (greater than about 20), it may be necessary to increase the stack size, e.g. -Xss128M, to avoid stack overflow.


getMaximumExpandDepth

public int getMaximumExpandDepth()
maximumExpandDepth is the maximum allowable depth of the subtree grown during an EXPAND mutation. It has a default value of 4.


setMaximumReplacementDepth

public void setMaximumReplacementDepth(int maxDepth)
When the SUBTREE_REPLACEMENT mutation takes place, a randomly chosen subtree is replaced by a random subtree, of similar size grown with the GROW method. The parameter maxDepth sets the maximum depth of the tree that is grown. If maxDepth is set to a high value (greater than about 20), it may be necessary to increase the stack size, e.g. -Xss128M, to avoid stack overflow.


getMaximumReplacementDepth

public int getMaximumReplacementDepth()
maximumReplacementDepth is the maximum allowable depth of the subtree grown during a SUBTREE mutation. It has a default value of 4.


getMutationOperators

public Mutation.MutationOperator[] getMutationOperators()
Returns the array of mutationOperators used to perform mutation. This array should have been provided to the constructor.