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:
And, Divide, Equals, Exponential, GreaterThan, IfThenElse, LessThan, LogicConstant, Minus, Not, Or, Plus, RealConstant, RealVar, Square, SquareRoot, Times

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

Generic Node definition

See Also:
Serialized Form

Constructor Summary
Node()
           
 
Method Summary
 java.lang.Object clone()
           
 Node deepClone(int currentDepth)
           
abstract  double eval(DataHolder data)
          Evaluate the Node for a sinlge sample.
protected abstract  void evalVect(double[] outVect, double[][] kidOutVect, DataHolder data)
          Evaluate the Node for all samples (vectorial evaluation).
 void evalVect(Output out, TempOutputFactory tempOutputFactory, DataHolder data)
          Evaluate a Node for all samples (vectorial evaluation), using Output objects for storing the results.
 int getCurrentDepth()
           
 Node getKid(int whichKid)
           
 int getMaxDepthFromHere()
           
 int getNSubNodes()
           
 NodeParent getParent()
           
 int getWhichKidOfParent()
           
 void init(Config config, DataHolder data)
          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 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

init

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

Parameters:
config -
data -

eval

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

Parameters:
data -
Returns:
The output of the Node

evalVect

public void evalVect(Output out,
                     TempOutputFactory tempOutputFactory,
                     DataHolder data)
Evaluate a Node for all samples (vectorial evaluation), using Output objects for storing the results. Override this method only if the Node has a special behabior with respect to multiple dimension outputs

Parameters:
out -
tempOutputFactory -
data -

evalVect

protected abstract void evalVect(double[] outVect,
                                 double[][] kidOutVect,
                                 DataHolder data)
Evaluate the Node for all samples (vectorial evaluation). All Nodes must override this method

Parameters:
outVect - The array where the outout must be stored
kidOutVect - A matrix holding the outputs of this Node's kids. Each row holds the output for each kid
data - 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