org.rlcommunity.rlglue.utilities
Class TaskSpecV3

java.lang.Object
  extended by org.rlcommunity.rlglue.utilities.TaskSpecDelegate
      extended by org.rlcommunity.rlglue.utilities.TaskSpecV3

 class TaskSpecV3
extends TaskSpecDelegate

The newest version of the Task Spec (May 15th 2008). With the release of version 3, the framework of the Task Spec (in Java atleast) was overhauled. The capability of adding more versions of the Task Spec without affecting old versions was addded. @see rlglue.utilities.TaskSpecDelegate for more info. TaskSpecV3 now has the capability of appending a string of extra data onto the end of the task spec.

Author:
mradkie

Field Summary
private  int action_dim
          Total number of actions
private  double[] action_maxs
          Array of the maximum value for the actions.
private  double[] action_mins
          Array of the minimum value for the actions.
private  char[] action_types
          Array of types for the actions
private  char episodic
          Stores whether the environment is episodic or continuous.
private  java.lang.String extraString
          String of extra data to be appended onto the end of the Task Spec.
private  int num_continuous_action_dims
          Number of continous actions
private  int num_continuous_obs_dims
          Number of continous observations.
private  int num_discrete_action_dims
          Number of discrete actions
private  int num_discrete_obs_dims
          Number of discrete observations.
private  int obs_dim
          Total number of observations.
private  double[] obs_maxs
          Array of the maximum value for the observations.
private  double[] obs_mins
          Array of the minimum value for the observations.
private  char[] obs_types
          Array of types for the observations.
(package private) static int parser_version
          Version of the parser used for this Task Spec.
private  double reward_max
          Maximum value for the reward.
private  double reward_min
          Minimum value for the reward.
private  double version
          Task Spec version.
 
Constructor Summary
TaskSpecV3()
           
TaskSpecV3(java.lang.String taskSpecString)
          The constructor for version 3 of the Task Spec taks a string as a parameter.
 
Method Summary
private  java.lang.String buildActionString()
          Builds the action portion of the Task Spec string from the information stored within this Task Spec object.
private  java.lang.String buildObsString()
          Builds the observation portion of the Task Spec string from the information stored within this Task Spec object.
protected  void constraintCheck()
          Checks to make sure that: observation mins < observation maxs; action mins < action maxs and reward mins < reward maxs.
 java.lang.String dump()
          Builds a debug string of all the information stored within this Task Spec.
 int getActionDim()
           
 double[] getActionMaxs()
           
 double[] getActionMins()
           
 char[] getActionTypes()
           
 char getEpisodic()
           
 java.lang.String getExtraString()
           
 int getNumContinuousActionDims()
           
 int getNumContinuousObsDims()
           
 int getNumDiscreteActionDims()
           
 int getNumDiscreteObsDims()
           
 int getObsDim()
           
 double[] getObsMaxs()
           
 double[] getObsMins()
           
 char[] getObsTypes()
           
 int getParserVersion()
           
 double getRewardMax()
           
 double getRewardMin()
           
 java.lang.String getStringRepresentation()
          Builds the string representation of the Task Spec, which follows the Task Spec language.
 double getVersion()
           
 boolean isActionMaxPosInfinity(int index)
           
 boolean isActionMaxUnknown(int index)
           
 boolean isActionMinNegInfinity(int index)
           
 boolean isActionMinUnknown(int index)
           
 boolean isMaxRewardInf()
           
 boolean isMaxRewardUnknown()
           
 boolean isMinRewardNegInf()
           
 boolean isMinRewardUnknown()
           
 boolean isObsMaxPosInfinity(int index)
           
 boolean isObsMaxUnknown(int index)
           
 boolean isObsMinNegInfinity(int index)
           
 boolean isObsMinUnknown(int index)
           
protected  void parseActionRanges(java.util.StringTokenizer actionTokenizer)
          Parses the ranges for the actions, storing the minimum values in one array and the max values in a second array.
protected  void parseActions(java.lang.String actionString)
          Parses all information out of the actions portion of the Task Spec.
protected  void parseActionTypesAndDimensions(java.lang.String actionTypesString)
          Parses out the action information from the string parameter and stores it.
protected  void parseObservationRanges(java.util.StringTokenizer observationTokenizer)
          Parses the ranges for the observations, storing the minimum values in one array and the max values in a second array.
protected  void parseObservations(java.lang.String observationString)
          Parses all information out of the observation portion of the Task Spec.
protected  void parseObservationTypesAndDimensions(java.lang.String obsTypesString)
          Parses out the observation information from the string parameter and stores it.
