classifier.gp
Class CrossoverPlain

java.lang.Object
  extended byclassifier.gp.CrossoverPlain
All Implemented Interfaces:
CrossoverOperator, Operators, java.io.Serializable

public class CrossoverPlain
extends java.lang.Object
implements CrossoverOperator

Implementation of the classical crossover operator

Version:
0.1
Author:
Sacchi Matteo, Sassi Federico
See Also:
Serialized Form

Field Summary
protected  double external
           
protected  GProgram female
           
protected  double internal
           
protected  GProgram male
           
protected  int max_depth
           
 
Constructor Summary
CrossoverPlain(int max_depth, double internal, boolean keep)
          Inizialize the parameters of the crossover
 
Method Summary
 double getExternaleRate()
          Probability that a external node is chosen as a crossover point
 double getInternalRate()
          Probability that a internal node is chosen as a crossover point
 int getMaxDepth()
          Maximum allowable depth of the resulting tree
 void setExternalRate(double external)
          To change the probability that a external node is chosen as a crossover point
 void setInternalRate(double internal)
          To change the probability that a internal node is chosen as a crossover point
 void setMaxDetph(int max)
          To change the maximum allowable depth of a tree
 GProgram[] start(GProgram[] programs)
          Method to start the crossover operation
(package private)  void validateCrossover(GProgram male, GProgram female, GProgram[] offspring)
          To check if the result of a crossover is valid, if it's not and keep==true then the crossover operation will be repeated recursively
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

male

protected GProgram male

female

protected GProgram female

max_depth

protected int max_depth

internal

protected double internal

external

protected double external
Constructor Detail

CrossoverPlain

public CrossoverPlain(int max_depth,
                      double internal,
                      boolean keep)
Inizialize the parameters of the crossover

Parameters:
max_depth - Maximum allowable depth of the resulting tree
internal - Probability [0..1] that a internal node is chosen as a crossover point
keep - if it is true the crossover will be repeated until a pair of valid children in found
Method Detail

getMaxDepth

public int getMaxDepth()
Maximum allowable depth of the resulting tree

Returns:
An integer that correspond to the maximum allowable depth of a tree

getInternalRate

public double getInternalRate()
Probability that a internal node is chosen as a crossover point

Returns:
The probability as a double in the range [0..1]

getExternaleRate

public double getExternaleRate()
Probability that a external node is chosen as a crossover point

Returns:
The probability as a double in the range [0..1]

setMaxDetph

public void setMaxDetph(int max)
To change the maximum allowable depth of a tree

Parameters:
max - new integer value of the maximum depth

setInternalRate

public void setInternalRate(double internal)
To change the probability that a internal node is chosen as a crossover point

Parameters:
internal - a double value in the range of [0..1]

setExternalRate

public void setExternalRate(double external)
To change the probability that a external node is chosen as a crossover point

Parameters:
external - a double value in the range of [0..1]

start

public GProgram[] start(GProgram[] programs)
Method to start the crossover operation

Specified by:
start in interface CrossoverOperator
Parameters:
programs - Array of 2 GProgram containing the parents
Returns:
Array of 2 GProgram containing the result of the crossover

validateCrossover

void validateCrossover(GProgram male,
                       GProgram female,
                       GProgram[] offspring)
To check if the result of a crossover is valid, if it's not and keep==true then the crossover operation will be repeated recursively

Parameters:
male - a parent
female - the other parent
offspring - array of 2 GProgram that contain the offspring that have to be checked