com.groovyj.jgprog
Class BranchTypingCross

java.lang.Object
  |
  +--com.groovyj.jgprog.CrossMethod
        |
        +--com.groovyj.jgprog.BranchTypingCross

public class BranchTypingCross
extends CrossMethod


Constructor Summary
BranchTypingCross()
           
 
Method Summary
 Individual[] cross(Individual i1, Individual i2)
          Crosses two individuals.
protected static Chromosome[] doCross(Chromosome c0, Chromosome c1)
          Crosses two chromsomes using branch-typing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BranchTypingCross

public BranchTypingCross()
Method Detail

cross

public Individual[] cross(Individual i1,
                          Individual i2)
Crosses two individuals. A random chromosome is chosen for crossing based probabilistically on the proportion of nodes in each chromosome in the first individual.

Overrides:
cross in class CrossMethod
Parameters:
i1 - the first individual to cross
i2 - the second individual to cross
Returns:
an array of the two resulting individuals

doCross

protected static Chromosome[] doCross(Chromosome c0,
                                      Chromosome c1)
Crosses two chromsomes using branch-typing.

A random point in the first chromosome is chosen, with 90% probability it will be a function and 10% 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 given maximum depth then that chromosome is simply copied from the original rather than crossed.

Parameters:
c0 - the first chromosome to cross
c1 - the second chromosome to cross
Returns:
an array of the two resulting chromosomes
Since:
1.0