org.jscience.computing.ai.reinforcement.qlearning
Class QTable

java.lang.Object
  extended by org.jscience.computing.ai.reinforcement.qlearning.QTable

public class QTable
extends java.lang.Object

Q-table implementation


Constructor Summary
QTable()
          Creates a q-table with default parameters
 
Method Summary
 void clear()
          Clears the content of q-table
 java.lang.Object getBestAction(java.lang.Object state)
          Returns best action for given state
 java.util.Collection getBestActions()
          Returns all of the best actions for each states tried so far
 double getBestValue(java.lang.Object state)
          Returns the best reinforcement value for given state
 int getNumberOfStates()
          Returns the number of different states in the q-table
 int getSize()
          Returns the number of entries in q-table
 java.util.Enumeration getStates()
          Returns different states in the q-table.
 double getValue(java.lang.Object state, java.lang.Object action)
          Returns reinforcement value for given state and action
 boolean hasState(java.lang.Object state)
          Chacks whether the q-table contains the given state
 boolean hasStateActionPair(java.lang.Object state, java.lang.Object action)
          Chacks whether the q-table contains the given state-action pair
 void updateValue(java.lang.Object state, java.lang.Object action, double value)
          Updates q-table with given state, action and value information
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QTable

public QTable()
Creates a q-table with default parameters

Method Detail

updateValue

public void updateValue(java.lang.Object state,
                        java.lang.Object action,
                        double value)
Updates q-table with given state, action and value information

Parameters:
state - state before the action is done
action - action performed for given reward
value - reinforcement taken after the action is done

getBestAction

public java.lang.Object getBestAction(java.lang.Object state)
                               throws QTableEntryNotFoundException
Returns best action for given state

Parameters:
state - state to look for best action
Returns:
selected action
Throws:
QTableEntryNotFoundException - if the given state is not found in q-table

getValue

public double getValue(java.lang.Object state,
                       java.lang.Object action)
                throws QTableEntryNotFoundException
Returns reinforcement value for given state and action

Parameters:
state - state to look for reinforcement value
action - action to look for reinforcement value
Returns:
reinforcement value
Throws:
QTableEntryNotFoundException - if the given state-action pair can not be found in q-table

getBestValue

public double getBestValue(java.lang.Object state)
                    throws QTableEntryNotFoundException
Returns the best reinforcement value for given state

Parameters:
state - state to look for the best reinforcement value
Returns:
the best reinforcement vlaue for given state
Throws:
QTableEntryNotFoundException - if the given state is not found in the q-table

hasState

public boolean hasState(java.lang.Object state)
Chacks whether the q-table contains the given state

Parameters:
state - state to search in the q-table
Returns:
true if the state is found in the q-table else returns false

hasStateActionPair

public boolean hasStateActionPair(java.lang.Object state,
                                  java.lang.Object action)
Chacks whether the q-table contains the given state-action pair

Parameters:
state - state to search in the q-table
action - action to search in the q-table
Returns:
true if the state is found in the q-table else returns false

getNumberOfStates

public int getNumberOfStates()
Returns the number of different states in the q-table

Returns:
number of different states in the q-table

getStates

public java.util.Enumeration getStates()
Returns different states in the q-table.

Returns:
different states in the q-table.

getBestActions

public java.util.Collection getBestActions()
Returns all of the best actions for each states tried so far

Returns:
all of the best actions

getSize

public int getSize()
Returns the number of entries in q-table

Returns:
size of this q-table

clear

public void clear()
Clears the content of q-table