gov.sandia.cognition.framework.lite
Class MutableSemanticMemoryLite

java.lang.Object
  extended by gov.sandia.cognition.framework.lite.AbstractSemanticMemoryLite
      extended by gov.sandia.cognition.framework.lite.MutableSemanticMemoryLite
All Implemented Interfaces:
CognitiveModule, SemanticMemory, Serializable

public class MutableSemanticMemoryLite
extends AbstractSemanticMemoryLite

The MutableSemanticMemoryLite implements a SemanticMemory that can be dynamically changed. Because it can be dynamically changed,

Since:
1.0
Author:
Justin Basilico, Kevin R. Dixon
See Also:
Serialized Form

Constructor Summary
MutableSemanticMemoryLite(SemanticIdentifierMap semanticIdentifierMap, MutablePatternRecognizerLite recognizer)
          Creates a new instance of MutableSemanticMemoryLite.
 
Method Summary
 void addNode(SemanticLabel label)
          Adds a node to the semantic memory.
protected  void assertArgumentIsNode(SemanticLabel label)
          Asserts that the given argument is a node, throwing an IllegalArgumentException if it is not a node.
protected  void buildInputMapping()
          Builds the mapping of identifiers to input indices.
 int findInputIndexForIdentifier(SemanticIdentifier semanticIdentifier)
          Finds the input vector index for a given identifier.
 String getName()
          Gets the human-readable name of module.
 MutablePatternRecognizerLite getSettings()
          Gets the pattern recognizer.
 boolean isNode(SemanticLabel label)
          Returns true if the given semantic label is a node in the network.
 void removeNode(SemanticLabel label)
          Removes a node and all links associated with that node from the semantic memory.
 void setAssociation(SemanticLabel from, SemanticLabel to, double weight)
          Sets the association between nodes in the recognizer.
 boolean trySetInputLabel(SemanticLabel label, boolean inputLabel)
          Attempts to set whether or not the given label is an input label.
 boolean trySetOutputLabel(SemanticLabel label, boolean outputLabel)
          Attempts to set whether or not the given label is an output label.
 
Methods inherited from class gov.sandia.cognition.framework.lite.AbstractSemanticMemoryLite
buildOutputMapping, getNetwork, getOutputIdentifiers, getRecognizer, getSemanticIdentifierMap, initializeState, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MutableSemanticMemoryLite

public MutableSemanticMemoryLite(SemanticIdentifierMap semanticIdentifierMap,
                                 MutablePatternRecognizerLite recognizer)
Creates a new instance of MutableSemanticMemoryLite. It creates its own copy of the given mutable recognizer.

Parameters:
semanticIdentifierMap - The SemanticIdentifierMap to use.
recognizer - The pattern recognizer to use, which is copied and stored internally.
Method Detail

buildInputMapping

protected void buildInputMapping()
Builds the mapping of identifiers to input indices.


findInputIndexForIdentifier

public int findInputIndexForIdentifier(SemanticIdentifier semanticIdentifier)
Finds the input vector index for a given identifier. If the identifier is not in the index, -1 is returned.

Specified by:
findInputIndexForIdentifier in class AbstractSemanticMemoryLite
Parameters:
semanticIdentifier - The identifier to find the input index of.
Returns:
The input vector index for the given identifier, if it is part of the input vector. -1 otherwise.

isNode

public boolean isNode(SemanticLabel label)
Returns true if the given semantic label is a node in the network.

Parameters:
label - The label to look at.
Returns:
True if the given label is a node in the semantic network and false otherwise.

addNode

public void addNode(SemanticLabel label)
Adds a node to the semantic memory.

Parameters:
label - The label for the node to add.

removeNode

public void removeNode(SemanticLabel label)
Removes a node and all links associated with that node from the semantic memory.

Parameters:
label - The label of the node to remove.

trySetInputLabel

public boolean trySetInputLabel(SemanticLabel label,
                                boolean inputLabel)
Attempts to set whether or not the given label is an input label. It returns true if the set operation was successful and false otherwise.

Parameters:
label - The label to set whether or not it is input label.
inputLabel - Whether or not the label is an input label.
Returns:
True if the operation was successful and false if it was not.

trySetOutputLabel

public boolean trySetOutputLabel(SemanticLabel label,
                                 boolean outputLabel)
Attempts to set whether or not the given label is an output label. It returns true if the set operation was successful and false otherwise.

Parameters:
label - The label to set whether or not it is output label.
outputLabel - Whether or not the label is an output label.
Returns:
True if the operation was successful and false if it was not.

setAssociation

public void setAssociation(SemanticLabel from,
                           SemanticLabel to,
                           double weight)
Sets the association between nodes in the recognizer.

Parameters:
from - The label of the node the assocation is from.
to - The label of the node the assocation is to.
weight - The weight of the association.

assertArgumentIsNode

protected void assertArgumentIsNode(SemanticLabel label)
Asserts that the given argument is a node, throwing an IllegalArgumentException if it is not a node.

Parameters:
label - The label to assert that it is a node in the recognizer.
Throws:
IllegalArgumentException - If the given label is not a node.

getName

public String getName()
Gets the human-readable name of module.

Returns:
The human-readable name of the module.

getSettings

public MutablePatternRecognizerLite getSettings()
Gets the pattern recognizer.

Returns:
The pattern recognizer.