edu.memphis.ccrg.lida.pam
Class PerceptualAssociativeMemoryImpl

java.lang.Object
  extended by edu.memphis.ccrg.lida.framework.FrameworkModuleImpl
      extended by edu.memphis.ccrg.lida.pam.PerceptualAssociativeMemoryImpl
All Implemented Interfaces:
PreafferenceListener, FrameworkModule, FullyInitializable, Initializable, ModuleListener, BroadcastListener, PerceptualAssociativeMemory, WorkspaceListener

public class PerceptualAssociativeMemoryImpl
extends FrameworkModuleImpl
implements PerceptualAssociativeMemory, BroadcastListener, WorkspaceListener, PreafferenceListener

Default implementation of PerceptualAssociativeMemory. Module essentially concerned with PamNode and PamLinks, source of meaning in LIDA, how they are activated and how they pass activation among themselves.

Author:
Ryan J. McCall

Nested Class Summary
protected static class PerceptualAssociativeMemoryImpl.PamNodeStructure
          Internal implementation of NodeStructureImpl.
 
Field Summary
static LinkCategory FEATURE
          Primitive LinkCategory FEATURE
static LinkCategory LATERAL
          Primitive LinkCategory LATERAL
protected  java.util.Map<java.lang.String,PamNode> nodesByLabel
          Pam's pamnode indexed by label
static LinkCategory NONE
          Primitive LinkCategory NONE
protected  PerceptualAssociativeMemoryImpl.PamNodeStructure pamNodeStructure
          A PerceptualAssociativeMemoryImpl.PamNodeStructure which contains all of the PamNode, PamLink and their connections.
static LinkCategory PARENT
          Primitive LinkCategory PARENT
 
Fields inherited from class edu.memphis.ccrg.lida.framework.FrameworkModuleImpl
taskSpawner
 
Constructor Summary
PerceptualAssociativeMemoryImpl()
          Default constructor.
 
Method Summary
 PamLink addDefaultLink(Link link)
          Adds a COPY of specified link to this PAM.
 java.util.Set<PamLink> addDefaultLinks(java.util.Set<? extends Link> links)
          Adds a COPY of specified collection of PamLinks to this PAM.
 PamNode addDefaultNode(Node n)
          Adds a COPY of specified node to this PerceptualAssociativeMemory.
 java.util.Set<PamNode> addDefaultNodes(java.util.Set<? extends Node> nodes)
          Adds a COPY of a collection of Nodes to this PAM.
 void addDetectionAlgorithm(DetectionAlgorithm detector)
          Adds specified DetectionAlgorithm to be run.
 LinkCategory addLinkCategory(LinkCategory cat)
          Adds a COPY of specified LinkCategory to this PerceptualAssociativeMemory.
 void addLinkToPercept(Link l)
          Adds Link to the percept.
 void addListener(ModuleListener l)
          Override this method to add a listener to the module
 void addNodeStructureToPercept(NodeStructure ns)
          Adds a NodeStructure to the percept.
 void addNodeToPercept(Node n)
          Adds Node to the percept.
 void addPamListener(PamListener pl)
          Adds PamListener.
 boolean containsLink(ExtendedId id)
          Contains link.
 boolean containsLink(Link link)
          Returns true if this PAM contains specified PamLink.
 boolean containsNode(ExtendedId id)
          Contains node.
 boolean containsNode(Node node)
          Returns true if this PAM contains specified PamNode.
 void decayModule(long ticks)
          Decay only this Module.
 double getDownscaleFactor()
          Gets downscaleFactor
 int getExcitationTaskTicksPerRun()
           
 Link getLink(ExtendedId eid)
           
 java.util.Collection<LinkCategory> getLinkCategories()
          Returns all categories in this Pam
 LinkCategory getLinkCategory(int id)
          Returns LinkCategory with specified id.
 java.util.Collection<Link> getLinks()
          Returns an unmodifiable collection of the PamLinks in this PAM as Links.
 java.lang.Object getModuleContent(java.lang.Object... params)
          Intended to be called from the GUI.
 Node getNode(ExtendedId eid)
          Returns the PamNode with specified ExtendedId or null
 Node getNode(int id)
          Returns the PamNode with specified id from this PAM or null.
 Node getNode(java.lang.String label)
          Returns the PamNode with specified label or null.
 java.util.Collection<Node> getNodes()
          Returns an unmodifiable collection of the PamNodes in this PAM as Nodes.
