org.rlcommunity.rlglue.utilities
Class TaskSpec

java.lang.Object
  extended by org.rlcommunity.rlglue.utilities.TaskSpec

public class TaskSpec
extends java.lang.Object

This class is used to store and parse the information given to an Agent in the RL-Glue framework. The Task Spec stores information the Agent needs regarding the environment, such as the number of actions, observations, and their ranges. For more information please read the RL-Glue Task Spec info

This class was written to handle future revisions to the Task Spec while providing backwards compatibility with old Task Spec versions. This is accomplished through the use of the factory design pattern. The TaskSpecDelegate object is the medium through which the TaskSpec communicates with different implementations of the Task Spec versions. So far, each Task Spec version has incrementally added functionality, but this might not always be the case, so this framework was designed to robustly accomodate future versions.

Author:
Matt Radkie

Constructor Summary
TaskSpec(java.lang.String taskSpec)
          Constructor that takes a string adhereing to the Task Spec language protocol.
 
Method Summary
 java.lang.String dump()
          Returns a string containing debug information about the Task Spec.
 int getActionDim()
          Gets the size of the action array (Number of actions)
 double[] getActionMaxs()
          Gets the array of maxs for the actions.
 double[] getActionMins()
          Gets the array of mins for the actions.
 char[] getActionTypes()
          Gets the types for the actions.
 char getEpisodic()
          Gets the episodic characteristic of the Task Spec.
 java.lang.String getExtraString()
          Gets the string value for the ExtraString.
 int getNumContinuousActionDims()
          Gets the number of continous actions
 int getNumContinuousObsDims()
          Gets the number of continuous observations.
 int getNumDiscreteActionDims()
          Gets the number of descrete actions
 int getNumDiscreteObsDims()
          Gets the number of descrete observations.
 int getObsDim()
          Gets the size of the observation array (Number of observations)
 double[] getObsMaxs()
          Gets the array of maxs for the observations.
 double[] getObsMins()
          Gets the array of mins for the observations.
 char[] getObsTypes()
          Gets the types for the observations.
 int getParserVersion()
          Gets the version of the parser used on the Task Spec.
 double getRewardMax()
          Gets the max reward.
 double getRewardMin()
          Gets the min reward.
 double getTaskSpecVersion()
          Gets the version of the Task spec.
 int getVersion()
          Gets the Task Spec version.
 boolean isActionMaxPosInfinity(int index)
          Checks if the action max at index is positive infinity.
 boolean isActionMaxUnknown(int index)
          Checks if the action max at index is unknown.
 boolean isActionMinNegInfinity(int index)
          Checks if the action min at index is negative infinity.
 boolean isActionMinUnknown(int index)
          Checks if the min action at index is unknown.
 boolean isMaxRewardInf()
          Checks if the max reward is positive infinity.
 boolean isMaxRewardUnknown()
          Checks if the max reward is unknown.
 boolean isMinRewardNegInf()
          Checks if the min reward is negative infinity.
 boolean isMinRewardUnknown()
          Checks if the min reward is unknown.
 boolean isObsMaxPosInfinity(int index)
          Checks if the observation max at index is positive infinity.
 boolean isObsMaxUnknown(int index)
          Checks if the observation max at index is unknown.
 boolean isObsMinNegInfinity(int index)
          Checks if the observation min at index is negative infinity.
 boolean isObsMinUnknown(int index)
          Checks if the observation min at index is unknown.
static void main(java.lang.String[] args)
          Main has no purpose in this class other than for debugging.
 void setActionDim(int dim)
          Set the size of the action array.
 void setActionMaxs(double[] maxs)
          Sets the array of maxs for the actions.
 void setActionMins(double[] mins)
          Sets the array of mins for the actions.
 void setActionTypes(char[] types)
          Sets the types for the actions.
 void setEpisodic(char episodic)
          Set the episodec character in the Task Spec.
 void setExtraString(java.lang.String newString)
          Sets the string value for the ExtraString.
 void setNumContinuousActionDims(int numCont)
          Sets the number of continous actions.
 void setNumContinuousObsDims(int numCont)
          Sets the number of continuous observations.
 void setNumDiscreteActionDims(int numDisc)
          Sets the number of descrete actions.
 void setNumDiscreteObsDims(int numDisc)
          Sets the number of descrete observations.
 void setobsDim(int dim)
          Set the size of the observation array.
 void setObsMaxs(double[] maxs)
          Sets the array of maxs for the observations.
 void setObsMins(double[] mins)
          Sets the array of mins for the observations.
 void setObsTypes(char[] types)
          Sets the types for the observations.
 void setRewardMax(double max)
          Sets the max reward.
 void setRewardMin(double min)
          Sets the min reward.
 void setVersion(int version)
          Set the version of the Task Spec.
 java.lang.String toString()
          Returns the string representation of the Task Spec object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaskSpec

