gpalta.core
Class Tree

java.lang.Object
  extended by gpalta.core.Individual
      extended by gpalta.core.Tree
All Implemented Interfaces:
NodeParent, java.io.Serializable, java.lang.Cloneable

public class Tree
extends Individual
implements NodeParent

The simplest individual: a function tree

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gpalta.core.Individual
fitCalculated, hits
 
Constructor Summary
Tree(NodeSet type)
          Creates a new instance of Tree
Tree(java.lang.String expression, NodeSet type, NodeFactory nodeFactory)
           
 
Method Summary
 Individual deepClone()
          Get a new, totally independent copy of this individual.
 Output eval(ProblemData problemData)
           
 void evalVect(Output out, TempVectorFactory tempVectorFactory, ProblemData problemData)
           
 int getCurrentDepth()
           
 Node getKid(int whichKid)
           
 int getMaxDepthFromHere()
           
 int getNSubNodes()
           
 NodeParent getParent()
           
 int getSize()
          Get the size of this Individual, hopefully without recalculating it (ie. in the case of a Tree, without descending every node).
 void newKids()
           
 int nKids()
           
 void setKid(int whichKid, Node kid)
           
 void setMaxDepthFromHere(int maxDepthFromHere)
           
 void setNSubNodes(int nSubNodes)
           
 java.lang.String toString()
           
 NodeSet typeOfKids(int whichKid)
           
 
Methods inherited from class gpalta.core.Individual
isOnPop, readFitness, setFitness, setOnPop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tree

public Tree(NodeSet type)
Creates a new instance of Tree


Tree

public Tree(java.lang.String expression,
            NodeSet type,
            NodeFactory nodeFactory)
Method Detail

eval

public Output eval(ProblemData problemData)
Specified by:
eval in class Individual

evalVect

public void evalVect(Output out,
                     TempVectorFactory tempVectorFactory,
                     ProblemData problemData)
Specified by:
evalVect in class Individual

nKids

public int nKids()
Specified by:
nKids in interface NodeParent

typeOfKids

public NodeSet typeOfKids(int whichKid)
Specified by:
typeOfKids in interface NodeParent

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

deepClone

public Individual deepClone()
Description copied from class: Individual
Get a new, totally independent copy of this individual. Subclasses must implement this method properly, in order to insure that two instances are not modified unintentionally

Specified by:
deepClone in class Individual

getSize

public int getSize()
Description copied from class: Individual
Get the size of this Individual, hopefully without recalculating it (ie. in the case of a Tree, without descending every node). In most cases, this will mean the number of nodes present in the Individual

Specified by:
getSize in class Individual

getParent

public NodeParent getParent()
Specified by:
getParent in interface NodeParent

getNSubNodes

public int getNSubNodes()
Specified by:
getNSubNodes in interface NodeParent

setNSubNodes

public void setNSubNodes(int nSubNodes)
Specified by:
setNSubNodes in interface NodeParent

getKid

public Node getKid(int whichKid)
Specified by:
getKid in interface NodeParent

setKid

public void setKid(int whichKid,
                   Node kid)
Specified by:
setKid in interface NodeParent

getMaxDepthFromHere

public int getMaxDepthFromHere()
Specified by:
getMaxDepthFromHere in interface NodeParent

setMaxDepthFromHere

public void setMaxDepthFromHere(int maxDepthFromHere)
Specified by:
setMaxDepthFromHere in interface NodeParent

getCurrentDepth

public int getCurrentDepth()
Specified by:
getCurrentDepth in interface NodeParent

newKids

public void newKids()
Specified by:
newKids in interface NodeParent