static double getPerceptThreshold()
          Returns the perceptThreshold
 PropagationStrategy getPropagationStrategy()
          Gets PropagationStrategy governing how activation is propagated in this PAM.
 int getPropagationTaskTicksPerRun()
           
 double getUpscaleFactor()
          Gets upscaleFactor
 void init()
          Will set parameters with the following names:

pam.Upscale
pam.Downscale
pam.Selectivity
pam.excitationTicksPerRun
pam.propagationTicksPerRun
 boolean isOverPerceptThreshold(PamLinkable l)
          Returns whether PamLinkable is above percept threshold.
 void learn(BroadcastContent bc)
          This is a placeholder method to remind implementing classes that they should implement learning.
 void propagateActivationToParents(PamNode pn)
          Propagates activation from a PamNode to its parents.
 void receiveBroadcast(BroadcastContent bc)
          This method should return as possible in order to not delay the rest of the broadcasting.
 void receiveExcitation(PamLinkable pl, double amount)
          Excites specified PamLinkable an amount of activation.
 void receiveExcitation(java.util.Set<PamLinkable> linkables, double amount)
          Excites PamLinkable with an amount of activation.
 void receivePreafference(NodeStructure addList, NodeStructure deleteList)
          Listener receives preafference.
 void receiveWorkspaceContent(ModuleName originatingBuffer, WorkspaceContent content)
          Receive NodeStructure content from ModuleType originatingBuffer
 void setDownscaleFactor(double f)
          Sets downscaleFactor
 void setPerceptThreshold(double t)
          Sets perceptThreshold
 void setPropagationStrategy(PropagationStrategy b)
          Sets PropagationStrategy governing how activation is propagated in this PAM.
 void setUpscaleFactor(double f)
          Sets upscaleFactor
 
Methods inherited from class edu.memphis.ccrg.lida.framework.FrameworkModuleImpl
addSubModule, containsSubmodule, containsSubmodule, getAssistingTaskSpawner, getModuleName, getParam, getSubmodule, getSubmodule, getSubmodules, init, setAssistingTaskSpawner, setAssociatedModule, setModuleName, taskManagerDecayModule, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.memphis.ccrg.lida.framework.FrameworkModule
addSubModule, containsSubmodule, containsSubmodule, getAssistingTaskSpawner, getModuleName, getSubmodule, getSubmodule, getSubmodules, setAssistingTaskSpawner, setModuleName, taskManagerDecayModule
 
Methods inherited from interface edu.memphis.ccrg.lida.framework.initialization.FullyInitializable
setAssociatedModule
 
Methods inherited from interface edu.memphis.ccrg.lida.framework.initialization.Initializable
getParam, init
 

Field Detail

pamNodeStructure

protected PerceptualAssociativeMemoryImpl.PamNodeStructure pamNodeStructure
A PerceptualAssociativeMemoryImpl.PamNodeStructure which contains all of the PamNode, PamLink and their connections.


nodesByLabel

protected java.util.Map<java.lang.String,PamNode> nodesByLabel
Pam's pamnode indexed by label


NONE

public static LinkCategory NONE
Primitive LinkCategory NONE


LATERAL

public static LinkCategory LATERAL
Primitive LinkCategory LATERAL


PARENT

public static LinkCategory PARENT
Primitive LinkCategory PARENT


FEATURE

public static LinkCategory FEATURE
Primitive LinkCategory FEATURE

Constructor Detail

PerceptualAssociativeMemoryImpl

public PerceptualAssociativeMemoryImpl()
Default constructor.

Method Detail

init

public void init()
Will set parameters with the following names:

pam.Upscale
pam.Downscale
pam.Selectivity
pam.excitationTicksPerRun
pam.propagationTicksPerRun

Specified by:
init in interface Initializable
Overrides:
init in class FrameworkModuleImpl
See Also:
FrameworkModuleImpl.init()

setPropagationStrategy

public void setPropagationStrategy(PropagationStrategy b)
Description copied from interface: PerceptualAssociativeMemory
Sets PropagationStrategy governing how activation is propagated in this PAM.

Specified by:
setPropagationStrategy in interface PerceptualAssociativeMemory
Parameters:
b - PropagationStrategy

getPropagationStrategy

