org.rlcommunity.rlglue.codec.taskspec
Class TaskSpec

java.lang.Object
  extended by org.rlcommunity.rlglue.codec.taskspec.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.

This most recent Implementation of TaskSpecDelegate is TaskSpecVRLGLUE3

Author:
Matt Radkie

Constructor Summary
TaskSpec(java.lang.String taskSpec)
          Constructor that takes a string adhereing to the Task Spec language protocol.
TaskSpec(TaskSpecDelegate theTaskSpecDelegate)
           
 
Method Summary
static boolean checkTaskSpec(java.lang.String theTaskSpecString)
          Quick sanity check.
 java.lang.String dump()
          Deprecated. This is dumb.
 int getActionDim()
          Gets the size of the action array (Number of actions)
 double[] getActionMaxs()
          Deprecated. I don't like this anymore.
 double[] getActionMins()
          Deprecated. I don't like this anymore.
 char[] getActionTypes()
          Deprecated. I don't like this anymore.
 DoubleRange getContinuousActionRange(int i)
          Get the min, max, and special information for the i'th double action.
 DoubleRange getContinuousObservationRange(int i)
          Get the min, max, and special information for the i'th double observation.
 double getDiscountFactor()
          Get the discount factor.
 IntRange getDiscreteActionRange(int i)
          Get the min, max, and special information for the i'th integer action.
 IntRange getDiscreteObservationRange(int i)
          Get the min, max, and special information for the i'th integer observation.
 char getEpisodic()
          Deprecated. use getProblemType()
 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()
          Deprecated. This is useless.
 double[] getObsMaxs()
          Deprecated. I don't like this anymore.
 double[] getObsMins()
          Deprecated. I don't like this anymore.
 char[] getObsTypes()
          Deprecated. I don't like this anymore.
 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.
 DoubleRange getRewardRange()
          Get the range of rewards
 java.lang.String getStringRepresentation()
          Returns the string representation of the Task Spec object.
 double getTaskSpecVersion()
          Deprecated. Use getVersionString
 int getVersion()
          Deprecated. Moving to a string version
 java.lang.String getVersionString()
           
 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.
 java.lang.String toString()
          Deprecated. We never should have overloaded toString in this way.
 
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

TaskSpec

public TaskSpec(TaskSpecDelegate theTaskSpecDelegate)
Method Detail

getVersion

public int getVersion()
Deprecated. Moving to a string version

Gets the Task Spec version.

Returns:
Integer value of the Task Spec version.

checkTaskSpec

public static boolean checkTaskSpec(java.lang.String theTaskSpecString)
Quick sanity check. It parses the task spec into an Task Spec TSA. Then, it uses the string representation of TSA to make TSAB. Finally, it makes sure that the string representation of TSA is the same as TSB.

Parameters:
theTaskSpecString -
Returns:
Whether this task spec appears to be valid

getVersionString

public java.lang.String getVersionString()
Returns:
a string representing the version of the task spec that has been parsed
Since:
RL-Glue3.0

toString

public java.lang.String toString()
Deprecated. We never should have overloaded toString in this way.

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
Returns:
String representation of the Task Spec

getStringRepresentation

public java.lang.String getStringRepresentation()
Returns the string representation of the Task Spec object. This string representation follows the Task Spec language as outlined http://glue.rl-community.org/Home/rl-glue/task-spec-language

Returns:
String representation of the Task Spec

dump

public java.lang.String dump()
Deprecated. This is dumb.

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.

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.

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

isMaxRewardInf

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

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

isMinRewardUnknown

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

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

isMaxRewardUnknown

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

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

getTaskSpecVersion

public double getTaskSpecVersion()
Deprecated. Use getVersionString

Gets the version of the Task spec.

Returns:
the version of the Task Spec used.

getEpisodic

public char getEpisodic()
Deprecated. use getProblemType()

Gets the episodic characteristic of the Task Spec.

Returns:
Char value representing if an environment is episodic

getObsDim

public int getObsDim()
Deprecated. This is useless.

Gets the size of the observation array (Number of observations)

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

getNumDiscreteObsDims

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

Returns:
Integer value for the number of descrete observations

getNumContinuousObsDims

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

Returns:
Integer value for the number of continuous observations.

getObsTypes

public char[] getObsTypes()
Deprecated. I don't like this anymore.

Gets the types for the observations.

Returns:
Character array representing the types of the observations.

getObsMins

public double[] getObsMins()
Deprecated. I don't like this anymore.

Gets the array of mins for the observations.

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

getObsMaxs

public double[] getObsMaxs()
Deprecated. I don't like this anymore.

Gets the array of maxs for the observations.

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

getActionDim

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

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

getNumDiscreteActionDims

public int getNumDiscreteActionDims()
Gets the number of descrete actions

Returns:
Integer number of descrete actions.

getNumContinuousActionDims

public int getNumContinuousActionDims()
Gets the number of continous actions

Returns:
Integer number of continous actions.

getActionTypes

public char[] getActionTypes()
Deprecated. I don't like this anymore.

Gets the types for the actions.

Returns:
Character array representing the types of the actions.

getActionMins

public double[] getActionMins()
Deprecated. I don't like this anymore.

Gets the array of mins for the actions.

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

getActionMaxs

public double[] getActionMaxs()
Deprecated. I don't like this anymore.

Gets the array of maxs for the actions.

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

getRewardMax

public double getRewardMax()
Gets the max reward.

Returns:
Double value of the max reward.

getRewardMin

public double getRewardMin()
Gets the min reward.

Returns:
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.

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

getParserVersion

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

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 -

getDiscountFactor

public double getDiscountFactor()
Get the discount factor.

Since:
RL-Glue-3.0

getDiscreteObservationRange

public IntRange getDiscreteObservationRange(int i)
Get the min, max, and special information for the i'th integer observation.

Parameters:
i -
Since:
RL-Glue-3.0

getDiscreteActionRange

public IntRange getDiscreteActionRange(int i)
Get the min, max, and special information for the i'th integer action.

Parameters:
i -
Since:
RL-Glue-3.0

getContinuousObservationRange

public DoubleRange getContinuousObservationRange(int i)
Get the min, max, and special information for the i'th double observation.

Parameters:
i -
Since:
RL-Glue-3.0

getContinuousActionRange

public DoubleRange getContinuousActionRange(int i)
Get the min, max, and special information for the i'th double action.

Parameters:
i -
Since:
RL-Glue-3.0

getRewardRange

public DoubleRange getRewardRange()
Get the range of rewards

Since:
RL-Glue-3.0