edu.memphis.ccrg.lida.proceduralmemory
Class ProceduralMemoryImpl

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.proceduralmemory.ProceduralMemoryImpl
All Implemented Interfaces:
FrameworkModule, FullyInitializable, Initializable, ModuleListener, BroadcastListener, ProceduralMemory

public class ProceduralMemoryImpl
extends FrameworkModuleImpl
implements ProceduralMemory, BroadcastListener

Default implementation of ProceduralMemory. Indexes scheme by context elements for quick access. Assumes that the Condition of Scheme are Node only.

Author:
Ryan J. McCall, Javier Snaider

Nested Class Summary
static class ProceduralMemoryImpl.ConditionType
          The possible type of usage for a condition inside a Scheme
protected  class ProceduralMemoryImpl.InternalNodeStructure
          Allows Nodes to be added without copying.
 
Field Summary
 
Fields inherited from class edu.memphis.ccrg.lida.framework.FrameworkModuleImpl
taskSpawner
 
Constructor Summary
ProceduralMemoryImpl()
           
 
Method Summary
 void activateSchemes()
          Using the broadcast, activate the relevant schemes of ProceduralMemory
(package private)  Condition addCondition(Condition c)
          Add Condition c to the condition pool if it is not already stored.
 void addListener(ModuleListener l)
          Override this method to add a listener to the module
 boolean containsScheme(Scheme s)
          Returns whether this procedural memory contains specified scheme.
 Behavior createInstantiation(Scheme s)
          Instantiates specified Scheme .
 void decayModule(long ticks)
          Decay only this Module.
 NodeStructure getBroadcastBuffer()
          Gets the broadcast buffer.
 java.util.Collection<Condition> getConditionPool()
          Gets the condition pool.
 java.lang.Object getModuleContent(java.lang.Object... params)
          Intended to be called from the GUI.
 Scheme getNewScheme(Action a)
          Gets a new Scheme having specified Action.
 int getSchemeCount()
          Returns a count of the schemes
 java.util.Collection<Scheme> getSchemes()
          Returns a view of all Scheme objects currently in the ProceduralMemory.
(package private)  void indexScheme(Scheme s, Condition c, ProceduralMemoryImpl.ConditionType type)
          Add a reference to specified Scheme from specified condition.
 void init()
          This module can initialize the following parameters:

proceduralMemory.schemeSelectionThreshold type=double amount of activation schemes must have to be instantiated, default is 0.0
proceduralMemory.contextWeight type=double The weight of context conditions for the calculation of scheme activation.
 void learn(Coalition coalition)
          A place-holder method to remind implementing classes that they should implement learning.
 void receiveBroadcast(Coalition coal)
          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 removeScheme(Scheme s)
          Removes specified Scheme.
 boolean shouldInstantiate(Scheme s, NodeStructure broadcastBuffer)
          Returns true if the specified scheme's total activation is greater than the scheme selection threshold.
 
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
 

Constructor Detail

ProceduralMemoryImpl

public ProceduralMemoryImpl()
Method Detail

init

public void init()
This module can initialize the following parameters:

proceduralMemory.schemeSelectionThreshold type=double amount of activation schemes must have to be instantiated, default is 0.0
proceduralMemory.contextWeight type=double The weight of context conditions for the calculation of scheme activation. Should be positive
proceduralMemory.addingListWeight type=double The weight of adding list conditions for the calculation of scheme activation. Should be positive
proceduralMemory.conditionDecayStrategy type=string The DecayStrategy used by all conditions in the condition pool (and broadcast buffer).
proceduralMemory.schemeClass type=string qualified name of the Scheme class used by this module

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

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

getNewScheme

public Scheme getNewScheme(Action a)
Description copied from interface: ProceduralMemory
Gets a new Scheme having specified Action.

Specified by:
getNewScheme in interface ProceduralMemory
Parameters:
a - an Action
Returns:
a new Scheme with Action a

addCondition

Condition addCondition(Condition c)
Add Condition c to the condition pool if it is not already stored.
Returns the stored condition with same id as c.
This method is intended to be used only by SchemeImpl to ensure that all schemes in the ProceduralMemory share the same condition instances.

Parameters:
c - the condition to add to the condition pool.
Returns:
c or the stored condition with same id as c

indexScheme

void indexScheme(Scheme s,
                 Condition c,
                 ProceduralMemoryImpl.ConditionType type)
Add a reference to specified Scheme from specified condition. Thus the presence of Condition c in the broadcast buffer will tend to activate s. The specified scheme should be one that will have c in its conditions (e.g. in the Context or adding list) Indexes Scheme s by Condition c of ConditionType type.

Parameters:
s - the Scheme to index
c - the condition
type - the type of the condition. This select the indexing map

receiveBroadcast

public void receiveBroadcast(Coalition coal)
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:
coal - the Coalition that won the most recent competition for consciousness

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

activateSchemes

public void activateSchemes()
Description copied from interface: ProceduralMemory
Using the broadcast, activate the relevant schemes of ProceduralMemory

Specified by:
activateSchemes in interface ProceduralMemory

shouldInstantiate

public boolean shouldInstantiate(Scheme s,
                                 NodeStructure broadcastBuffer)
Returns true if the specified scheme's total activation is greater than the scheme selection threshold.
The threshold can be set in the init() method.

Specified by:
shouldInstantiate in interface ProceduralMemory
Parameters:
s - the Scheme to be checked
broadcastBuffer - the NodeStructure in ProceduralMemory containing recent broadcast
Returns:
true if the Scheme should be instantiated, false otherwise.

createInstantiation

public Behavior createInstantiation(Scheme s)
Description copied from interface: ProceduralMemory
Instantiates specified Scheme .

Specified by:
createInstantiation in interface ProceduralMemory
Parameters:
s - a Scheme over instantiation threshold
Returns:
a Behavior, an instantiation of Scheme s

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.

removeScheme

public void removeScheme(Scheme s)
Description copied from interface: ProceduralMemory
Removes specified Scheme.

Specified by:
removeScheme in interface ProceduralMemory
Parameters:
s - scheme to be removed.

containsScheme

public boolean containsScheme(Scheme s)
Description copied from interface: ProceduralMemory
Returns whether this procedural memory contains specified scheme.

Specified by:
containsScheme in interface ProceduralMemory
Parameters:
s - a Scheme
Returns:
true if it contains an equal scheme

getSchemeCount

public int getSchemeCount()
Description copied from interface: ProceduralMemory
Returns a count of the schemes

Specified by:
getSchemeCount in interface ProceduralMemory
Returns:
number of schemes currently in this procedural memory.

getSchemes

public java.util.Collection<Scheme> getSchemes()
Description copied from interface: ProceduralMemory
Returns a view of all Scheme objects currently in the ProceduralMemory.

Specified by:
getSchemes in interface ProceduralMemory
Returns:
a Collection of schemes

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.

getConditionPool

public java.util.Collection<Condition> getConditionPool()
Gets the condition pool. Method intended for testing only.

Returns:
an UnmodifiableCollection of the condition in the pool

getBroadcastBuffer

public NodeStructure getBroadcastBuffer()
Gets the broadcast buffer. Method intended for testing only.

Returns:
an NodeStructure containing recent broadcasts