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

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

public class Chronobag
extends Object
implements Serializable

The Chronobag class is one of the most significant class in this project. It is a collection of episode memories from one time period. Chronobags can consist of episode from one particular day or from a longer time period.

One special instance of this class is a chronobag of episodes from the current day. Any time some action is executed, it is added to this chronobag and then into the current episode.

Each night a new present day chronobag is created and other chronobags are shifted by one day. It is clear, the episodes in chronobags are subjects to forgetting, so as new episodes are created in current day chronobag, episodes in all chronobags can be forgotten each night when the process of forgetting is triggered.

Author:
Michal Cermak
See Also:
Serialized Form

Field Summary
 int id
          ID of this chronobag.
 IdGenerator idGenerator
          A reference to ID generator structure, that will provide the unique IDs to all inside node.
 boolean newNodeAdded
          An indicator whether new node was added into this chronobags since its visualization was last refreshed.
 HashMap<String,ObjectNode> objectNodes
          Map of ObjectNodes remembered by the agent.
 
Constructor Summary
Chronobag(IdGenerator idGen, AgentMemory mem)
          Instantiate the class by providing references to a common ID generator and parent AgentMemory structure.
Chronobag(IdGenerator idGen, AgentMemory _mem, Chronobag last)
          Instantiate the class by providing references to a common ID generator, parent AgentMemory structure and older chronobag of the same level that will be added behind the new chronobag in temporal chain.
 
Method Summary
 boolean addNewNode(String atomicAction, ArrayList<String> trace, ArrayList<AffordanceUsed> affordances)
          This method should be called each time agent executes an atomic action.
 boolean addNewNode(String atomicAction, ArrayList<String> trace, ArrayList<AffordanceUsed> affordances, String time)
           
 double calculateChronobagScore()
          Method used to compute the score of this chronobag based on its current properties and node it consists.
 boolean copyEpisodeToAbstractChronobag(Episode e)
          Creates a copy of specified episode from this chronobag and copies it to the more abstract chronobag.
 Chronobag createMoreAbstractChronobag()
          Creates a chronobag on higher level of time abstraction whose interval will include whole interval of this chronobag.
 ObjectNode createObjectNode(String item)
          Adds new node to the map of ObjectNodes remembered by the agent.
 void decideToForgetNodes()
           
 void deleteChronobag()
           
 void deleteEpisode(Episode e)
           
 void finish()
          Moves all the episodes from current episode list to finished episodes list.
 boolean finishNode(String node, ArrayList<String> trace, boolean succeeded)
          Marks specified episodic node as finished.
 AgeInterval getAge()
          Getter method for the age structure.
 Episode getEpisode(Integer id)
           
 Collection<Episode> getEpisodes()
          Creates and returns a collection of all episodes in a chronobag.
 Episode getFirstEpisode()
          A getter method for the firstEpisode variable.
 Integer getLastEpisodeId()
           
 int getLevel()
          Getter method for the level variable.
 int getMaxNumberOfNodes()
          Getter method for maxNumberOfNodes Maximum number of nodes the chronobag could contain.
 AgentMemory getMemory()
          Getter method for the mem variable.
 Chronobag getMoreAbstractChronobag()
          Returns a chronobag belonging to a higher level of time abstraction chronobags that contains episode from time interval that includes whole time interval of this chronobag
 int getNumberOfEpisodeNodes()
          Getter method for the numberOfEpisodeNodes variable.
 Chronobag getOlderChronobag()
          Getter method for the older variable.
 double getScore()
          Getter method for the score structure.
 Chronobag getYoungerChronobag()
          Getter method for the younger variable.
 void increaseDay()
          Method used to increase the age of a chronobag by one day.
 void increaseMaxNumberOfNodes(Chronobag c)
          Increases the maxNumberOfNodes variable by the number of nodes in a chronobag.
 boolean isLandmark()
          Getter method for the landmark variable.
 void reviewActiveEpisodes(ArrayList<String> list)
           
 String toString()
          Returns a String object representing this Chronobag's info.
 boolean uniteEpisode(Episode e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

idGenerator

public final IdGenerator idGenerator
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).