protected  void parseRewards(java.lang.String rewardString)
          Parses all information out of the reward portion of the Task Spec.
protected  boolean rangeKnown(java.lang.String valueRange)
          Checks if the range of a given parameter is known.
protected  java.lang.String removeWhiteSpace(java.lang.String input)
          Removes spaces from a given string.
 void setActionDim(int dim)
           
 void setActionMaxs(double[] maxs)
           
 void setActionMins(double[] mins)
           
 void setActionTypes(char[] types)
           
 void setEpisodic(char episodic)
           
 void setExtraString(java.lang.String newString)
           
 void setNumContinuousActionDims(int numCont)
           
 void setNumContinuousObsDims(int numCont)
           
 void setNumDiscreteActionDims(int numDisc)
           
 void setNumDiscreteObsDims(int numDisc)
           
 void setObsDim(int dim)
           
 void setObsMaxs(double[] maxs)
           
 void setObsMins(double[] mins)
           
 void setObsTypes(char[] types)
           
 void setRewardMax(double max)
           
 void setRewardMin(double min)
           
 void setVersion(int version)
           
protected  double validValue(java.lang.String valueString)
          Parses a double out of a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

private double version
Task Spec version. Should be 3.


episodic

private char episodic
Stores whether the environment is episodic or continuous.


obs_dim

private int obs_dim
Total number of observations.


num_discrete_obs_dims

private int num_discrete_obs_dims
Number of discrete observations.


num_continuous_obs_dims

private int num_continuous_obs_dims
Number of continous observations.


obs_types

private char[] obs_types
Array of types for the observations.


obs_mins

private double[] obs_mins
Array of the minimum value for the observations. (One min per observation)


obs_maxs

private double[] obs_maxs
Array of the maximum value for the observations. (One max per observation)


action_dim

private int action_dim
Total number of actions


num_discrete_action_dims

private int num_discrete_action_dims
Number of discrete actions


num_continuous_action_dims

private int num_continuous_action_dims
Number of continous actions


action_types

private char[] action_types
Array of types for the actions


action_mins

private double[] action_mins
Array of the minimum value for the actions. (One min per action)


action_maxs

private double[] action_maxs
Array of the maximum value for the actions. (One max per action)


reward_max

private double reward_max
Maximum value for the reward.


reward_min

private double reward_min
Minimum value for the reward.


extraString

private java.lang.String extraString
String of extra data to be appended onto the end of the Task Spec.


parser_version

static final int parser_version
Version of the parser used for this Task Spec.

See Also:
Constant Field Values
Constructor Detail

TaskSpecV3

public TaskSpecV3(java.lang.String taskSpecString)
The constructor for version 3 of the Task Spec taks a string as a parameter. This string is then parsed out, and the information from this string, such as number of actions or observations can be accessed. The format of the string should follow the conventions of the Task Spec language. Please refer to Task Spec for more information.

Version 3 of the Task Spec added the capability of appending a string of extra data onto the end of the Task Spec.

Parameters:
taskSpecString - String format of a Task Spec to be parsed into an object.

TaskSpecV3

TaskSpecV3()
Method Detail

parseObservationTypesAndDimensions

protected void parseObservationTypesAndDimensions(java.lang.String obsTypesString)
                                           throws java.lang.Exception
Parses out the observation information from the string parameter and stores it. Number of observations and observation types are parsed.

Parameters:
obsTypesString - Observation portion of the Task Spec.
Throws:
java.lang.Exception

parseObservationRanges

protected void parseObservationRanges(java.util.StringTokenizer observationTokenizer)
Parses the ranges for the observations, storing the minimum values in one array and the max values in a second array.

Parameters:
observationTokenizer - Tokenizer on the observation string, tokenizing on the '_'.

parseActionTypesAndDimensions

protected void parseActionTypesAndDimensions(java.lang.String actionTypesString)
                                      throws java.lang.Exception
Parses out the action information from the string parameter and stores it. Number of actions and action types are parsed.

Parameters:
obsTypesString - Action portion of the Task Spec.
Throws:
java.lang.Exception

parseActionRanges

protected void parseActionRanges(java.util.StringTokenizer actionTokenizer)
Parses the ranges for the actions, storing the minimum values in one array and the max values in a second array.

Parameters:
observationTokenizer - Tokenizer on the action string, tokenizing on the '_'.

parseObservations

protected void parseObservations(java.lang.String observationString)
                          throws java.lang.Exception
Parses all information out of the observation portion of the Task Spec. Observation string is passed in, the number of observations, the observation types and ranges are all parsed out of this string and stored within the respective variables.

