Class Observations

java.lang.Object
  |
  +--Observations

public class Observations
extends Object

This class implements a set of observations on the truth value of fluents.


Field Summary
static int FALSE
          The fluent is observed to be false.
static int TRUE
          The fluent is observed to be true.
static int UNSPECIFIED
          No observation is available on the fluent.
 
Constructor Summary
Observations(Vector f, int time)
          Constructs a set of observations on the truth value of the given set of fluents at the specified time step.
Observations(Vector f, int time, int defTruth)
          Constructs a set of observations on the truth value of the given set of fluents at the specified time step.
 
Method Summary
 int get(int index)
          Retrieves the observed value for a fluent.
 int get(String fluent)
          Retrieves the observed value for a fluent.
 String getFluent(int index)
          Retrieves the name of the fluent whose index is specified.
 int getSize()
          Returns the number of fluents that can be possibly described by this set of observations.
static int nextVal(int t)
          Returns the next value that can be used for observations, given the current one.
 void set(int index, int truth)
          Sets the observed value of a fluent.
 void set(String fluent, int truth)
          Sets the observed value of a fluent.
 String toAProlog()
          Returns a string containing the A-Prolog representation of the observations.
 void toggle(int index)
          Updates the observed value of a fluent by taking the next value that can be used for observations.
 void toggle(String fluent)
          Updates the observed value of a fluent by taking the next value that can be used for observations.
 String toString()
          Returns a string representation of the observations.
 Vector toVector()
          Returns a Vector containing the representation of the observations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FALSE

public static final int FALSE
The fluent is observed to be false.

TRUE

public static final int TRUE
The fluent is observed to be true.

UNSPECIFIED

public static final int UNSPECIFIED
No observation is available on the fluent.
Constructor Detail

Observations

public Observations(Vector f,
                    int time,
                    int defTruth)
Constructs a set of observations on the truth value of the given set of fluents at the specified time step. All fluents are assigned the specified truth value (UNSPECIFIED can be used to leave all of the unspecified).
Parameters:
f - the set of fluents
time - the time step that observations are about
defTruth - the default truth value

Observations

public Observations(Vector f,
                    int time)
Constructs a set of observations on the truth value of the given set of fluents at the specified time step. All fluents are set as unspecified by default.
Parameters:
f - the set of fluents
time - the time step that observations are about
Method Detail

getSize

public int getSize()
Returns the number of fluents that can be possibly described by this set of observations.
Returns:
the number of fluents

nextVal

public static int nextVal(int t)
Returns the next value that can be used for observations, given the current one. The ordering is:
   ,
 
and the list is cyclic.
Parameters:
t - the current value
Returns:
the next value

toggle

public void toggle(int index)
Updates the observed value of a fluent by taking the next value that can be used for observations. The ordering used is: given the current one. The ordering is:
   ,
 
and the list is cyclic.
Parameters:
index - the index of the fluent

toggle

public void toggle(String fluent)
Updates the observed value of a fluent by taking the next value that can be used for observations. The ordering used is: given the current one. The ordering is:
   ,
 
and the list is cyclic.
Parameters:
fluent - the name of the fluent

get

public int get(int index)
Retrieves the observed value for a fluent. The value is UNSPECIFIED (if no observation is available), TRUE, or FALSE.
Parameters:
index - the index of the fluent
Returns:
the observed value

get

public int get(String fluent)
Retrieves the observed value for a fluent. The value is UNSPECIFIED (if no observation is available), TRUE, or FALSE.
Parameters:
fluent - the name of the fluent
Returns:
the observed value

getFluent

public String getFluent(int index)
Retrieves the name of the fluent whose index is specified.
Parameters:
index - the index of the fluent
Returns:
the name of the fluent

set

public void set(int index,
                int truth)
Sets the observed value of a fluent. The value can be UNSPECIFIED (if no observation is available), TRUE, or FALSE.
Parameters:
index - the index of the fluent
truth - the observed value

set

public void set(String fluent,
                int truth)
Sets the observed value of a fluent. The value can be UNSPECIFIED (if no observation is available), TRUE, or FALSE.
Parameters:
fluent - the name of the fluent
truth - the observed value

toString

public String toString()
Returns a string representation of the observations. Fluents observed true are listed by their name. Fluents observed false are listed with a "-" prefixed to their name. Fluents about which no observation is present are not listed. Elements are separated by a space.
Overrides:
toString in class Object
Returns:
the string representation of the observations

toAProlog

public String toAProlog()
Returns a string containing the A-Prolog representation of the observations. Observations are represented by atoms of the form obs(FL,T), where T is the time step that the observations are about, and FL is either a the name of a fluent, or neg(F) (where F is the name of a fluent). Fluents about which no observation exists do not occur in the string.
Returns:
the string representation of the observations

toVector

public Vector toVector()
Returns a Vector containing the representation of the observations. The elements of the Vector are strings. Each string contains the name of a fluent, a number of spaces, and either "true ", "false", or " ". Spaces are used so that the contents of the Vector can be displayed in columns, and several vectors can be displayed side by side.
Returns:
the Vector representing the observations