id

public final int id
ID of this chronobag. Used as an ID of vertex representing this chronobag when visualizing Chronobag View.


newNodeAdded

public boolean newNodeAdded
An indicator whether new node was added into this chronobags since its visualization was last refreshed. Set to true when new node is added. Set to false when the chronobag is redrawed.


objectNodes

public HashMap<String,ObjectNode> objectNodes
Map of ObjectNodes remembered by the agent. This map is shared among the chronobags so it is possible to find all usages of specified object. Object are indexed by their unique name.

In episodes object nodes are connected with the affordance slots they were used in.

Constructor Detail

Chronobag

public Chronobag(IdGenerator idGen,
                 AgentMemory mem)
Instantiate the class by providing references to a common ID generator and parent AgentMemory structure.

The ID of a chronobag is also generated in constructor.

Parameters:
idGen - Reference to common IdGenerator.
mem - Reference to the AgentMemory structure.

Chronobag

public Chronobag(IdGenerator idGen,
                 AgentMemory _mem,
                 Chronobag last)
Instantiate the class by providing references to a common ID generator, parent AgentMemory structure and older chronobag of the same level that will be added behind the new chronobag in temporal chain.

The ID of a chronobag is also generated in constructor.

Parameters:
idGen - refernce to common IdGenerator.
mem - reference to the AgentMemory structure.
last - chronobag of the same level containing episodes preceding those added to this chronobag.
Method Detail

toString

public String toString()
Returns a String object representing this Chronobag's info. It is used to provide detailed information about chronobag when it is invoked from the visualization structures.

Overrides:
toString in class Object
Returns:
a string representation of the value of this object.

getYoungerChronobag

public Chronobag getYoungerChronobag()
Getter method for the younger variable.

Returns:
Return younger chronobag in the list when arranged by their age. Episodes younger chronobag were experienced just after episodes in this chronobag.

Chronobags can appear on different levels of abstraction, e.g. daily chronobags, week chronobags... This points to this next chronobag in the same level of abstraction. Chronobags of other levels forms separate chain of chronobags.


getOlderChronobag

public Chronobag getOlderChronobag()
Getter method for the older variable.

Returns:
Return older chronobag in the list when arranged by their age. Episodes older chronobag were experienced just before episodes in this chronobag.

Chronobags can appear on different levels of abstraction, e.g. daily chronobags, week chronobags... This points to this next chronobag in the same level of abstraction. Chronobags of other levels forms separate chain of chronobags.


getMemory

public AgentMemory getMemory()
Getter method for the mem variable.

Returns:
Returns a reference to the parent AgentMemory structure. It should be possible to access decision tree, schemas or other parts of memory via this reference.

getNumberOfEpisodeNodes

public int getNumberOfEpisodeNodes()
Getter method for the numberOfEpisodeNodes variable.

Returns:
Count the total number of EpisodeNode nodes in the chronobag.

getMoreAbstractChronobag

public Chronobag getMoreAbstractChronobag()
Returns a chronobag belonging to a higher level of time abstraction chronobags that contains episode from time interval that includes whole time interval of this chronobag

Returns:
Returns a reference to a chronobag or null if no such chronobag exists.

createMoreAbstractChronobag

public Chronobag createMoreAbstractChronobag()
Creates a chronobag on higher level of time abstraction whose interval will include whole interval of this chronobag. If such interval already exists, this method only returns it (same as getMoreAbstractChronobag method.

Returns:
Returns a newly created chronobag or the one satisfying requirements if it already existed.

increaseDay

public void increaseDay()
Method used to increase the age of a chronobag by one day. Should be called each night for all the chronobags.

There is no reversal to calling this method - age of chronobags or episodes cannot be decreased.

If age passes landmark threshold, chronobag is also marked as landmark.


getAge

public AgeInterval getAge()
Getter method for the age structure.

Returns:
Class containing information about the age of a chronobag. Age of all episodes in chronobag should fit inside this interval.

getScore

public double getScore()
Getter method for the score structure.

Returns:
Score of a chronobag. It is used to determine how many nodes can be kept in the chronobag after the "forgetting" process.

addNewNode

public boolean addNewNode(String atomicAction,
                          ArrayList<String> trace,
                          ArrayList<AffordanceUsed> affordances)
This method should be called each time agent executes an atomic action. It is the only way to add new EpisodeNodes into the Episodes. It finds (or creates) the current Episode according to the top level goal in trace. And invokes the addNewNode method on that episode while passing it the same parameters.

It is also responsible for maintaining the correct episode sequence within the chronobag.

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)