public TaskSpec(java.lang.String taskSpec)
Constructor that takes a string adhereing to the Task Spec language protocol. This string is parsed out by the appropriate version of the Task Spec.

Parameters:
taskSpec - String following the Task Spec language
Method Detail

getVersion

public int getVersion()
Gets the Task Spec version.

Parameters:
none -
Returns:
Integer value of the Task Spec version.

toString

public java.lang.String toString()
Returns the string representation of the Task Spec object. This string representation follows the Task Spec language as outlined here

Overrides:
toString in class java.lang.Object
Parameters:
none -
Returns:
String representation of the Task Spec

dump

public java.lang.String dump()
Returns a string containing debug information about the Task Spec. This debug information is usually printed to the screen, but returning it as a string allows the caller to print it out to log files etc as well.

Parameters:
none -
Returns:
String containing debug information for the Task Spec.

isObsMinNegInfinity

public boolean isObsMinNegInfinity(int index)
Checks if the observation min at index is negative infinity.

Parameters:
index - Integer index of the obs_min array.
Returns:
True if obs_min[index] is negative infinity, false otherwise.

isActionMinNegInfinity

public boolean isActionMinNegInfinity(int index)
Checks if the action min at index is negative infinity.

Parameters:
index - - integer index of the action_mins array.
Returns:
True if action_min[index] is negative infinity, false otherwise.

isObsMaxPosInfinity

public boolean isObsMaxPosInfinity(int index)
Checks if the observation max at index is positive infinity.

Parameters:
index - Interger index of the obs_maxs array.
Returns:
True if obs_max[index] is positive infinity, false otherwise.

isActionMaxPosInfinity

public boolean isActionMaxPosInfinity(int index)
Checks if the action max at index is positive infinity.

Parameters:
index - Integer index of the action_maxs array.
Returns:
True if action_max[index] is positive infinity, false otherwise.

isObsMinUnknown

public boolean isObsMinUnknown(int index)
Checks if the observation min at index is unknown.

Parameters:
index - Integer index of the obs_mins array.
Returns:
True if the min value for observation[index] is unknown, false otherwise.

isObsMaxUnknown

public boolean isObsMaxUnknown(int index)
Checks if the observation max at index is unknown.

Parameters:
index - Integer index of the obs_max array.
Returns:
True if the max value for observation[index] is unknown, false otherwise.

isActionMinUnknown

public boolean isActionMinUnknown(int index)
Checks if the min action at index is unknown.

Parameters:
index - Integer index of the action_mins array.
Returns:
True if the min value for action[index] is unknown, false otherwise.

isActionMaxUnknown

public boolean isActionMaxUnknown(int index)
Checks if the action max at index is unknown.

Parameters:
index - Integer index of the action_maxs array.
Returns:
True if the max value for action[index] is unknown, false otherwise.

isMinRewardNegInf

public boolean isMinRewardNegInf()
Checks if the min reward is negative infinity.

Parameters:
none -
Returns:
True if the min reward is negative infinity, false otherwise.

isMaxRewardInf

public boolean isMaxRewardInf()
Checks if the max reward is positive infinity.

Parameters:
none -
Returns:
True if the max reward is positive infinity, false otherwise.

isMinRewardUnknown

public boolean isMinRewardUnknown()
Checks if the min reward is unknown.

Parameters:
none -
Returns:
True if the min reward is unknown, false otherwise.

isMaxRewardUnknown

public boolean isMaxRewardUnknown()
Checks if the max reward is unknown.

Parameters:
none -
Returns:
True if the max reward is unknown, false otherwise.

getTaskSpecVersion

public double getTaskSpecVersion()
Gets the version of the Task spec.

Parameters:
none -
Returns:
the version of the Task Spec used.

setVersion

public void setVersion(int version)
Set the version of the Task Spec.

Parameters:
version - Integer representing the version of the Task Spec.

getEpisodic

public char getEpisodic()
Gets the episodic characteristic of the Task Spec.

Parameters:
none -
Returns:
Char value representing if an environment is episodic

setEpisodic

public void setEpisodic(char episodic)
Set the episodec character in the Task Spec.

Parameters:
episodic - Character representing whether an environment is episodic.

getObsDim

public int getObsDim()
Gets the size of the observation array (Number of observations)

Parameters:
none -
Returns:
The size of the observation array (Number of observations)

setobsDim

public void setobsDim(int dim)
Set the size of the observation array.

Parameters:
dim - Integer for the size of the observation array.

getNumDiscreteObsDims

public int getNumDiscreteObsDims()
Gets the number of descrete observations.

Parameters:
none -
Returns:
Integer value for the number of descrete observations

setNumDiscreteObsDims

