geneticWedge.gp
Class Crossover

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

public final class Crossover
extends java.lang.Object

Crossover performs crossover ('sexual' recombination) between 2 Individuals, generating 1 or 2 offspring. It holds various parameters that control the way in which crossover is performed.


Constructor Summary
Crossover()
          The default constructor creates a Crossover with default parameters.
Crossover(double functionProportion, int noOfTries)
          Create a Crossover object.
 
Method Summary
 void collectTransmissionInfo(boolean collect)
          If set to true, collectTransmissionInfo saves information concerning the relationship between parent and offspring during crossover operations
 Individual[] cross(Individual ind1, Individual ind2, boolean twoOffspring, Input[] inputs, Constant[] constants, int maxLength, int maxDepth)
          This method returns an array of Individuals created by crossing 2 parents (ind1 and ind2).
 boolean getBroodUse()
          Checks whether brood recombination is being used.
 int getDataSamplingFactor()
          The dataSamplingFactor is a variable related to brood recombination.
 int getHalfBroodSize()
          halfBroodSize is the number of pairs of offspring created during brood recombination.
 java.util.Vector<double[]> getTransmissionInfo()
          Returns a vector containing information about the relationship between parent and offspring during crossover operations, provided collectTransmissionInfo has been set to true.
 void setBroodSize(int halfBroodSize)
          halfBroodSize is the number of pairs of offspring created during brood recombination.
 void setBroodSize(int halfBroodSize, int dataSamplingFactor)
          halfBroodSize is the number of pairs of offspring created during brood recombination.
 void setBroodUse(boolean useBrood)
          Sets whether brood recombination should be used.
 void setData(double[][] inputs, double[] targets)
          In order to use brood recombination the data, i.e.
 void setExpectedCrossoverDepth(double depth)
          This sets the 'expected' depth at which crossover will take place.
 void setFitnessFunction(AbstractPopulation.FitnessFunction fitnessFunction)
          This method is only important when using brood recombination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Crossover

public Crossover()
The default constructor creates a Crossover with default parameters. These are functionProportion of NaN (random choice of nodes) and noOfTries of 5 (before stopping the attempt to create valid offspring).


Crossover

public Crossover(double functionProportion,
                 int noOfTries)
Create a Crossover object.

Parameters:
functionProportion - The proportion of crossover points that will be chosen to be Functions. The remainder of crossover points will occur at Terminals. If set to NaN, crossover points will be seleted randomly.
noOfTries - The number of times that Crossover will try to create valid offspring.
Method Detail

setExpectedCrossoverDepth

public void setExpectedCrossoverDepth(double depth)
This sets the 'expected' depth at which crossover will take place. A Poisson distribution is then created with this expected value in order to select the depth at which crossover takes place. If this method is not called, or it is called with depth outside the range 0.0-1.0 (exclusive), the crossover 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 crossover operations


getTransmissionInfo

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


cross

public Individual[] cross(Individual ind1,
                          Individual ind2,
                          boolean twoOffspring,
                          Input[] inputs,
                          Constant[] constants,
                          int maxLength,
                          int maxDepth)
This method returns an array of Individuals created by crossing 2 parents (ind1 and ind2).

Parameters:
twoOffspring - If true two offspring will be returned. If false only one offspring will be returned.
maxDepth - The maximum depth of the returned offspring
maxLength - The maximum length of the returned offspring

setBroodSize

public void setBroodSize(int halfBroodSize)
halfBroodSize is the number of pairs of offspring created during brood recombination. For example, a half brood size of 4 will result in 8 (4 pairs) offspring, the best of which will pass through to the next generation.


setBroodSize

public void setBroodSize(int halfBroodSize,
                         int dataSamplingFactor)
halfBroodSize is the number of pairs of offspring created during brood recombination. For example, a half brood size of 4 will result in 8 (4 pairs) offspring, the best of which will bass through to the next generation. The dataSamplingFactor is the rate at which data will be sampled when assessing the fitness of brood members. For example a sampling factor of 10 will result in 1 in 10 of the data being sampled.


getHalfBroodSize

public int getHalfBroodSize()
halfBroodSize is the number of pairs of offspring created during brood recombination. For example, a half brood size of 4 will result in 8 (4 pairs) offspring, the best of which will pass through to the next generation.


getDataSamplingFactor

public int getDataSamplingFactor()
The dataSamplingFactor is a variable related to brood recombination. It is the rate at which data will be sampled when assessing the fitness of brood members. For example a sampling factor of 10 will result in 1 in 10 of the data being sampled.


setData

public void setData(double[][] inputs,
                    double[] targets)
In order to use brood recombination the data, i.e. inputs and target outputs, must be set, allowing the identification of successful crossover. This method must therefore be called by a Population before an attempt is made at crossover.


setBroodUse

public void setBroodUse(boolean useBrood)
Sets whether brood recombination should be used.


getBroodUse

public boolean getBroodUse()
Checks whether brood recombination is being used.


setFitnessFunction

public void setFitnessFunction(AbstractPopulation.FitnessFunction fitnessFunction)
This method is only important when using brood recombination.