public PropagationStrategy getPropagationStrategy()
Description copied from interface: PerceptualAssociativeMemory
Gets PropagationStrategy governing how activation is propagated in this PAM.

Specified by:
getPropagationStrategy in interface PerceptualAssociativeMemory
Returns:
this Pam's PropagationStrategy

getExcitationTaskTicksPerRun

public int getExcitationTaskTicksPerRun()
Returns:
the excitationTaskTicksPerRun

getPropagationTaskTicksPerRun

public int getPropagationTaskTicksPerRun()
Returns:
the propagationTaskTicksPerRun

addDefaultNodes

public java.util.Set<PamNode> addDefaultNodes(java.util.Set<? extends Node> nodes)
Description copied from interface: PerceptualAssociativeMemory
Adds a COPY of a collection of Nodes to this PAM. Nodes will be of Pam's default type.

Specified by:
addDefaultNodes in interface PerceptualAssociativeMemory
Parameters:
nodes - nodes to add
Returns:
Copied PamNodes actually stored in this PAM

addDefaultNode

public PamNode addDefaultNode(Node n)
Description copied from interface: PerceptualAssociativeMemory
Adds a COPY of specified node to this PerceptualAssociativeMemory. Node will be of Pam's default type.

Specified by:
addDefaultNode in interface PerceptualAssociativeMemory
Parameters:
n - PamNode
Returns:
Copied PamNode actually stored in this PAM.

addDefaultLinks

public java.util.Set<PamLink> addDefaultLinks(java.util.Set<? extends Link> links)
Description copied from interface: PerceptualAssociativeMemory
Adds a COPY of specified collection of PamLinks to this PAM. Links will be of Pam's default type.

Specified by:
addDefaultLinks in interface PerceptualAssociativeMemory
Parameters:
links - PamLinks to add
Returns:
Copied PamLinks actually stored in this PAM

addDefaultLink

public PamLink addDefaultLink(Link link)
Description copied from interface: PerceptualAssociativeMemory
Adds a COPY of specified link to this PAM. Link will be of Pam's default type.

Specified by:
addDefaultLink in interface PerceptualAssociativeMemory
Parameters:
link - PamLink to add
Returns:
Copied PamLink actually stored in this PAM

addDetectionAlgorithm

public void addDetectionAlgorithm(DetectionAlgorithm detector)
Description copied from interface: PerceptualAssociativeMemory
Adds specified DetectionAlgorithm to be run.

Specified by:
addDetectionAlgorithm in interface PerceptualAssociativeMemory
Parameters:
detector - DetectionAlgorithm

addPamListener

public void addPamListener(PamListener pl)
Description copied from interface: PerceptualAssociativeMemory
Adds PamListener.

Specified by:
addPamListener in interface PerceptualAssociativeMemory
Parameters:
pl - listener

receiveBroadcast

public void receiveBroadcast(BroadcastContent bc)
Description copied from interface: BroadcastListener
This method should return as possible in order to not delay the rest of the broadcasting. A good implementation should copy the broadcast content and create a task to process it.

Specified by:
receiveBroadcast in interface BroadcastListener
Parameters:
bc - the Content of the Broadcast

receiveWorkspaceContent

public void receiveWorkspaceContent(ModuleName originatingBuffer,
                                    WorkspaceContent content)
Description copied from interface: WorkspaceListener
Receive NodeStructure content from ModuleType originatingBuffer

Specified by:
receiveWorkspaceContent in interface WorkspaceListener
Parameters:
originatingBuffer - source of content
content - sent content

receivePreafference

public void receivePreafference(NodeStructure addList,
                                NodeStructure deleteList)
Description copied from interface: PreafferenceListener
Listener receives preafference.

Specified by:
receivePreafference in interface PreafferenceListener
Parameters:
addList - expected additions in future percepts
deleteList - expected deletions in future percepts

learn

public void learn(BroadcastContent bc)
Description copied from interface: BroadcastListener
This is a placeholder method to remind implementing classes that they should implement learning. LIDA theory says receivers of the broadcast should learn from it. This method will not be called directly by GlobalWorkspace but should be managed by the receiving module.

Specified by:
learn in interface BroadcastListener
Parameters:
bc - content

decayModule

public void decayModule(long ticks)
Description copied from interface: FrameworkModule
Decay only this Module.