createObjectNode

public ObjectNode createObjectNode(String item)
Adds new node to the map of ObjectNodes remembered by the agent. This map is shared among the chronobags so it is possible to find all usages of specified object. Object are indexed by their unique name.

New node is not created if it already exists.

Parameters:
item - Unique name of an object.
Returns:
Returns a reference to the ObjectNode representing the item in the parameter.

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 moved from currentEpisodes list to finishedEpisodes list.

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. Should be empty if node itself is top-level goal.
succeeded - True if node was finished successfully.
Returns:
Returns true node was successfully located and marked, false otherwise.

getEpisodes

public Collection<Episode> getEpisodes()
Creates and returns a collection of all episodes in a chronobag. Collection will contain both finished and unfinished episodes.

Returns:
Returns collection of all episodes in this chronobag.

getFirstEpisode

public Episode getFirstEpisode()
A getter method for the firstEpisode variable.

Returns:
Returns a link to the first episode in this chronobag. Used to display episodes in correct sequence when visualizing the chronobag.

getLevel

public int getLevel()
Getter method for the level variable.

Returns:
Returns the level of abstraction of temporal location of chronobag's episodes. Chronobag can contain episodes from single day or from longer time frame (e.g. a week). Level 0 zero means the chronobag is daily chronobag. Higher level means the chronobag contains episodes from longer time period.

calculateChronobagScore

public double calculateChronobagScore()
Method used to compute the score of this chronobag based on its current properties and node it consists. It represents overall attractiveness of the chronobag.

Returns:
Returns the new score value.

copyEpisodeToAbstractChronobag

public boolean copyEpisodeToAbstractChronobag(Episode e)
Creates a copy of specified episode from this chronobag and copies it to the more abstract chronobag. Episode can be copied to more abstract chronobag only once. Order of episodes in more abstract chronobag is maintained based on episode IDs that are generated in an ascending way.

Parameters:
e - Episode to be copied.
Returns:
Returns true if episode was copied successfully, returns false otherwise.

isLandmark

public boolean isLandmark()
Getter method for the landmark variable.

Returns:
Returns true if chronobag is old enough to pass a landmark threshold. No episodes are forgotten from landmark episodes.

finish

public void finish()
Moves all the episodes from current episode list to finished episodes list. Called at the end the day for present chronobag.


decideToForgetNodes

public void decideToForgetNodes()

reviewActiveEpisodes

public void reviewActiveEpisodes(ArrayList<String> list)

uniteEpisode

public boolean uniteEpisode(Episode e)

deleteEpisode

public void deleteEpisode(Episode e)

deleteChronobag

public void deleteChronobag()

getMaxNumberOfNodes

public int getMaxNumberOfNodes()
Getter method for maxNumberOfNodes Maximum number of nodes the chronobag could contain. For daily chronobags it is calculated before first forgetting process is triggered. For abstract chronobags it is sum of daily values from daily chronobags covering the same time period

Returns:
Returns value of maxNumberOfNodes variable.

increaseMaxNumberOfNodes

public void increaseMaxNumberOfNodes(Chronobag c)
Increases the maxNumberOfNodes variable by the number of nodes in a chronobag. maxNumberOfNodes is initially zero and it increase only via this method. For daily chronobags it should be called just once just before forgetting process is triggered for the first time as the chronobag is no longer the present chronobag. For abstract chronobag it is called once for each daily chronobag whose age belongs to the age period of abstract chronobag.

Parameters:
c - Daily chronobag whose actual number of nodes will be added to the maximum number of nodes for this chronobag.

getLastEpisodeId

public Integer getLastEpisodeId()

getEpisode

public Episode getEpisode(Integer id)


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