gpalta.nodes
Class Node

java.lang.Object
  extended by gpalta.nodes.Node
All Implemented Interfaces:
NodeParent, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Abs, And, Angle, Cos, Divide, Equals, Exponential, GreaterThan, IfThenElse, LessThan, LogicConstant, Minus, NormOfX, Not, Or, Plus, RBF, RealConstant, RealVar, Sin, Square, SquareRoot, Times

public abstract class Node
extends java.lang.Object
implements NodeParent, java.lang.Cloneable, java.io.Serializable

Generic Node definition. User defined nodes must extend this class

See Also:
Serialized Form

Constructor Summary
Node()
           
 
Method Summary
 java.lang.Object clone()
           
 Node deepClone(int currentDepth)
           
abstract  double eval(ProblemData problemData)
          Evaluate the Node for a single sample.
 void evalVect(double[] outVect, TempVectorFactory tempVectorFactory, ProblemData problemData)
          Evaluate a Node for all samples (vectorial evaluation).
protected abstract  void evalVectInternal(double[] outVect, double[][] kidsOutput, ProblemData problemData)
          Internal method that evaluates the Node given its kids' outputs.
 int getCurrentDepth()
           
 Node getKid(int whichKid)
           
 int getMaxDepthFromHere()
           
 int getNSubNodes()
           
 NodeParent getParent()
           
 NodeSet getType()
           
 int getWhichKidOfParent()
           
 void init(Config config, ProblemData problemData)
          Initialize the Node.
abstract  java.lang.String name()
          Get the Node's short name (such as "plus", "minus", "x1", etc)
 void newKids()
           
abstract  int nKids()
          Read the number of kids of the Node
static java.lang.String parse(java.lang.String expression, NodeParent parent, int whichKid, NodeFactory nodeFactory)
           
 void setCurrentDepth(int currentDepth)
           
 void setKid(int whichKid, Node kid)
           
 void setMaxDepthFromHere(int maxDepthFromHere)
           
 void setNSubNodes(int nSubNodes)
           
 void setParent(NodeParent parent)
           
 void setType(NodeSet type)
           
 void setTypeOfKids(int whichKid, NodeSet t)
           
 void setWhichKidOfParent(int whichKidOfParent)
           
 java.lang.String toString()
           
 NodeSet typeOfKids(int whichKid)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node()
Method Detail

getType

public NodeSet getType()

setType

public void setType(NodeSet type)

init

public void init(Config config,
                 ProblemData problemData)
Initialize the Node. Override this if the node has a state that needs to be specified when created

Parameters:
config -
problemData -

eval

public abstract double eval(ProblemData problemData)
Evaluate the Node for a single sample. All Nodes must override this method. The Node is responsible for evaluating its children, if any.

Parameters:
problemData -
Returns:
The output of the Node

evalVect

public final void evalVect(double[] outVect,
                           TempVectorFactory tempVectorFactory,
                           ProblemData problemData)
Evaluate a Node for all samples (vectorial evaluation). This method should be called by an Individual to evaluate the root Node

Parameters:
outVect -
tempVectorFactory -
problemData -

evalVectInternal

protected abstract void evalVectInternal(double[] outVect,
                                         double[][] kidsOutput,
                                         ProblemData problemData)
Internal method that evaluates the Node given its kids' outputs. All Nodes must override this method. Different to eval(), in this case, kids are already evaluated

Parameters:
outVect - The array where the outout must be stored
kidsOutput - Each array holds all the outputs for a kid
problemData - The problem's data

setTypeOfKids

public void setTypeOfKids(int whichKid,
                          NodeSet t)

typeOfKids

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

nKids

public abstract int nKids()
Read the number of kids of the Node

Specified by:
nKids in interface NodeParent
Returns:
The number of kids this Node has

name

public abstract java.lang.String name()
Get the Node's short name (such as "plus", "minus", "x1", etc)

Returns:
The Node's name

toString

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

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

deepClone

public Node deepClone(int currentDepth)

parse

public static java.lang.String parse(java.lang.String expression,
                                     NodeParent parent,
                                     int whichKid,
                                     NodeFactory nodeFactory)

getWhichKidOfParent

public int getWhichKidOfParent()

setWhichKidOfParent

public void setWhichKidOfParent(int whichKidOfParent)

getParent

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

setParent

public void setParent(NodeParent parent)

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

getCurrentDepth

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

setCurrentDepth

public void setCurrentDepth(int currentDepth)

newKids

public void newKids()
Specified by:
newKids 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