Class History

java.lang.Object
  |
  +--History

public class History
extends Object

This class represent a history, i.e. a set of observations about fluents and about occurrences of actions.


Constructor Summary
History(Vector f, Vector a, Vector aa, Vector xa)
          Constructs an empty History with the specified sets of fluents, actions, agent actions, and exogenous actions.
 
Method Summary
 void addTimeStep()
          Adds a new time step to the history.
 Vector getActions()
          Returns the actions that the can be described by the History.
 Vector getAgentActions()
          Returns the agent actions that the can be described by the History.
 int getCurrTime()
          Returns the step of the history which corresponds to the current moment of time.
 Vector getExogenousActions()
          Returns the exugenous action that the can be described by the History.
 Vector getFluents()
          Returns the fluents that the can be described by the History.
 int getNumSteps()
          Returns the number of step contained in the history.
 Observations getObservations()
          Returns the set of observations on fluents for the last time step.
 Observations getObservations(int i)
          Returns the set of observations on fluents for the given step.
 Occurrences getOccurrences()
          Returns the set of observations on actions for the last time step.
 Occurrences getOccurrences(int i)
          Returns the set of observations on actions for the given step.
 void load(InputStream i)
          Fills the History with data loaded from an InputStream.
 void remTimeStep()
          Removes the last time step from the history.
 void reset()
          Removes all observations from the History.
 void setCurrTime(int ct)
          Sets the step of the history which corresponds to the current moment of time.
 void setObservations(int i, Observations f)
          Sets the set of observations on fluents for the given step.
 void setObservations(Observations f)
          Sets the set of observations on fluents for the last time step.
 void setOccurrences(int i, Occurrences a)
          Sets the set of observations on actions for the given step.
 void setOccurrences(Occurrences a)
          Sets the set of observations on actions for the last time step.
 Vector toAProlog()
          Returns a Vector containing the A-Prolog representation of the History.
 void toAProlog(File f)
          Writes to a file the A-Prolog representation of the History.
 void toAProlog(File f, boolean append)
          Writes to a file the A-Prolog representation of the History.
 void toAProlog(String f)
          Writes to a file the A-Prolog representation of the History.
 void toAProlog(String f, boolean append)
          Writes to a file the A-Prolog representation of the History.
 Vector toVector()
          Returns a Vector representing the History.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

History

public History(Vector f,
               Vector a,
               Vector aa,
               Vector xa)
Constructs an empty History with the specified sets of fluents, actions, agent actions, and exogenous actions.
Method Detail

getFluents

public Vector getFluents()
Returns the fluents that the can be described by the History.
Returns:
the fluents that the can be described by the History.

getActions

public Vector getActions()
Returns the actions that the can be described by the History.
Returns:
the actions that the can be described by the History.

getAgentActions

public Vector getAgentActions()
Returns the agent actions that the can be described by the History.
Returns:
the agent actions that the can be described by the History.

getExogenousActions

public Vector getExogenousActions()
Returns the exugenous action that the can be described by the History.
Returns:
the exogenous actions that the can be described by the History.

reset

public void reset()
Removes all observations from the History.

getCurrTime

public int getCurrTime()
Returns the step of the history which corresponds to the current moment of time.
Returns:
the current time step

setCurrTime

public void setCurrTime(int ct)
Sets the step of the history which corresponds to the current moment of time.
Parameters:
ct - the current time step

getNumSteps

public int getNumSteps()
Returns the number of step contained in the history.
Returns:
the number of time step in the history

addTimeStep

public void addTimeStep()
Adds a new time step to the history.

remTimeStep

public void remTimeStep()
Removes the last time step from the history. If the current time step was the last step, the current time step is decreased.


getObservations

public Observations getObservations(int i)
Returns the set of observations on fluents for the given step.
Parameters:
i - the step whose observations must be retrieved
Returns:
the observations on fluents for the time step

getObservations

public Observations getObservations()
Returns the set of observations on fluents for the last time step.
Returns:
the observations on fluents for the time step

getOccurrences

public Occurrences getOccurrences(int i)
Returns the set of observations on actions for the given step.
Parameters:
i - the step whose observations must be retrieved
Returns:
the observations on actions for the time step

getOccurrences

public Occurrences getOccurrences()
Returns the set of observations on actions for the last time step.
Returns:
the observations on actions for the time step

setObservations

public void setObservations(int i,
                            Observations f)
Sets the set of observations on fluents for the given step.
Parameters:
i - the step whose observations must be modified
f - the new observations

setObservations

public void setObservations(Observations f)
Sets the set of observations on fluents for the last time step.
Parameters:
f - the new observations

setOccurrences

public void setOccurrences(int i,
                           Occurrences a)
Sets the set of observations on actions for the given step.
Parameters:
i - the step whose observations must be modified
a - the new observations

setOccurrences

public void setOccurrences(Occurrences a)
Sets the set of observations on actions for the last time step.
Parameters:
a - the new observations

toVector

public Vector toVector()
Returns a Vector representing the History. The elements of the Vector are strings. Every time step is represented by two consecutive elements of the array:
    XXX)*OBS: 
         HPD: 
 
where XXX is the step, and the "*", if present, means that this is the current time step.
Returns:
a Vector representing the History

toAProlog

public Vector toAProlog()
Returns a Vector containing the A-Prolog representation of the History. Each element of the Vector is a string containing either the observations about fluents or the observations about actions for a time step.
Returns:
a Vector representing the History

toAProlog

public void toAProlog(String f,
                      boolean append)
Writes to a file the A-Prolog representation of the History. The representation is either appended to the file, or overwritten to it.
Parameters:
f - the file name
append - true if the representation must be appended; false if the file must be overwritten

toAProlog

public void toAProlog(File f,
                      boolean append)
Writes to a file the A-Prolog representation of the History. The representation is either appended to the file, or overwritten to it.
Parameters:
f - the File object for the file to be written
append - true if the representation must be appended; false if the file must be overwritten

toAProlog

public void toAProlog(String f)
Writes to a file the A-Prolog representation of the History. The file is overwritten.
Parameters:
f - the file name

toAProlog

public void toAProlog(File f)
Writes to a file the A-Prolog representation of the History. The file is overwritten.
Parameters:
f - the File object for the file to be written

load

public void load(InputStream i)
          throws IOException
Fills the History with data loaded from an InputStream. Data are expected to be encoded in A-Prolog, as atoms of the form obs(FL,T) or hpd(FL,T), where T is the step and FL is either a fluent or neg(F) (and F is a fluent).
Parameters:
i - the InputStream from which data are read