clarion.system
Class WorkingMemory

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<T>
                  extended by clarion.system.AbstractIntermediateModule<AbstractChunk>
                      extended by clarion.system.WorkingMemory
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<AbstractChunk>, java.util.Collection<AbstractChunk>, java.util.List<AbstractChunk>, java.util.Queue<AbstractChunk>

public class WorkingMemory
extends AbstractIntermediateModule<AbstractChunk>

This class implements the working memory within CLARION. It extends the AbstractIntermediateModule class. Conceptually, this system exists between the ACS and the NACS. However, implementationally it is logical to specify it as an intermediate module since it is used by several subsystems. Therefore, in the CLARION Library, the working memory is contained within the CLARION class.

Usage:

This class contains methods for adding and removing items from the working memory. The working memory is used primarily by the ACS, but it can be used to facilitate interactions between the ACS and the NACS.

Working memory can contain specialized chunks that only exist within working memory. Example of such a chunk include the "carry over" digit in addition or the "borrow" digit in subtraction. Unlike a goal, the dimensions of a working memory chunk can have the same IDs the dimensions in the sensory information space. This equates to "remembering" or "visualizing" something within the sensory information space and recalling it for later use.

Currently this is simply a container for the working memory slots. Any manipulations on the chunks in working memory must be manually specified.

It is EXTREMELY important that you only manipulate the working memory using the add and remove methods that have been overridden by this class.

This class contains both global (static) and local constants. The default is to use the local constants. If you want to change any of the global constants, you need to do so before any instances of this class are initialized.

Version:
6.0.4
Author:
Nick Wilson
See Also:
Serialized Form

Field Summary
static int GLOBAL_WORKING_MEMORY_CAPACITY
          The number of slots in working memory.
private static long serialVersionUID
           
private  SpecializedWMChunkCollection SpecializedWMChunks
          Specialized chunks specific only to working memory.
 int WORKING_MEMORY_CAPACITY
          The number of slots in working memory.
 
Fields inherited from class clarion.system.AbstractIntermediateModule
InputSpace
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
WorkingMemory(CLARION Agent)
          Initializes the working memory.
 
Method Summary
 boolean add(AbstractChunk C)
          Adds a chunk to working memory.
 boolean addAll(java.util.Collection<? extends AbstractChunk> C)
          Adds a collection of chunks to working memory.
 boolean addSpecializedWMChunk(AbstractChunk C)
          Adds a working memory chunk to the list of specialized working memory chunks.
 boolean addSpecializedWMChunks(java.util.Collection<AbstractChunk> Chunks)
          Adds a collection of specialized working memory chunks to the list of specialized working memory chunks.
protected  void attachSelfToAgent(CLARION Agent)
          Attaches the working memory to the specified CLARION agent.
 AbstractChunk get(java.lang.Object ID)
          Gets the chunk from working memory with the specified ID.
 int getNumSpecializedWMChunks()
          Gets the number of specialized working memory chunks.
 AbstractChunk getSpecializedWMChunk(int Index)
          Gets the chunk from the specialized working memory chunk list at the specified Index.
 AbstractChunk getSpecializedWMChunk(java.lang.Object ID)
          Gets the chunk from the specialized working memory chunk list with the specified ID.
 java.util.Collection<AbstractChunk> getSpecializedWMChunks()
          Gets a collection of the specialized working memory chunks.
 AbstractChunk remove(int Index)
          Removes a chunk from working memory.
 boolean remove(java.lang.Object C)
          Removes the specified chunk object from working memory.
 
Methods inherited from class clarion.system.AbstractIntermediateModule
updateInputSpace
 
Methods inherited from class java.util.LinkedList
add, addAll, addFirst, addLast, clear, clone, contains, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, peek, poll, remove, removeFirst, removeLast, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

GLOBAL_WORKING_MEMORY_CAPACITY

public static int GLOBAL_WORKING_MEMORY_CAPACITY
The number of slots in working memory.


WORKING_MEMORY_CAPACITY

public int WORKING_MEMORY_CAPACITY
The number of slots in working memory.


SpecializedWMChunks

private SpecializedWMChunkCollection SpecializedWMChunks
Specialized chunks specific only to working memory.

Constructor Detail

WorkingMemory

public WorkingMemory(CLARION Agent)
Initializes the working memory. During initialization this instance of the working memory will attach itself to the CLARION agent you specify.

Parameters:
Agent - The agent to which the working memory is being attached.
Method Detail

add

public boolean add(AbstractChunk C)
            throws FullContainerException,
                   java.lang.IllegalArgumentException
Adds a chunk to working memory. If you are trying to add a chunk to working memory that has dimension-value pairs that do not exist in CLARION's internal input space or the working memory is full, this method will throw an exception.

If you want to add a new specialized working memory chunk to the list of specialized working memory chunks, call the addSpecializedWMChunk method.

