Class Occurrences

java.lang.Object
  |
  +--Occurrences

public class Occurrences
extends Object

This class represents a set of observations on the occurrence of actions.


Constructor Summary
Occurrences(Vector a, int time)
          Constructs a set of observations on occurrences of actions for the given time step.
Occurrences(Vector a, int time, boolean defTruth)
          Constructs a set of observations on occurrences of actions for the given time step.
 
Method Summary
 boolean get(int index)
          Returns whether an action has been observed to occur.
 boolean get(String action)
          Returns whether an action has been observed to occur.
 String getAction(int index)
          Returns the name of the action whose index is specified.
 int getSize()
          Returns the number of actions that can be possibly described by these observations.
static boolean nextVal(boolean t)
          Returns true if the parameter is false, and false otherwise.
 void set(int index, boolean truth)
          Sets whether the action was observed to occur.
 void set(String action, boolean truth)
          Sets whether the action was observed to occur.
 String toAProlog()
          Returns a string containing the A-Prolog representation of the observations.
 void toggle(int index)
          Inverts the truth value of an observation.
 void toggle(String action)
          Inverts the truth value of an observation.
 String toString()
          Returns a string representation of the observations.
 Vector toVector()
          Returns a Vector containing the A-Prolog representation of the observations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Occurrences

public Occurrences(Vector a,
                   int time,
                   boolean defTruth)
Constructs a set of observations on occurrences of actions for the given time step. Observations are set to the specified truth value (either true or false).
Parameters:
a - the set of actions that observations are about
time - the step that observations are about
defTruth - the default truth value of observations

Occurrences

public Occurrences(Vector a,
                   int time)
Constructs a set of observations on occurrences of actions for the given time step. By default, all actions are assumed not to have been observed to occur.
Parameters:
a - the set of actions that observations are about
time - the step that observations are about
Method Detail

getSize

public int getSize()
Returns the number of actions that can be possibly described by these observations.
Returns:
the number of actions

nextVal

public static boolean nextVal(boolean t)
Returns true if the parameter is false, and false otherwise.
Parameters:
t - a truth value
Returns:
the opposite truth value

toggle

public void toggle(int index)
Inverts the truth value of an observation.
Parameters:
index - the index of the action to be updated

toggle

public void toggle(String action)
Inverts the truth value of an observation.
Parameters:
action - the name of the action to be updated

get

public boolean get(int index)
Returns whether an action has been observed to occur.
Parameters:
index - the index of the action to be updated
Returns:
true if the action was observed to occur; false otherwise

get

public boolean get(String action)
Returns whether an action has been observed to occur.
Parameters:
action - the name of the action to be updated
Returns:
true if the action was observed to occur; false otherwise

getAction

public String getAction(int index)
Returns the name of the action whose index is specified.
Parameters:
index - the index of the action
Returns:
the name of the action

set

public void set(int index,
                boolean truth)
Sets whether the action was observed to occur.
Parameters:
index - the index of the action
truth - true if the action was observed to occur; false otherwise

set

public void set(String action,
                boolean truth)
Sets whether the action was observed to occur.
Parameters:
action - the name of the action to be updated
truth - true if the action was observed to occur; false otherwise

toString

public String toString()
Returns a string representation of the observations. Only actions observed to occur are listed, and 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. Only actions observed to occur are listed, and are represented by an atom of the form hpd(ACT,T), where T is the time step and ACT is the name of the action
Returns:
the string representation of the observations

toVector

public Vector toVector()
Returns a Vector containing the A-Prolog representation of the observations. The elements of the Vector are strings. Each string contains the name of an action, a number of spaces, and either "true " or "false". 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