Specified by:
decayModule in interface FrameworkModule
Parameters:
ticks - number of ticks to decay.

receiveExcitation

public void receiveExcitation(PamLinkable pl,
                              double amount)
Description copied from interface: PerceptualAssociativeMemory
Excites specified PamLinkable an amount of activation.

Specified by:
receiveExcitation in interface PerceptualAssociativeMemory
Parameters:
pl - Id of the PamLinkable receiving the activation
amount - amount of activation to excite
See Also:
{@link BasicDetectionAlgorithm}

receiveExcitation

public void receiveExcitation(java.util.Set<PamLinkable> linkables,
                              double amount)
Description copied from interface: PerceptualAssociativeMemory
Excites PamLinkable with an amount of activation.

Specified by:
receiveExcitation in interface PerceptualAssociativeMemory
Parameters:
linkables - Ids of PamLinkable to be excited
amount - amount of activation

propagateActivationToParents

public void propagateActivationToParents(PamNode pn)
Description copied from interface: PerceptualAssociativeMemory
Propagates activation from a PamNode to its parents.

Specified by:
propagateActivationToParents in interface PerceptualAssociativeMemory
Parameters:
pn - The PamNode to propagate activation from.
See Also:
ExcitationTask, PropagationTask

addNodeStructureToPercept

public void addNodeStructureToPercept(NodeStructure ns)
Description copied from interface: PerceptualAssociativeMemory
Adds a NodeStructure to the percept.

Specified by:
addNodeStructureToPercept in interface PerceptualAssociativeMemory
Parameters:
ns - NodeStructure

addLinkToPercept

public void addLinkToPercept(Link l)
Description copied from interface: PerceptualAssociativeMemory
Adds Link to the percept.

Specified by:
addLinkToPercept in interface PerceptualAssociativeMemory
Parameters:
l - Link to add

addNodeToPercept

public void addNodeToPercept(Node n)
Description copied from interface: PerceptualAssociativeMemory
Adds Node to the percept.

Specified by:
addNodeToPercept in interface PerceptualAssociativeMemory
Parameters:
n - Node to add

containsNode

public boolean containsNode(Node node)
Description copied from interface: PerceptualAssociativeMemory
Returns true if this PAM contains specified PamNode.

Specified by:
containsNode in interface PerceptualAssociativeMemory
Parameters:
node - the node
Returns:
true, if successful

containsNode

public boolean containsNode(ExtendedId id)
Description copied from interface: PerceptualAssociativeMemory
Contains node.

Specified by:
containsNode in interface PerceptualAssociativeMemory
Parameters:
id - ExtendedId of sought node
Returns:
true if PAM contains the node with this id.

containsLink

public boolean containsLink(Link link)
Description copied from interface: PerceptualAssociativeMemory
Returns true if this PAM contains specified PamLink.

Specified by:
containsLink in interface PerceptualAssociativeMemory
Parameters:
link - the link
Returns:
true, if successful

containsLink

public boolean containsLink(ExtendedId id)
Description copied from interface: PerceptualAssociativeMemory
Contains link.

Specified by:
containsLink in interface PerceptualAssociativeMemory
Parameters:
id - ExtendedId of sought link
Returns:
true if PAM contains the link with this id.

getNodes

public java.util.Collection<Node> getNodes()
Description copied from interface: PerceptualAssociativeMemory
Returns an unmodifiable collection of the PamNodes in this PAM as Nodes.

Specified by:
getNodes in interface PerceptualAssociativeMemory
Returns:
the PamNodes of this PAM

getLinks

public java.util.Collection<Link> getLinks()
Description copied from interface: PerceptualAssociativeMemory
Returns an unmodifiable collection of the PamLinks in this PAM as Links.

Specified by:
getLinks in interface PerceptualAssociativeMemory
Returns:
the PamLink of this PAM

getModuleContent

public java.lang.Object getModuleContent(java.lang.Object... params)
Description copied from class: FrameworkModuleImpl
Intended to be called from the GUI. Override this method to return particular module content based on params.

Specified by:
getModuleContent in interface FrameworkModule
Overrides:
getModuleContent in class FrameworkModuleImpl
Parameters:
params - - specifies what content will be returned.
Returns:
various kinds of content of this module.

addListener

public void addListener(ModuleListener l)
Description copied from class: FrameworkModuleImpl
Override this method to add a listener to the module

