edu.iastate.jrelm.core
Class SimpleStateDomain<O>

java.lang.Object
  extended by edu.iastate.jrelm.core.SimpleStateDomain<O>
Type Parameters:
O - - This is the original type of state Objects in the given collection.
All Implemented Interfaces:
StateDomain<java.lang.Integer,SimpleState<O>>

public class SimpleStateDomain<O>
extends java.lang.Object
implements StateDomain<java.lang.Integer,SimpleState<O>>

SimpleStateDomain is basic implementation of the StateDomain interface. This no-frills domain is essentially built around an ArrayList of SimpleStates that wrap a given collection of Objects that represent state choices.

This domain builds itself from a given collection of Objects. Each Object is considered to represent a state of the environment external to the ReinforcementLearning (or agent). The Collection is the list of all possible states an ReinforcementLearner may encounter. Internally, each Object is wrapped in SimpleState and the space of possible states is organized by Integer index. The use of SimpleState wrappers allow the domain to be used with other learning components (i.e. ReinforcementLearners that implement stateful learning algorithms).

Note, this class is only appropriate for contexts where the set of all possible states is discrete and finite.


Constructor Summary
SimpleStateDomain(java.util.Collection<O> states)
          Build a domain from the given collection of Objects.
 
Method Summary
 boolean containsState(SimpleState<O> stateToCheck)
          Determines if the given Action is in this domain.
 java.util.ArrayList<java.lang.Integer> getIDList()
          Retrieve a list of the identifiers for all States in this domain.
 SimpleState<O> getState(int stateIndex)
          Convenience method to allow states to be retrieved with an int id.
 SimpleState<O> getState(java.lang.Integer id)
          Retrieves the State indicated by the id object.
 int size()
          Reports the number of States in this domain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleStateDomain

public SimpleStateDomain(java.util.Collection<O> states)
Build a domain from the given collection of Objects.

Parameters:
states - - list of objects specifying states.
Method Detail

containsState

public boolean containsState(SimpleState<O> stateToCheck)
Description copied from interface: StateDomain
Determines if the given Action is in this domain.

Specified by:
containsState in interface StateDomain<java.lang.Integer,SimpleState<O>>
See Also:
StateDomain

getState

public SimpleState<O> getState(java.lang.Integer id)
Description copied from interface: StateDomain
Retrieves the State indicated by the id object. Should return null if the id does not match an existing Action.

Specified by:
getState in interface StateDomain<java.lang.Integer,SimpleState<O>>
Parameters:
id - - identifier indicating the desired State
Returns:
the requested State associated with id in this domain
See Also:
StateDomain

getState

public SimpleState<O> getState(int stateIndex)
Convenience method to allow states to be retrieved with an int id. This id should be the index of the desired object in the original collection given to the domain in the constructor.

Parameters:
stateIndex - - int index of the desired state in the domain
Returns:
- the desired state (note: the original object is wrapped in a SimpleState)

size

public int size()
Description copied from interface: StateDomain
Reports the number of States in this domain.

Specified by:
size in interface StateDomain<java.lang.Integer,SimpleState<O>>
Returns:
size of this domain
See Also:
edu.iastate.jrelm.core.DiscreteFiniteDomain

getIDList

public java.util.ArrayList<java.lang.Integer> getIDList()
Description copied from interface: StateDomain
Retrieve a list of the identifiers for all States in this domain.

Specified by:
getIDList in interface StateDomain<java.lang.Integer,SimpleState<O>>
Returns:
list of action IDs.