edu.memphis.ccrg.lida.episodicmemory.sdm
Class SparseDistributedMemoryImpl

java.lang.Object
  extended by edu.memphis.ccrg.lida.episodicmemory.sdm.SparseDistributedMemoryImpl
All Implemented Interfaces:
SparseDistributedMemory

public class SparseDistributedMemoryImpl
extends java.lang.Object
implements SparseDistributedMemory

Implementation of Kanerva's sparse distributed memory. This implementation is based on the model described in P. Kanerva, "Sparse Distributed Memory and Related Models" in Associative Neural Memories: Theory and Implementation , pp. 50-76, Oxford University Press, 1993.

Author:
Javier Snaider, Ryan J. McCall

Constructor Summary
SparseDistributedMemoryImpl(int memorySize, int radius, int wordLength)
          Constructs a new SparseDistributedMemory with equal address and word sizes
SparseDistributedMemoryImpl(int memorySize, int radius, int wordLength, int addrLength)
          Constructs a new SparseDistributedMemory with specified parameters
 
Method Summary
 void mappedStore(cern.colt.bitvector.BitVector wrd, cern.colt.bitvector.BitVector mapping)
          Stores word in this sparse distributed memory using the word as address.
 cern.colt.bitvector.BitVector retrieve(cern.colt.bitvector.BitVector addr)
          Retrieves the contents of this sparse distributed memory at the given address.
 cern.colt.bitvector.BitVector retrieve(cern.colt.bitvector.BitVector addr, cern.colt.bitvector.BitVector mapping)
          Retrieves the contents of this SDM at specified address.
 cern.colt.bitvector.BitVector retrieveIterating(cern.colt.bitvector.BitVector addr)
          Retrieves the contents of this sparse distributed memory at the given address iterating this process until result is equal to the address.
 cern.colt.bitvector.BitVector retrieveIterating(cern.colt.bitvector.BitVector addr, cern.colt.bitvector.BitVector mapping)
          Retrieves the contents of this SDM at specified address.
 void store(cern.colt.bitvector.BitVector wrd)
          Stores word in this sparse distributed memory using the word as address.
 void store(cern.colt.bitvector.BitVector wrd, cern.colt.bitvector.BitVector addr)
          Stores word in the given address in this sparse distributed memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseDistributedMemoryImpl

public SparseDistributedMemoryImpl(int memorySize,
                                   int radius,
                                   int wordLength)
Constructs a new SparseDistributedMemory with equal address and word sizes

Parameters:
memorySize - number of hard locations
radius - the activation radius used to find the nearest hard locations
wordLength - the word size and the address size

SparseDistributedMemoryImpl

public SparseDistributedMemoryImpl(int memorySize,
                                   int radius,
                                   int wordLength,
                                   int addrLength)
Constructs a new SparseDistributedMemory with specified parameters

Parameters:
memorySize - the number of hard location
radius - the activation radius used to find the nearest hard locations
wordLength - size of vectors stored at hard locations
addrLength - the address size
Method Detail

store

public void store(cern.colt.bitvector.BitVector wrd,
                  cern.colt.bitvector.BitVector addr)
Description copied from interface: SparseDistributedMemory
Stores word in the given address in this sparse distributed memory.

Specified by:
store in interface SparseDistributedMemory
Parameters:
wrd - the word to be stored
addr - the address where the word is to be stored

store

public void store(cern.colt.bitvector.BitVector wrd)
Description copied from interface: SparseDistributedMemory
Stores word in this sparse distributed memory using the word as address.

Specified by:
store in interface SparseDistributedMemory
Parameters:
wrd - the word to be stored

mappedStore

public void mappedStore(cern.colt.bitvector.BitVector wrd,
                        cern.colt.bitvector.BitVector mapping)
Description copied from interface: SparseDistributedMemory
Stores word in this sparse distributed memory using the word as address. The word is mapped (using XOR) with the mapping address.

Specified by:
mappedStore in interface SparseDistributedMemory
Parameters:
wrd - the word to be stored.
mapping - the mapping address.

retrieve

public cern.colt.bitvector.BitVector retrieve(cern.colt.bitvector.BitVector addr)
Description copied from interface: SparseDistributedMemory
Retrieves the contents of this sparse distributed memory at the given address.

Specified by:
retrieve in interface SparseDistributedMemory
Parameters:
addr - the address of the contents to be retrieved
Returns:
the contents of this sparse distributed memory associated with the given address

retrieve

public cern.colt.bitvector.BitVector retrieve(cern.colt.bitvector.BitVector addr,
                                              cern.colt.bitvector.BitVector mapping)
Description copied from interface: SparseDistributedMemory
Retrieves the contents of this SDM at specified address. The address is first mapped using specified mapping then the mapped address is used to retrieve content from this SDM.
Note that the retrieved BitVector is mapped back before it is returned.

Specified by:
retrieve in interface SparseDistributedMemory
Parameters:
addr - the address vector
mapping - the mapping vector
Returns:
the contents of this sparse distributed memory associated with the given address or null if the iteration did not converge

retrieveIterating

public cern.colt.bitvector.BitVector retrieveIterating(cern.colt.bitvector.BitVector addr)
Description copied from interface: SparseDistributedMemory
Retrieves the contents of this sparse distributed memory at the given address iterating this process until result is equal to the address.

Specified by:
retrieveIterating in interface SparseDistributedMemory
Parameters:
addr - the address of the contents to be retrieved
Returns:
the contents of this sparse distributed memory associated with the given address or null if the iteration did not converge

retrieveIterating

public cern.colt.bitvector.BitVector retrieveIterating(cern.colt.bitvector.BitVector addr,
                                                       cern.colt.bitvector.BitVector mapping)
Description copied from interface: SparseDistributedMemory
Retrieves the contents of this SDM at specified address. The address is first mapped using specified mapping then the mapped address is used to retrieve the contents of this SDM until result of retrieval is equal to address.

Specified by:
retrieveIterating in interface SparseDistributedMemory
Parameters:
addr - BitVector address that is being retrieved
mapping - mapping to use
Returns:
the contents of this sparse distributed memory associated with the given address or null if the iteration did not converge