clarion.system
Class TableLookup

java.lang.Object
  extended by clarion.system.AbstractImplicitModule
      extended by clarion.system.AbstractTrainableImplicitModule
          extended by clarion.system.AbstractRuntimeTrainableImplicitModule
              extended by clarion.system.TableLookup
All Implemented Interfaces:
InterfaceHandlesFeedback, InterfaceRuntimeTrainable, InterfaceTracksMatchStatistics, InterfaceTrainable

public class TableLookup
extends AbstractRuntimeTrainableImplicitModule

This class implements a table lookup within CLARION. It extends the AbstractRuntimeTrainableImplicitModule class.

Usage:

A table lookup is the simplest form of implicit module that can be used in the bottom level of the CLARION subsystems. It consists of a hash map that uses dimension-value collections as keys and output chunk collections as values. The keys of the hash map are configurations of the input layer that are compared to the current input and the values of the hash map are output chunks that correspond to the chunks on the output layer.

When the forwardPass method is called, the table lookup takes the current input and compares it to the keys of the hash map until it finds a match. If no match is found, the forwardPass method does nothing. When a match is found, the method sets the activations of the output chunks of the table lookup to the activations of the output chunks contained within the collection located at the slot in the hash map whose key matched the current input.

This class is considered to be runtime trainable in that a value can be specified by the feedback for a chosen output chunk and that value will then be set as the new activation for that output chunk within the collection of output chunks located at the slot in the hash map whose key matched the current input. This procedure is performed during by the backwardPass method.

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

Field Summary
protected  double Feedback
          The immediate feedback given (if given).
static double GLOBAL_POSITIVE_MATCH_THRESHOLD
          The threshold for the positive match criterion.
private  java.util.HashMap<DimensionValueCollection,AbstractOutputChunkCollection<? extends AbstractOutputChunk>> LookupTable
          The hash map backed table lookup.
protected  double NM
          The negative match counter.
protected  double PM
          The positive match counter.
 double POSITIVE_MATCH_THRESHOLD
          The threshold for the positive match criterion.
 
Fields inherited from class clarion.system.AbstractTrainableImplicitModule
DesiredOutput
 
Fields inherited from class clarion.system.AbstractImplicitModule
ACTUATION_TIME, ChosenOutput, DECISION_TIME, GLOBAL_ACTUATION_TIME, GLOBAL_DECISION_TIME, GLOBAL_PERCEPTION_TIME, InputAsCollection, Output, PERCEPTION_TIME
 
Constructor Summary
TableLookup(java.util.Collection<Dimension> InputSpace, AbstractOutputChunkCollection<? extends AbstractOutputChunk> Outputs, java.util.Map<DimensionValueCollection,AbstractOutputChunkCollection<? extends AbstractOutputChunk>> Table)
          Initializes the table lookup with the input space, outputs, and map specified.
 
Method Summary
 void backwardPass()
          Updates the table lookup table given the chosen action and the feedback.
 boolean checkMatchCriterion()
          Checks to see if the positive match criterion is satisfied given the immediate feedback received.
 void forwardPass()
          Calculates the output activations based on the current input.
 java.lang.Double getSuccessRate()
          Gets the success rate.
 
Methods inherited from class clarion.system.AbstractRuntimeTrainableImplicitModule
getFeedback, getNM, getPM, incrementNM, incrementPM, resetMatchStatistics, setFeedback, setNM, setPM, updateMatchStatistics
 
Methods inherited from class clarion.system.AbstractTrainableImplicitModule
getSumSqErrors, setDesiredOutput, setDesiredOutput
 
Methods inherited from class clarion.system.AbstractImplicitModule
getChosenOutput, getInput, getNumInput, getNumOutput, getOutput, getOutput, getResponseTime, setChosenOutput, setInput, setInput, setInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface clarion.system.InterfaceTrainable
getSumSqErrors, setDesiredOutput, setDesiredOutput
 

Field Detail

LookupTable

private java.util.HashMap<DimensionValueCollection,AbstractOutputChunkCollection<? extends AbstractOutputChunk>> LookupTable
The hash map backed table lookup.


Feedback

protected double Feedback
The immediate feedback given (if given).


PM

protected double PM
The positive match counter.


NM

protected double NM
The negative match counter.


GLOBAL_POSITIVE_MATCH_THRESHOLD

public static double GLOBAL_POSITIVE_MATCH_THRESHOLD
The threshold for the positive match criterion.


POSITIVE_MATCH_THRESHOLD

public double POSITIVE_MATCH_THRESHOLD
The threshold for the positive match criterion.

Constructor Detail

TableLookup

public TableLookup(java.util.Collection<Dimension> InputSpace,
                   AbstractOutputChunkCollection<? extends AbstractOutputChunk> Outputs,
                   java.util.Map<DimensionValueCollection,AbstractOutputChunkCollection<? extends AbstractOutputChunk>> Table)
Initializes the table lookup with the input space, outputs, and map specified.

Parameters:
InputSpace - The input space for the table lookup.
Outputs - The output chunks for the output layer of the table lookup.
Table - The table to use for looking up outputs from the table lookup.
Method Detail

backwardPass

public void backwardPass()
Updates the table lookup table given the chosen action and the feedback. This method should not be called before the setFeedback and setChosenAction methods have been called.

In the backwardPass method, a value is specified by the feedback for a chosen output chunk and that value is then be set as the new activation for that output chunk within the collection of output chunks located at the slot in the hash map whose key matched the current input.

Specified by:
backwardPass in interface InterfaceTrainable
Specified by:
backwardPass in class AbstractTrainableImplicitModule

forwardPass

public void forwardPass()
Calculates the output activations based on the current input. This method should not be called until the setInput method has been called setting the input activations to the current state.

When the forwardPass method is called, the table lookup takes the current input and compares it to the keys of the hash map until it finds a match. If no match is found, the forwardPass method does nothing. When a match is found, the method sets the activations of the output chunks of the table lookup to the activations of the output chunks contained within the collection located at the slot in the hash map whose key matched the current input.

Specified by:
forwardPass in class AbstractImplicitModule

checkMatchCriterion

public boolean checkMatchCriterion()
Checks to see if the positive match criterion is satisfied given the immediate feedback received.

This check is usually performed before the backwardPass method is called but after the setFeedback and setChosenAction methods have been called.

Returns:
True if the positive match criterion has been satisfied, otherwise false.

getSuccessRate

public java.lang.Double getSuccessRate()
Gets the success rate. If no match statistics have been updated (i.e. PM & NM are both 0), this method will return null.

Returns:
The success rate (or null if no match statistics have been updated).