gpsys
Class GeneBranch

java.lang.Object
  |
  +--gpsys.GeneBranch

public class GeneBranch
extends java.lang.Object

A GeneBranch defines a Gene subtree of a GP Gene tree. It has instance variables defining the parent Gene of this subtree, and where it is referenced in the parent. The GeneBranch provides suffiecient information to allow a subtree to be replaced by another one. The latter could be generated either by creation (for mutation) or crossover.

Version:
$Revision: 1.1 $, $Date: 2000/07/05 16:21:25 $
Author:
Adil Qureshi
Department of Computer Science,
University College London,
Gower St,
London WC1E 6BT,
UK.

Field Summary
 Gene child
          The Gene subtree itself.
static long functionCount
          Total number of times a function point was selected for mutation or crossover.
 int index
          The arguments index of this Gene subtree in the parent Gene.
 Gene parent
          The parent of the Gene subtree.
static long terminalCount
          Total number of times a terminal point was selected for mutation or crossover.
static int TYPE_VECTOR_SIZE
          The default size of the vector used for keeping subtrees of a given type.
 
Constructor Summary
private GeneBranch(Gene parent, int index, Gene child)
          Construct a GeneBranch using the supplied arguments to initialise the instance variables.
  GeneBranch(java.util.Random rng, Gene treeTop)
          select a subtree at random from the given tree.
  GeneBranch(java.util.Random rng, Gene treeTop, Type type)
          select a subtree of a given type at random from the given tree.
 
Method Summary
static void branchesOfType(Gene parent, int index, Gene child, Type type, java.util.Vector terminalBranches, java.util.Vector functionBranches)
          Get a table of all subtrees of a given type.
 void selectBranch(java.util.Random rng, Gene tree, Type type)
          select a subtree of at random from the given tree.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

parent

public Gene parent
The parent of the Gene subtree.

index

public int index
The arguments index of this Gene subtree in the parent Gene.

child

public Gene child
The Gene subtree itself.

TYPE_VECTOR_SIZE

public static final int TYPE_VECTOR_SIZE
The default size of the vector used for keeping subtrees of a given type.

functionCount

public static long functionCount
Total number of times a function point was selected for mutation or crossover.

terminalCount

public static long terminalCount
Total number of times a terminal point was selected for mutation or crossover.
Constructor Detail

GeneBranch

private GeneBranch(Gene parent,
                   int index,
                   Gene child)
Construct a GeneBranch using the supplied arguments to initialise the instance variables.
Parameters:
parent - the parent of this subtree.
index - the arguments index of this Gene subtree in the parent Gene.
child - the subtree itself.

GeneBranch

public GeneBranch(java.util.Random rng,
                  Gene treeTop)
select a subtree at random from the given tree.
Parameters:
rng - the random number generator to be used.
treeTop - the tree from which to select a subtree.

GeneBranch

public GeneBranch(java.util.Random rng,
                  Gene treeTop,
                  Type type)
select a subtree of a given type at random from the given tree.
Parameters:
rng - the random number generator to be used.
treeTop - the tree from which to select a subtree.
type - the type of the subtree to be selected.
Method Detail

selectBranch

public void selectBranch(java.util.Random rng,
                         Gene tree,
                         Type type)
select a subtree of at random from the given tree. Initialise the instance variable to reflect the selected tree.
Parameters:
rng - the random number generator to be used.
tree - the tree from which to select a subtree.

branchesOfType

public static void branchesOfType(Gene parent,
                                  int index,
                                  Gene child,
                                  Type type,
                                  java.util.Vector terminalBranches,
                                  java.util.Vector functionBranches)
Get a table of all subtrees of a given type.
Parameters:
parent - the parent Gene of the child.
index - the arguments index of the child in the parent.
child - the child Gene subtree.
type - the type of subtree required (null if don't care).
terminalBranches - the table of subtrees that are terminals.
functionBranches - the table of subtrees that are functions.