JGAP

org.jgap.gp.impl
Class BranchTypingCross

java.lang.Object
  extended by org.jgap.gp.CrossMethod
      extended by org.jgap.gp.impl.BranchTypingCross
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class BranchTypingCross
extends CrossMethod
implements java.io.Serializable, java.lang.Comparable, java.lang.Cloneable

Crossing over for GP ProgramChromosomes.

Since:
3.0
See Also:
Serialized Form

Constructor Summary
BranchTypingCross(GPConfiguration a_config)
          Standard constructor.
BranchTypingCross(GPConfiguration a_config, boolean a_simpleChromosomeSelection)
           
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object a_other)
          The compareTo-method.
protected  ProgramChromosome[] doCross(ProgramChromosome a_c0, ProgramChromosome a_c1)
          Crosses two chromsomes using branch-typing.
 boolean equals(java.lang.Object a_other)
          The equals-method.
 IGPProgram[] operate(IGPProgram a_i1, IGPProgram a_i2)
          Crosses two individuals.
 
Methods inherited from class org.jgap.gp.CrossMethod
getConfiguration
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BranchTypingCross

public BranchTypingCross(GPConfiguration a_config)
Standard constructor.

Parameters:
a_config - the configuration to use

BranchTypingCross

public BranchTypingCross(GPConfiguration a_config,
                         boolean a_simpleChromosomeSelection)
Parameters:
a_config - the configuration to use
a_simpleChromosomeSelection - true: plainly select chromosomes, false: select chromosomes proportionally to their size (=number of nodes within a chromosome)
Since:
3.4
Method Detail

operate

public IGPProgram[] operate(IGPProgram a_i1,
                            IGPProgram a_i2)
Crosses two individuals. A random chromosome is chosen for crossing based on the proportion of nodes in each chromosome in the first individual.

Specified by:
operate in class CrossMethod
Parameters:
a_i1 - the first individual to cross
a_i2 - the second individual to cross
Returns:
an array of the two resulting individuals
Since:
3.0

doCross

protected ProgramChromosome[] doCross(ProgramChromosome a_c0,
                                      ProgramChromosome a_c1)
                               throws InvalidConfigurationException
Crosses two chromsomes using branch-typing. A random point in the first chromosome is chosen, with a certain probability it will be a function and with a rest probability it will be a terminal. A random point in the second chromosome is chosen using the same probability distribution, but the node chosen must be of the same type as the chosen node in the first chromosome. If a suitable point in the second chromosome couldn't be found then the chromosomes are not crossed. If a resulting chromosome's depth is larger than the maximum crossover depth then that chromosome is simply copied from the original rather than crossed.

Parameters:
a_c0 - the first chromosome to cross
a_c1 - the second chromosome to cross
Returns:
an array of the two resulting chromosomes
Throws:
InvalidConfigurationException
Since:
3.0

compareTo

public int compareTo(java.lang.Object a_other)
The compareTo-method.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
a_other - the other object to compare
Returns:
0 or 1 in this case, as BranchTypingCross objects keep no state
Since:
3.0

equals

public boolean equals(java.lang.Object a_other)
The equals-method.

Overrides:
equals in class java.lang.Object
Parameters:
a_other - the other object to compare
Returns:
always true for non-null BranchTypingCross objects because they keep no state
Since:
3.0

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object
Returns:
deep clone of this instance
Since:
3.2

JGAP