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
 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<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()
           
 Node getFollowedBy()
          Accessor to node that follows this node.
 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 getSimilarityCounts(java.util.Map<java.lang.Integer,java.lang.Integer> size)
          Add to a map from number of similarity nodes to frequency, for this node and its children.
 java.util.List<Node> getSimilarNodes()
          Accessor to list of similar nodes.
 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.
 void setFollowedBy(Node node)
          Modify node that follows 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 writeSimilarityLinksAsVna(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.


getSimilarNodes

public java.util.List<Node> getSimilarNodes()
Accessor to list of similar nodes.


getFollowedBy

public Node getFollowedBy()
Accessor to node that follows this node.


setFollowedBy

public void setFollowedBy(Node node)
Modify node that follows 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.


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.


getSimilarityCounts

protected void getSimilarityCounts(java.util.Map<java.lang.Integer,java.lang.Integer> size)
Add to a map from number of similarity nodes 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 be 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 one of: 2. gather together current node image and images of all nodes linked by the test 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.


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

writeSimilarityLinksAsVna

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