public void setNumDiscreteObsDims(int numDisc)
Sets the number of descrete observations.

Parameters:
numDisc - Integer number of descrete observations.

getNumContinuousObsDims

public int getNumContinuousObsDims()
Gets the number of continuous observations.

Parameters:
none -
Returns:
Integer value for the number of continuous observations.

setNumContinuousObsDims

public void setNumContinuousObsDims(int numCont)
Sets the number of continuous observations.

Parameters:
numDisc - Integer number of continuous observations.

getObsTypes

public char[] getObsTypes()
Gets the types for the observations.

Parameters:
none -
Returns:
Character array representing the types of the observations.

setObsTypes

public void setObsTypes(char[] types)
Sets the types for the observations.

Parameters:
types - Character array representing the types of the observations.

getObsMins

public double[] getObsMins()
Gets the array of mins for the observations.

Parameters:
none -
Returns:
double[] Array of the min values for the observations.

setObsMins

public void setObsMins(double[] mins)
Sets the array of mins for the observations.

Parameters:
mins - array of doubles corresponding to the mins for the observations.

getObsMaxs

public double[] getObsMaxs()
Gets the array of maxs for the observations.

Parameters:
none -
Returns:
double[] Array of the maxs values for the observations.

setObsMaxs

public void setObsMaxs(double[] maxs)
Sets the array of maxs for the observations.

Parameters:
mins - array of doubles corresponding to the maxs for the observations.

getActionDim

public int getActionDim()
Gets the size of the action array (Number of actions)

Parameters:
none -
Returns:
The size of the action array (Number of actions)

setActionDim

public void setActionDim(int dim)
Set the size of the action array.

Parameters:
dim - Integer for the size of the action array.

getNumDiscreteActionDims

public int getNumDiscreteActionDims()
Gets the number of descrete actions

Parameters:
none -
Returns:
Integer number of descrete actions.

setNumDiscreteActionDims

public void setNumDiscreteActionDims(int numDisc)
Sets the number of descrete actions.

Parameters:
numDisc - Integer number of descrete actions.

getNumContinuousActionDims

public int getNumContinuousActionDims()
Gets the number of continous actions

Parameters:
none -
Returns:
Integer number of continous actions.

setNumContinuousActionDims

public void setNumContinuousActionDims(int numCont)
Sets the number of continous actions.

Parameters:
numDisc - Integer number of continous actions.

getActionTypes

public char[] getActionTypes()
Gets the types for the actions.

Parameters:
none -
Returns:
Character array representing the types of the actions.

setActionTypes

public void setActionTypes(char[] types)
Sets the types for the actions.

Parameters:
types - Character array representing the types of the actions.

getActionMins

public double[] getActionMins()
Gets the array of mins for the actions.

Parameters:
none -
Returns:
double[] Array of the min values for the actions.

setActionMins

public void setActionMins(double[] mins)
Sets the array of mins for the actions.

Parameters:
mins - Double array of values corresponding to action min values.

getActionMaxs

public double[] getActionMaxs()
Gets the array of maxs for the actions.

Parameters:
none -
Returns:
double[] Array of the max values for the actions.

setActionMaxs

public void setActionMaxs(double[] maxs)
Sets the array of maxs for the actions.

Parameters:
mins - Double array of values corresponding to action max values.

getRewardMax

public double getRewardMax()
Gets the max reward.

Parameters:
none -
Returns:
Double value of the max reward.

setRewardMax

public void setRewardMax(double max)
Sets the max reward.

Parameters:
max - Double value of the max reward

getRewardMin

public double getRewardMin()
Gets the min reward.

Parameters:
none -
Returns:
Double value of the min reward.

setRewardMin

public void setRewardMin(double min)
Sets the min reward.

Parameters:
min - Double value of the min reward.

getExtraString

public java.lang.String getExtraString()
Gets the string value for the ExtraString. 'ExtraString' is new for Task Spec version 3. It allows additional information to be appended to the end of the Task Spec. When environments use this feature, agents will require special code to handle this.

Parameters:
none -
Returns:
String of additional information appended onto the end of the Task Spec.

setExtraString

public void setExtraString(java.lang.String newString)
Sets the string value for the ExtraString. 'ExtraString' is new for Task Spec version 3. It allows additional information to be appended to the end of the Task Spec. When environments use this feature, agents will require special code to handle this.

Parameters:
newString - the new string to be appended to the TaskSpec.

getParserVersion

public int getParserVersion()
Gets the version of the parser used on the Task Spec.

Parameters:
none -
Returns:
Integer version of the parser used on the Task Spec.

main

public static void main(java.lang.String[] args)
Main has no purpose in this class other than for debugging. This should have been deleted prior to release, but as it makes on going development easier, it has been left for now. Ideally in the future, this code will be removed and moved into test cases.

Parameters:
args -