cz.cuni.amis.pogamut.episodic.episodes
Class Episode

Package class diagram package Episode
java.lang.Object
  extended by cz.cuni.amis.pogamut.episodic.episodes.Episode
All Implemented Interfaces:
Serializable

public class Episode
extends Object
implements Serializable

The Episode class represents one episode experienced by an agent. It can be pictured as customized tree structure consisting of EpisodeNodes and more. It has a root node and that represents top-level goal. Its child is actions performed to achieve that goal, its children are goals needed to perform that action etc. In the leaves of the tree are nodes representing atomic actions. Moreover actions and intentions can have several affordance slots that need to be filled by applicable ObjectNodes.

Episode is open until it dissappears from agent's short-term memory. Once it is finished no nodes should be added into it, nodes should only be forgotten.

Author:
Michal Cermak
See Also:
Serialized Form

Field Summary
 boolean deleted
          When last of episode nodes (root) of this episode is deleted.
 boolean finished
          An indicator whether the episode was finished.
 int idEpisode
          This ID is different than other node IDs in memory. This is not used for visualize purposes.
 IdGenerator idGen
          A reference to ID generator structure, that will provide the unique IDs to all inside node.
 AgentMemory mem
           
 ArrayList<Episode> next
          The next field links Episodes of a chronobag in order they were executed.
 ArrayList<Episode> previous
          The previous field contains Episodes of a chronobag that were executed just before this episode.
 
Constructor Summary
Episode(Chronobag parent)
          Instantiate the class by providing reference to a parent Chronobag.
Episode(Episode other)
          Instantiate the class by providing reference to an already instantiated Episode.
 
Method Summary
 boolean addNewNode(String atomicAction, ArrayList<String> trace, ArrayList<AffordanceUsed> affordances)
          This method should be called for current episode each time agent executes an atomic action.
 boolean addNewNode(String atomicAction, ArrayList<String> trace, ArrayList<AffordanceUsed> affordances, String time)
           
 double calculateCopyScore()
           
 Episode createCopy(Chronobag c)
          Creates a copy of the episode structure.
 Episode deriveEpisode()
           
 double episodeSimilarity(Episode other)
          Calculates the similarity of two episodes.
 boolean finishNode(String node, ArrayList<String> trace, boolean succeeded)
          Marks specified episodic node as finished.
 boolean getCopied()
          A getter method for the copied variable.
 double getCopyScore()
          A getter method for the copyScore variable.
 int getIdEpisode()
          Getter method for the episode id.
 Chronobag getParentChronobag()
          Getter method for the parentChronobag variable.
 EpisodeNode getRoot()
          Getter method for the root variable.
 boolean mergeWith(Episode other)
           
 boolean setCopied()
          Sets the copied indicator to True
 boolean setParentChronobag(Chronobag c)
          Sets the reference to parent chronobag unless it was set before.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

finished

public boolean finished
An indicator whether the episode was finished. All episodes are created as not finished. It is finished when its top-level goal is finished.

Episode can be transferred into finishedEpisodes list in a chronobag even when it is not finished. This happens to all episodes that had to be interrupted because agent went to sleep at the end of a day. But once it is finished, it cannot appear in the currentEpisodes list in a chronobag.


idEpisode

public final int idEpisode
This ID is different than other node IDs in memory. This is not used for visualize purposes. It is used to determine when two episodes in different chronobags are copies of one episode and when they are both unique episodes.


idGen

public final IdGenerator idGen
A reference to ID generator structure, that will provide the unique IDs to all inside node. This unique IDs are mostly needed when identifying the visualized vertices (because nodes can have identical names).


deleted

public boolean deleted
When last of episode nodes (root) of this episode is deleted. It sets this flag to true and it means whole episode should be deleted.


next

public ArrayList<Episode> next
The next field links Episodes of a chronobag in order they were executed. It contains episodes executed just after current episode.

If episode was interrupted it can have more than one successor. Episodes in next list are ordered in order they were executed - first interruptions are at the beginning, final successor is at the end.


previous

public ArrayList<Episode> previous
The previous field contains Episodes of a chronobag that were executed just before this episode.

If episode was interrupted it can have more than one predecessor. Episodes in next list are ordered in reverse order than they were executed - first predecessors are at the end, last interruption is at the beginning.


