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

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

public class SimpleActionDomain<O>
extends java.lang.Object
implements ActionDomain<java.lang.Integer,SimpleAction<O>>

SimpleActionDomain is basic implementation of the ActionDomain interface. This no-frills domain is essentially built around an ArrayList of SimpleActions that wrap a given collection of Objects that represent action choices.

This domain builds itself from a given collection of Objects. Each Object is considered to represent a choice of action and the Collection the list of all possible actions an ReinforcementLearner can choose from. Internally, each Object is wrapped in SimpleAction and the space of possible actions is organized by Integer index. The use of SimpleAction wrappers allow the domain to be used with other learning components (i.e. ReinforcementLearner, StatelessPolicy).


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

Constructor Detail

SimpleActionDomain

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

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

containsAction

public boolean containsAction(SimpleAction<O> actionToCheck)
Description copied from interface: ActionDomain
Determines if the given Action is in this domain.

Specified by:
containsAction in interface ActionDomain<java.lang.Integer,SimpleAction<O>>
See Also:
ActionDomain

getAction

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

Specified by:
getAction in interface ActionDomain<java.lang.Integer,SimpleAction<O>>
Parameters:
id - - identifier indicating the desired Action
Returns:
the requested Action associated with id in this domain
See Also:
ActionDomain

getAction

public SimpleAction<O> getAction(int actionIndex)
Convenience method to allow actions 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:
actionIndex - - int index of the desired action in the domain
Returns:
- the desired action (note: the original object is wrapped in a SimpleAction)

size

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

Specified by:
size in interface ActionDomain<java.lang.Integer,SimpleAction<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: ActionDomain
Retrieve a list of the identifiers for all Actions in this domain.

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