edu.memphis.ccrg.lida.pam
Class PerceptualAssociativeMemoryImpl

java.lang.Object
  extended by edu.memphis.ccrg.lida.framework.initialization.InitializableImpl
      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
          All PamNode objects currently in PerceptualAssociativeMemoryImpl indexed by their 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)
          Deprecated. 
 PamLink addDefaultLink(Node src, Linkable snk, LinkCategory cat)
          Adds a new PamLink of default type to PAM.
 java.util.Set<PamLink> addDefaultLinks(java.util.Set<? extends Link> links)
          Deprecated. 
 PamNode addDefaultNode(Node n)
          Deprecated. 
 PamNode addDefaultNode(java.lang.String label)
          Adds a new PamNode of default type to PAM with specified label.
 java.util.Set<PamNode> addDefaultNodes(java.util.Set<? extends Node> nodes)
          Deprecated. 
 void addDetectionAlgorithm(DetectionAlgorithm detector)
          Adds specified DetectionAlgorithm to be run.
 PamLink addLink(java.lang.String type, Node src, Linkable snk, LinkCategory cat)
          Adds a new PamLink of specified type to PAM.
 LinkCategory addLinkCategory(LinkCategory cat)
          Adds a COPY of specified LinkCategory to this PerceptualAssociativeMemory.
 void addListener(ModuleListener l)
          Override this method to add a listener to the module
 PamNode addNode(java.lang.String type, java.lang.String label)
          Adds a new PamNode of specified type to PAM with specified label.
 void addPamListener(PamListener pl)
          Adds PamListener.
 void addToPercept(Link l)
          Adds Link to the percept.
 void addToPercept(Node n)
          Adds Node to the percept.
 void addToPercept(NodeStructure ns)
          Adds a NodeStructure to the percept.
 boolean containsLink(ExtendedId id)
          Contains link.
 boolean containsLink(Link l)
          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 the scaling on the amount of activation passed upwards from Nodes of lower conceptual depth to those of higher depth
pam.downscale the scaling on the amount of activation passed downwards from Nodes of higher conceptual depth to those of lower depth
pam.perceptThreshold the amount of activation a Node or Link must have to be part of the percept (be sent to the Workspace)
pam.excitationTicksPerRun the delay (in ticks) on the excitation of Nodes and Links after they receive some activation, default is 1 tick
pam.propagationTicksPerRun the delay (in ticks) on the propagation of activation from a Node or Link, default is 1 tick
pam.propagateActivationThreshold the amount of activation necessary to be propagated i.e.
 boolean isOverPerceptThreshold(PamLinkable l)
          Returns whether PamLinkable is above percept threshold.
 void learn(Coalition coalition)
          A place-holder method to remind implementing classes that they should implement learning.
 void propagateActivationToParents(PamNode pn)
          Propagates activation from a PamNode to its parents.
 void receiveBroadcast(Coalition coalition)
          Listener must receive a broadcast of a the winning Coalition 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, getSubmodule, getSubmodule, getSubmodules, setAssistingTaskSpawner, setAssociatedModule, setModuleName, taskManagerDecayModule, toString
 
Methods inherited from class edu.memphis.ccrg.lida.framework.initialization.InitializableImpl
containsParameter, getParam, getParameters, init
 
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
containsParameter, getParam, getParameters, 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
All PamNode objects currently in PerceptualAssociativeMemoryImpl indexed by their 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 the scaling on the amount of activation passed upwards from Nodes of lower conceptual depth to those of higher depth
pam.downscale the scaling on the amount of activation passed downwards from Nodes of higher conceptual depth to those of lower depth
pam.perceptThreshold the amount of activation a Node or Link must have to be part of the percept (be sent to the Workspace)
pam.excitationTicksPerRun the delay (in ticks) on the excitation of Nodes and Links after they receive some activation, default is 1 tick
pam.propagationTicksPerRun the delay (in ticks) on the propagation of activation from a Node or Link, default is 1 tick
pam.propagateActivationThreshold the amount of activation necessary to be propagated i.e. a lesser amount is not (worth being) passed

Specified by:
init in interface Initializable
Overrides:
init in class InitializableImpl
See Also:
Initializable

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

@Deprecated
public java.util.Set<PamNode> addDefaultNodes(java.util.Set<? extends Node> nodes)
Deprecated. 

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

@Deprecated
public PamNode addDefaultNode(Node n)
Deprecated. 

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

@Deprecated
public java.util.Set<PamLink> addDefaultLinks(java.util.Set<? extends Link> links)
Deprecated. 

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

@Deprecated
public PamLink addDefaultLink(Link link)
Deprecated. 

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

addDefaultNode

public PamNode addDefaultNode(java.lang.String label)
Description copied from interface: PerceptualAssociativeMemory
Adds a new PamNode of default type to PAM with specified label. Label must be unique. If not, existing node with specified label is returned.

Specified by:
addDefaultNode in interface PerceptualAssociativeMemory
Parameters:
label - the label of the new PamNode
Returns:
the new PamNode added to PAM, the existing Node with specified label or null

addNode

public PamNode addNode(java.lang.String type,
                       java.lang.String label)
Description copied from interface: PerceptualAssociativeMemory
Adds a new PamNode of specified type to PAM with specified label. Type should refer to a subclass of PamNodeImpl. Label must be unique. If not, existing node with specified label is returned.

Specified by:
addNode in interface PerceptualAssociativeMemory
Parameters:
type - the type of the new PamNode
label - the label of the new PamNode
Returns:
the new PamNode added to PAM, the existing Node with specified label or null

addDefaultLink

public PamLink addDefaultLink(Node src,
                              Linkable snk,
                              LinkCategory cat)
Description copied from interface: PerceptualAssociativeMemory
Adds a new PamLink of default type to PAM. If a link with the same attributes already exists the existing link will be returned instead.

Specified by:
addDefaultLink in interface PerceptualAssociativeMemory
Parameters:
src - the link's source
snk - the link's sink
cat - the link's category
Returns:
the new PamLink, the existing PamLink, or null

addLink

public PamLink addLink(java.lang.String type,
                       Node src,
                       Linkable snk,
                       LinkCategory cat)
Description copied from interface: PerceptualAssociativeMemory
Adds a new PamLink of specified type to PAM. Type should refer to a subclass of PamLinkImpl. If a link with the same attributes already exists the existing link will be returned instead.

Specified by:
addLink in interface PerceptualAssociativeMemory
Parameters:
type - link's type
src - the link's source
snk - the link's sink
cat - the link's category
Returns:
the new PamLink, the existing PamLink, or null

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(Coalition coalition)
Description copied from interface: BroadcastListener
Listener must receive a broadcast of a the winning Coalition This method should return as possible in order to not delay the rest of the broadcasting.

Specified by:
receiveBroadcast in interface BroadcastListener
Parameters:
coalition - the Coalition that won the most recent competition for consciousness

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(Coalition coalition)
Description copied from interface: BroadcastListener
A place-holder 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 the GlobalWorkspace and thus it should be managed by the receiving module.

Specified by:
learn in interface BroadcastListener
Parameters:
coalition - the Coalition that won the most recent competition for consciousness

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

addToPercept

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

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

addToPercept

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

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

addToPercept

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

Specified by:
addToPercept 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 l)
Description copied from interface: PerceptualAssociativeMemory
Returns true if this PAM contains specified PamLink.

Specified by:
containsLink in interface PerceptualAssociativeMemory
Parameters:
l - 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 - parameters specifying what content will be returned
Returns:
Parameter-specified 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