Parameters:
observationString - Observation portion of the Task Spec string
Throws:
java.lang.Exception

parseActions

protected void parseActions(java.lang.String actionString)
                     throws java.lang.Exception
Parses all information out of the actions portion of the Task Spec. Action string is passed in, the number of actions, the action types and ranges are all parsed out of this string and stored within the respective variables.

Parameters:
observationString - Action portion of the Task Spec string
Throws:
java.lang.Exception

parseRewards

protected void parseRewards(java.lang.String rewardString)
                     throws java.lang.Exception
Parses all information out of the reward portion of the Task Spec. Reward string is passed in, the min and max reward is stored.

Parameters:
observationString - Reward portion of the Task Spec string
Throws:
java.lang.Exception

validValue

protected double validValue(java.lang.String valueString)
Parses a double out of a string. This method acts like an overloaded Double.parseDouble(String) method, conventions for -infinity and infinity were added.

Parameters:
valueString - String to parse the double out of.
Returns:
The double parsed out of the strng.

rangeKnown

protected boolean rangeKnown(java.lang.String valueRange)
Checks if the range of a given parameter is known. Observations, actions and rewards all follow the convention [min,max]. If the min and max are not specified, the range is unknown.

Parameters:
valueRange - String of the form "[min,max]" where min and max may not be specified ("[,] or []").
Returns:
True if range is known, false otherwise.

removeWhiteSpace

protected java.lang.String removeWhiteSpace(java.lang.String input)
Removes spaces from a given string.

Parameters:
input - String to remove spaces from.
Returns:
Input string after spaces are removed.

constraintCheck

protected void constraintCheck()
                        throws java.lang.Exception
Checks to make sure that: observation mins < observation maxs; action mins < action maxs and reward mins < reward maxs.

Throws:
java.lang.Exception - Exception thrown if one of these conditions is not met.

isObsMinNegInfinity

public boolean isObsMinNegInfinity(int index)
Overrides:
isObsMinNegInfinity in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isObsMinNegInfinity(int index)

isActionMinNegInfinity

public boolean isActionMinNegInfinity(int index)
Overrides:
isActionMinNegInfinity in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isActionMinNegInfinity(int index)

isObsMaxPosInfinity

public boolean isObsMaxPosInfinity(int index)
Overrides:
isObsMaxPosInfinity in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isObsMaxPosInfinity(int index)

isActionMaxPosInfinity

public boolean isActionMaxPosInfinity(int index)
Overrides:
isActionMaxPosInfinity in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isActionMaxPosInfinity(int index)

isObsMinUnknown

public boolean isObsMinUnknown(int index)
Overrides:
isObsMinUnknown in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isObsMinUnknown(int index)

isObsMaxUnknown

public boolean isObsMaxUnknown(int index)
Overrides:
isObsMaxUnknown in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isObsMaxUnknown(int index)

isActionMinUnknown

public boolean isActionMinUnknown(int index)
Overrides:
isActionMinUnknown in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isActionMinUnknown(int index)

isActionMaxUnknown

public boolean isActionMaxUnknown(int index)
Overrides:
isActionMaxUnknown in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isActionMaxUnknown(int index)

isMinRewardNegInf

public boolean isMinRewardNegInf()
Overrides:
isMinRewardNegInf in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isMinRewardNegInf()

isMaxRewardInf

public boolean isMaxRewardInf()
Overrides:
isMaxRewardInf in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isMaxRewardInf()

isMinRewardUnknown

public boolean isMinRewardUnknown()
Overrides:
isMinRewardUnknown in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isMinRewardUnknown()

isMaxRewardUnknown

public boolean isMaxRewardUnknown()
Overrides:
isMaxRewardUnknown in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#isMaxRewardUnknown()

getStringRepresentation

public java.lang.String getStringRepresentation()
Builds the string representation of the Task Spec, which follows the Task Spec language.

Overrides:
getStringRepresentation in class TaskSpecDelegate
Parameters:
none -
Returns:
String representation of the Task Spec
See Also:
rlglue.utilities.TaskSpec#getStringRepresentation()

buildActionString

private java.lang.String buildActionString()
Builds the action portion of the Task Spec string from the information stored within this Task Spec object.

Parameters:
none -
Returns:
String representation of the action information.

buildObsString

private java.lang.String buildObsString()
Builds the observation portion of the Task Spec string from the information stored within this Task Spec object.

Parameters:
none -
Returns:
String representation of the observation information.

dump

public java.lang.String dump()
Builds a debug string of all the information stored within this Task Spec. Instead of printing this debug info to the screen, it is returned so the implementer can use it.