mem

public final AgentMemory mem
Constructor Detail

Episode

public Episode(Chronobag parent)
Instantiate the class by providing reference to a parent Chronobag.

Make sure episode is also added to the episodes of the parent chronobag - to the currentEpisodes list.

Parameters:
parent - reference to the parent Chronobag structure.

Episode

public Episode(Episode other)
Instantiate the class by providing reference to an already instantiated Episode. This can be used to create episode copies with identical episode IDs.

Make sure episode is also added to the episodes of the parent chronobag - to the currentEpisodes list.

Parameters:
other - reference to instantiated Episode structure.
Method Detail

addNewNode

public boolean addNewNode(String atomicAction,
                          ArrayList<String> trace,
                          ArrayList<AffordanceUsed> affordances)
This method should be called for current episode each time agent executes an atomic action. It is the only way to add new EpisodeNodes into the Episode. If episode was just started it is responsible for creating the root node. It then makes sure all trace nodes, node representing current atomic action, slots and objects used are created.

Parameters:
atomicAction - Name of an atomic action that was executed.
trace - List of names of decision nodes that lead to the atomic action executed. The top-level goal is first in the list and parent of atomic action is last item in the list.
affordances - List of AffordanceUsed objects. Each object represent one filled affordance slot that was needed for the execution of current atomic action.

addNewNode

public boolean addNewNode(String atomicAction,
                          ArrayList<String> trace,
                          ArrayList<AffordanceUsed> affordances,
                          String time)

finishNode

public boolean finishNode(String node,
                          ArrayList<String> trace,
                          boolean succeeded)
Marks specified episodic node as finished. If the root node of an episode is marked as finished, whole episode is marked as finished.

Parameters:
node - Name of a node that was finished.
trace - Names of traces nodes that lead to the finished node, beginning with top-level goal and ending with node's parent. Cannot be empty.
succeeded - True if node was finished successfully.
Returns:
Returns true node was successfully located and marked, false otherwise.

getParentChronobag

public Chronobag getParentChronobag()
Getter method for the parentChronobag variable.

Returns:
Returns a reference to the Chronobag this episode belongs to. The age of an episode has to be deduced from the age of its parent chronobag.

setParentChronobag

public boolean setParentChronobag(Chronobag c)
Sets the reference to parent chronobag unless it was set before.

Parameters:
c - Reference to the parent chronobag.
Returns:
Return true if new refernce was set, returns false if reference was set before.

getRoot

public EpisodeNode getRoot()
Getter method for the root variable.

Returns:
Returns the EpisodeNode representing top-level goal of this episode (root of episode tree).

episodeSimilarity

public double episodeSimilarity(Episode other)
Calculates the similarity of two episodes. Episodes are more similar when have more common nodes. In order to be identical (similarity = 1) all episode nodes have to be the same and all slots have to be filled with identical objects. If the top level goals are not identical, the similarity is always 0.

Parameters:
other - Reference to the episode that should be compared with the current one.
Returns:
Returns number between 0 and 1. 1 means episodes are identical.

createCopy

public Episode createCopy(Chronobag c)
Creates a copy of the episode structure. This method is called when episode is suppossed to be copied to more abstract chronobag. All the episode nodes are new unique IDs. Episode ID stays the same. Episode does not have parent chronobag yet.

Returns:
Returns a copy of this episode.

setCopied

public boolean setCopied()
Sets the copied indicator to True

Returns:
Return true if indicator was set to true now, returns false if indicator was set to true before.

getCopied

public boolean getCopied()
A getter method for the copied variable.

Returns:
Returns an indicator telling if the episode was already copied to more abstract chronobag. Each episode can be copied only once.

getCopyScore

public double getCopyScore()
A getter method for the copyScore variable.

Returns:
Returns a score of an episode that is used to determine whether it should be copied to more abstract chronobag. Once the value passes given threshold, episode copy is created and added to more abstract chronobag.

Returns -1 if episode was already copied.


calculateCopyScore

public double calculateCopyScore()

getIdEpisode

public int getIdEpisode()
Getter method for the episode id. Not used for visualization purposes. Used to determine when two episodes were created as copies.

Returns:
Returns ID of an episode.

mergeWith

public boolean mergeWith(Episode other)

deriveEpisode

public Episode deriveEpisode()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.