Specified by:
add in interface java.util.Collection<AbstractChunk>
Specified by:
add in interface java.util.List<AbstractChunk>
Overrides:
add in class java.util.LinkedList<AbstractChunk>
Parameters:
C - The chunk to add.
Returns:
True only if the chunk was successfully added.
Throws:
FullContainerException - If working memory is full.
java.lang.IllegalArgumentException - If the input space does not contain all of the dimension-value pairs specified in the chunk.

addAll

public boolean addAll(java.util.Collection<? extends AbstractChunk> C)
Adds a collection of chunks to working memory.

Specified by:
addAll in interface java.util.Collection<AbstractChunk>
Specified by:
addAll in interface java.util.List<AbstractChunk>
Overrides:
addAll in class java.util.LinkedList<AbstractChunk>
Parameters:
C - The chunks to add.
Returns:
True only if the chunks were successfully added.

remove

public AbstractChunk remove(int Index)
Removes a chunk from working memory.

Specified by:
remove in interface java.util.List<AbstractChunk>
Overrides:
remove in class java.util.LinkedList<AbstractChunk>
Parameters:
Index - The index of the chunk to remove.
Returns:
The removed chunk.

remove

public boolean remove(java.lang.Object C)
Removes the specified chunk object from working memory.

Specified by:
remove in interface java.util.Collection<AbstractChunk>
Specified by:
remove in interface java.util.List<AbstractChunk>
Overrides:
remove in class java.util.LinkedList<AbstractChunk>
Parameters:
C - The chunk to remove.
Returns:
True if the chunk was successfully removed.

get

public AbstractChunk get(java.lang.Object ID)
Gets the chunk from working memory with the specified ID. If none of the working memory chunks have the specified ID, this method returns null.

Parameters:
ID - The ID of the chunk to get from the list of specialized working memory chunks.
Returns:
The chunk.

getNumSpecializedWMChunks

public int getNumSpecializedWMChunks()
Gets the number of specialized working memory chunks.

Returns:
The number of specialized working memory chunks.

getSpecializedWMChunk

public AbstractChunk getSpecializedWMChunk(java.lang.Object ID)
Gets the chunk from the specialized working memory chunk list with the specified ID. If none of the specialized working memory chunks have the specified ID or the working memory does not contain any specialized working memory chunks, this method returns null.

This does NOT return a chunk from working memory. To get a chunk from working memory, call the get method.

Parameters:
ID - The ID of the chunk to get from the list of specialized working memory chunks.
Returns:
The chunk.

getSpecializedWMChunk

public AbstractChunk getSpecializedWMChunk(int Index)
Gets the chunk from the specialized working memory chunk list at the specified Index. If the working memory does not contain any specialized working memory chunks, this method returns null.

This does NOT return a chunk from working memory. To get a chunk from working memory, call the get method.

Parameters:
Index - The index of the chunk to get from the list of specialized working memory chunks.
Returns:
The chunk.

getSpecializedWMChunks

public java.util.Collection<AbstractChunk> getSpecializedWMChunks()
Gets a collection of the specialized working memory chunks. The collection returned is unmodifiable and is meant for reporting the internal state only. If the working memory does not contain any specialized working memory chunks, this method returns null.

Returns:
An unmodifiable collection of specialized working memory chunks.

addSpecializedWMChunk

public boolean addSpecializedWMChunk(AbstractChunk C)
Adds a working memory chunk to the list of specialized working memory chunks. If the chunk is already in the list of specialized working memory chunks, it will not be added.

Remember that the input layer of an implicit module or the condition of a rule in the ACS must contain nodes for all dimension-value pairs contained within any of the specialized working memory chunks you wish to have as input into the implicit module or rule condition.

This does NOT add a chunk to working memory. To add a chunk to working memory, call the add method.

Parameters:
C - The specialized working memory chunk to add.
Returns:
True if the chunk was successfully added.

addSpecializedWMChunks

public boolean addSpecializedWMChunks(java.util.Collection<AbstractChunk> Chunks)
Adds a collection of specialized working memory chunks to the list of specialized working memory chunks. If a chunk from the collection is already in the list of specialized working memory chunks, it will not be added.

Remember that the input layer of an implicit module or the condition of a rule in the ACS must contain nodes for all dimension-value pairs contained within any of the specialized working memory chunks you wish to have as input into the implicit module or rule condition.

This does NOT add a collection of chunks to working memory. To add a collection of chunks to working memory, call the addAll method.

Parameters:
Chunks - The collection of specialized working memory chunks to add.
Returns:
True if any of the specialized working memory chunks were successfully added.

attachSelfToAgent

protected void attachSelfToAgent(CLARION Agent)
Attaches the working memory to the specified CLARION agent.

Specified by:
attachSelfToAgent in class AbstractIntermediateModule<AbstractChunk>
Parameters:
Agent - The agent to wish this working memory will be attached.