com.epochx.op.crossover
Class KozaCrossover<TYPE>

java.lang.Object
  extended by com.epochx.op.crossover.KozaCrossover<TYPE>
All Implemented Interfaces:
GenerationListener, Crossover<TYPE>

public class KozaCrossover<TYPE>
extends java.lang.Object
implements Crossover<TYPE>, GenerationListener

This class implements a Koza style crossover operation on two CandidatePrograms.

Koza crossover performs a one point exchange with the choice of a swap point being either a function or terminal node with assigned probabilities. This class provides a constructor for specifying a probability of selecting a function swap point. The default constructor uses the typical rates of 90% function node swap point and 10% terminal node swap points.


Constructor Summary
KozaCrossover(GPModel<TYPE> model)
          Default constructor for Koza standard crossover.
KozaCrossover(GPModel<TYPE> model, double functionSwapProbability)
          Construct an instance of Koza crossover.
 
Method Summary
 CandidateProgram<TYPE>[] crossover(CandidateProgram<TYPE> program1, CandidateProgram<TYPE> program2)
          Crossover the two CandidatePrograms provided as arguments using Koza crossover.
 void onGenerationStart()
          Called at the start of each generation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KozaCrossover

public KozaCrossover(GPModel<TYPE> model,
                     double functionSwapProbability)
Construct an instance of Koza crossover.

Parameters:
functionSwapProbability - The probability of crossover operations choosing a function node as the swap point.

KozaCrossover

public KozaCrossover(GPModel<TYPE> model)
Default constructor for Koza standard crossover. The probability of a function node being selected as the swap point will default to 90%.

Method Detail

crossover

public CandidateProgram<TYPE>[] crossover(CandidateProgram<TYPE> program1,
                                          CandidateProgram<TYPE> program2)
Crossover the two CandidatePrograms provided as arguments using Koza crossover. The crossover points will be chosen from the function or terminal sets with the probability assigned at construction or the default value of 90% function node.

Specified by:
crossover in interface Crossover<TYPE>
Parameters:
program1 - The first CandidateProgram selected to undergo Koza crossover.
program2 - The second CandidateProgram selected to undergo Koza crossover.
Returns:
An array of the child CandidatePrograms that were the result of an exchange of genetic material between the two parents.

onGenerationStart

public void onGenerationStart()
Description copied from interface: GenerationListener
Called at the start of each generation. Note that this method is called before the generation statistics are generated so any generation statistics will be created based upon the population returned here.

Specified by:
onGenerationStart in interface GenerationListener