Overrides:
dump in class TaskSpecDelegate
Parameters:
none -
Returns:
String full of debug information about the Task Spec object.
See Also:
rlglue.utilities.TaskSpec#dump()

getVersion

public double getVersion()
Overrides:
getVersion in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getVersion()

setVersion

public void setVersion(int version)
Overrides:
setVersion in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setVersion(int version)

getEpisodic

public char getEpisodic()
Overrides:
getEpisodic in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getEpisodic()

setEpisodic

public void setEpisodic(char episodic)
Overrides:
setEpisodic in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setEpisodic(char episodic)

getObsDim

public int getObsDim()
Overrides:
getObsDim in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getObsDim()

setObsDim

public void setObsDim(int dim)
Overrides:
setObsDim in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setObsDim(int dim)

getNumDiscreteObsDims

public int getNumDiscreteObsDims()
Overrides:
getNumDiscreteObsDims in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getNumDiscreteObsDims()

setNumDiscreteObsDims

public void setNumDiscreteObsDims(int numDisc)
Overrides:
setNumDiscreteObsDims in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setNumDiscreteObsDims(int numDisc)

getNumContinuousObsDims

public int getNumContinuousObsDims()
Overrides:
getNumContinuousObsDims in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getNumContinuousObsDims()

setNumContinuousObsDims

public void setNumContinuousObsDims(int numCont)
Overrides:
setNumContinuousObsDims in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setNumContinuousObsDims(int numCont)

getObsTypes

public char[] getObsTypes()
Overrides:
getObsTypes in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getObsTypes()

setObsTypes

public void setObsTypes(char[] types)
Overrides:
setObsTypes in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setObsTypes(char[] types)

getObsMins

public double[] getObsMins()
Overrides:
getObsMins in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getObsMins()

setObsMins

public void setObsMins(double[] mins)
Overrides:
setObsMins in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setObsMins(double[] mins)

getObsMaxs

public double[] getObsMaxs()
Overrides:
getObsMaxs in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getObsMaxs()

setObsMaxs

public void setObsMaxs(double[] maxs)
Overrides:
setObsMaxs in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setObsMaxs(double[] maxs)

getActionDim

public int getActionDim()
Overrides:
getActionDim in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getActionDim()

setActionDim

public void setActionDim(int dim)
Overrides:
setActionDim in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setActionDim(int dim)

getNumDiscreteActionDims

public int getNumDiscreteActionDims()
Overrides:
getNumDiscreteActionDims in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getNumDiscreteActionDims()

setNumDiscreteActionDims

public void setNumDiscreteActionDims(int numDisc)
Overrides:
setNumDiscreteActionDims in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setNumDiscreteActionDims(int numDisc)

getNumContinuousActionDims

public int getNumContinuousActionDims()
Overrides:
getNumContinuousActionDims in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getNumContinuousActionDims()

setNumContinuousActionDims

public void setNumContinuousActionDims(int numCont)
Overrides:
setNumContinuousActionDims in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setNumContinuousActionDims(int numCont)

getActionTypes

public char[] getActionTypes()
Overrides:
getActionTypes in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getActionTypes()

setActionTypes

public void setActionTypes(char[] types)
Overrides:
setActionTypes in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setActionTypes(char[] types)

getActionMins

public double[] getActionMins()
Overrides:
getActionMins in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getActionMins()

setActionMins

public void setActionMins(double[] mins)
Overrides:
setActionMins in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setActionMins(double[] mins)

getActionMaxs

public double[] getActionMaxs()
Overrides:
getActionMaxs in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getActionMaxs()

setActionMaxs

public void setActionMaxs(double[] maxs)
Overrides:
setActionMaxs in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setActionMaxs(double[] maxs)

getRewardMax

public double getRewardMax()
Overrides:
getRewardMax in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getRewardMax()

setRewardMax

public void setRewardMax(double max)
Overrides:
setRewardMax in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setRewardMax(double max)

getRewardMin

public double getRewardMin()
Overrides:
getRewardMin in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getRewardMin()

setRewardMin

public void setRewardMin(double min)
Overrides:
setRewardMin in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setRewardMin(double min)

getExtraString

public java.lang.String getExtraString()
Overrides:
getExtraString in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getExtraString()

setExtraString

public void setExtraString(java.lang.String newString)
Overrides:
setExtraString in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#setExtraString(String newString)

getParserVersion

public int getParserVersion()
Overrides:
getParserVersion in class TaskSpecDelegate
See Also:
rlglue.utilities.TaskSpec#getParserVersion()