jchrest.architecture
Class Node

java.lang.Object
  extended by java.util.Observable
      extended by jchrest.architecture.Node

public class Node
extends java.util.Observable

Represents a node within the model's long-term memory discrimination network. Methods support learning and also display.


Constructor Summary
Node(Chrest model, int reference, ListPattern type)
          Constructor to construct a new root node for the model.
Node(Chrest model, ListPattern contents, ListPattern image)
          When constructing non-root nodes in the network, the new contents and image must be defined.
 
Method Summary
 void addActionLink(Node node)
          Add a node to the list of action links for this node.
 double averageDepth()
          Compute the average depth of nodes below this point.
 double averageImageSize()
          Compute the average size of the images in nodes below this point.
 boolean canFormTemplate()
          Return true if template conditions are met: 1.
 void clearFilledSlots()
           
 void clearTemplate()
          Clear out the template slots.
 void constructTemplates()
          Converts this node into a template, if appropriate, and repeats for all child nodes.
 int countTemplates()
          Count templates in part of network rooted at this node.
 void fillSlots(ListPattern pattern)
          Attempt to fill some of the slots using the items in the given pattern.
 java.util.List<Node> getActionLinks()
           
 Node getAssociatedNode()
          Accessor to node that is associated with this node.
 java.util.List<Link> getChildren()
          Accessor to children of node.
protected  void getContentCounts(java.util.Map<java.lang.Integer,java.lang.Integer> size)
          Add to a map of content sizes to node counts for this node and its children.
 ListPattern getContents()
          Accessor to contents of node.
 java.util.List<ItemSquarePattern> getFilledItemSlots()
           
 java.util.List<ItemSquarePattern> getFilledPositionSlots()
           
 ListPattern getImage()
          Accessor to image of node.
protected  void getImageCounts(java.util.Map<java.lang.Integer,java.lang.Integer> size)
          Add to a map of image sizes to node counts for this node and its children.
 Node getNamedBy()
          Accessor to node that names this node.
 int getReference()
          Accessor to reference number of node.
protected  void getSemanticLinkCounts(java.util.Map<java.lang.Integer,java.lang.Integer> size)
          Add to a map from number of semantic links to frequency, for this node and its children.
 java.util.List<Node> getSemanticLinks()
          Accessor to list of semantic links.
 int information()
          Compute the amount of information in current node.
 boolean isTemplate()
          Returns true if this node is a template.
 Node learnPrimitive(ListPattern pattern)
          LearnPrimitive is used to construct a test link and node containing precisely the given pattern.
 Node searchSemanticLinks(int maximumSemanticDistance)
          Search this node's semantic links for a more informative node, and return one if found.
 void setAssociatedNode(Node node)
          Modify node that is associated with this node.
 void setImage(ListPattern image)
          Change the node's image.
 void setNamedBy(Node node)
          Modify node that names this node.
 int size()
          Compute the size of the network below the current node.
 void writeLinksAsVna(java.io.Writer writer)
           
 void writeNodeAsVna(java.io.Writer writer)
          Write node information in VNA format.
 void writeSemanticLinksAsVna(java.io.Writer writer)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

public Node(Chrest model,
            int reference,
            ListPattern type)
Constructor to construct a new root node for the model.


Node

public Node(Chrest model,
            ListPattern contents,
            ListPattern image)
When constructing non-root nodes in the network, the new contents and image must be defined. Assume that the image always starts empty.

Method Detail

getReference

public int getReference()
Accessor to reference number of node.


getContents

public ListPattern getContents()
Accessor to contents of node.


getImage

public ListPattern getImage()
Accessor to image of node.


setImage

public void setImage(ListPattern image)
Change the node's image. Also notifies any observers.


getChildren

public java.util.List<Link> getChildren()
Accessor to children of node.


getSemanticLinks

public java.util.List<Node> getSemanticLinks()
Accessor to list of semantic links.


getAssociatedNode

public Node getAssociatedNode()
Accessor to node that is associated with this node.


setAssociatedNode

public void setAssociatedNode(Node node)
Modify node that is associated with this node.


getNamedBy

public Node getNamedBy()
Accessor to node that names this node.


setNamedBy

public void setNamedBy(Node node)
Modify node that names this node.


addActionLink

public void addActionLink(Node node)
Add a node to the list of action links for this node. Do not add the node if already present.


getActionLinks

public java.util.List<Node> getActionLinks()

size

public int size()
Compute the size of the network below the current node.


information

public int information()
Compute the amount of information in current node. Information is based on the size of the image + the number of slots.


getContentCounts

protected void getContentCounts(java.util.Map<java.lang.Integer,java.lang.Integer> size)
Add to a map of content sizes to node counts for this node and its children.


getImageCounts

protected void getImageCounts(java.util.Map<java.lang.Integer,java.lang.Integer> size)
Add to a map of image sizes to node counts for this node and its children.


getSemanticLinkCounts

protected void getSemanticLinkCounts(java.util.Map<java.lang.Integer,java.lang.Integer> size)
Add to a map from number of semantic links to frequency, for this node and its children.


averageDepth

public double averageDepth()
Compute the average depth of nodes below this point.


averageImageSize

public double averageImageSize()
Compute the average size of the images in nodes below this point.


countTemplates

public int countTemplates()
Count templates in part of network rooted at this node.


getFilledItemSlots

public java.util.List<ItemSquarePattern> getFilledItemSlots()

getFilledPositionSlots

public java.util.List<ItemSquarePattern> getFilledPositionSlots()

isTemplate

public boolean isTemplate()
Returns true if this node is a template. To be a template, the node must have at least one slot of any kind.


clearTemplate

public void clearTemplate()
Clear out the template slots.


fillSlots

public void fillSlots(ListPattern pattern)
Attempt to fill some of the slots using the items in the given pattern.


clearFilledSlots

public void clearFilledSlots()

constructTemplates

public void constructTemplates()
Converts this node into a template, if appropriate, and repeats for all child nodes. Note: usually, this process is done as a whole at the end of training, but can also be done on a node-by-node basis, during training.


canFormTemplate

public boolean canFormTemplate()
Return true if template conditions are met: 1. contents size > _model.getMinTemplateLevel () then: 2. gather together current node image and images of all nodes linked by the test and semantic links remove the contents of current node from those images see if any piece or square repeats more than once


learnPrimitive

public Node learnPrimitive(ListPattern pattern)
LearnPrimitive is used to construct a test link and node containing precisely the given pattern. It is assumed the given pattern contains a single primitive item, and is finished. TODO: CLEAN UP CODE AND DESCRIPTION


searchSemanticLinks

public Node searchSemanticLinks(int maximumSemanticDistance)
Search this node's semantic links for a more informative node, and return one if found.


writeNodeAsVna

public void writeNodeAsVna(java.io.Writer writer)
                    throws java.io.IOException
Write node information in VNA format.

Throws:
java.io.IOException

writeLinksAsVna

public void writeLinksAsVna(java.io.Writer writer)
                     throws java.io.IOException
Throws:
java.io.IOException

writeSemanticLinksAsVna

public void writeSemanticLinksAsVna(java.io.Writer writer)
                             throws java.io.IOException
Throws:
java.io.IOException