Specified by:
addListener in interface FrameworkModule
Overrides:
addListener in class FrameworkModuleImpl
Parameters:
l - - listener of this FrameworkModule

getPerceptThreshold

public static double getPerceptThreshold()
Returns the perceptThreshold

Returns:
threshold for a PamLinkable to be instantiated into a percept

setPerceptThreshold

public void setPerceptThreshold(double t)
Description copied from interface: PerceptualAssociativeMemory
Sets perceptThreshold

Specified by:
setPerceptThreshold in interface PerceptualAssociativeMemory
Parameters:
t - threshold for a Linkable to become part of the percept

isOverPerceptThreshold

public boolean isOverPerceptThreshold(PamLinkable l)
Description copied from interface: PerceptualAssociativeMemory
Returns whether PamLinkable is above percept threshold.

Specified by:
isOverPerceptThreshold in interface PerceptualAssociativeMemory
Parameters:
l - a PamLinkable
Returns:
true if PamLinkable's total activation is above percept threshold

getUpscaleFactor

public double getUpscaleFactor()
Description copied from interface: PerceptualAssociativeMemory
Gets upscaleFactor

Specified by:
getUpscaleFactor in interface PerceptualAssociativeMemory
Returns:
scale factor for feed-forward activation propagation

setUpscaleFactor

public void setUpscaleFactor(double f)
Description copied from interface: PerceptualAssociativeMemory
Sets upscaleFactor

Specified by:
setUpscaleFactor in interface PerceptualAssociativeMemory
Parameters:
f - scale factor for feed-forward activation propagation

getDownscaleFactor

public double getDownscaleFactor()
Description copied from interface: PerceptualAssociativeMemory
Gets downscaleFactor

Specified by:
getDownscaleFactor in interface PerceptualAssociativeMemory
Returns:
scale factor for top-down activation propagation

setDownscaleFactor

public void setDownscaleFactor(double f)
Description copied from interface: PerceptualAssociativeMemory
Sets downscaleFactor

Specified by:
setDownscaleFactor in interface PerceptualAssociativeMemory
Parameters:
f - scale factor for top-down activation propagation

getLink

public Link getLink(ExtendedId eid)
Specified by:
getLink in interface PerceptualAssociativeMemory
Parameters:
eid - link's eid
Returns:
the PamLink with specified id from this PAM or null.

getNode

public Node getNode(ExtendedId eid)
Description copied from interface: PerceptualAssociativeMemory
Returns the PamNode with specified ExtendedId or null

Specified by:
getNode in interface PerceptualAssociativeMemory
Parameters:
eid - sought ExtendedId
Returns:
PamNode the actual Node

getNode

public Node getNode(int id)
Description copied from interface: PerceptualAssociativeMemory
Returns the PamNode with specified id from this PAM or null.

Specified by:
getNode in interface PerceptualAssociativeMemory
Parameters:
id - the id
Returns:
the pam node

getLinkCategories

public java.util.Collection<LinkCategory> getLinkCategories()
Description copied from interface: PerceptualAssociativeMemory
Returns all categories in this Pam

Specified by:
getLinkCategories in interface PerceptualAssociativeMemory
Returns:
Collection of all LinkCategory

getLinkCategory

public LinkCategory getLinkCategory(int id)
Description copied from interface: PerceptualAssociativeMemory
Returns LinkCategory with specified id.

Specified by:
getLinkCategory in interface PerceptualAssociativeMemory
Parameters:
id - id of LinkCategory sought
Returns:
LinkCategory or null if category does not exist in PAM.

addLinkCategory

public LinkCategory addLinkCategory(LinkCategory cat)
Description copied from interface: PerceptualAssociativeMemory
Adds a COPY of specified LinkCategory to this PerceptualAssociativeMemory. Category must also be a node in order to be added. Node will be of Pam's default type.

Specified by:
addLinkCategory in interface PerceptualAssociativeMemory
Parameters:
cat - LinkCategory
Returns:
Copied LinkCategory actually stored in this PAM.

getNode

public Node getNode(java.lang.String label)
Description copied from interface: PerceptualAssociativeMemory
Returns the PamNode with specified label or null. This method is intended to be used only during initialization.

Specified by:
getNode in interface PerceptualAssociativeMemory
Parameters:
label - sought
Returns:
PamNode the actual Node