cz.cuni.amis.pogamut.episodic.memory
Class AgentMemory

Package class diagram package AgentMemory
java.lang.Object
  extended by cz.cuni.amis.pogamut.episodic.memory.AgentMemory
All Implemented Interfaces:
IAgentMemory, Serializable

public class AgentMemory
extends Object
implements IAgentMemory, Serializable

AgentMemory is the main class of this project and integrates all the information agent remembers. Its main parts are: decision tree mirroring the decision nodes from pogamut end project, chronobags containing memories of episodes group together on temporal basis and schemas integrating all the episodes experienced by an agent into the average episodes.

Before agent memory can be used, it needs to be initialized by providing the content of the decision tree. Then each time agent performs an action new nodes are added into the memory structures. Memory nodes are forgotten during the reorganization process that is triggered once a day when the agent goes to sleep.

Author:
Michal Cermak
See Also:
Serialized Form

Field Summary
 Semaphore sem
           
static boolean visualize
          Parameter determining if the visualization components should be displayed while agent's memory is running.
 
Constructor Summary
AgentMemory()
           
 
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, String time, ArrayList<AffordanceUsed> affordances)
          This method should be called each time agent executes an atomic action.
 void addVisualizationListener(IVisualizationListener listener)
           
 void fireVisualizationEvent(VisualizationEvent event)
           
 void generateStatistics(String fileName)
          Generates a csv file with information how different goals were satisfied.
 Collection<Chronobag> getChronobags()
           
 Map<Integer,Chronobag> getChronobagSequenceEnds()
           
 DecisionTree getDecisionTree()
          Getter method for the decisionTree.
 IdGenerator getIdGenerator()
           
 Integer getLastEpisodeId()
           
 HashSet<Chronobag> getPastChrononags()
           
 Chronobag getPresentChronobag()
           
 SchemaBag getSchemaBag()
           
 void initialize(Collection<Intention> topLevelGoals)
          Creates the decision tree structure based on the trees representing decision plans for top-level goals received in a parameter.
 void initVisualizers()
           
 boolean nodeFinished(String node, ArrayList<String> trace, boolean succeeded)
          Marks specified episodic node as finished.
 void registerNewPastChronobag(Chronobag c)
          Each time new past chronobag is created it has to be added to the set of all past chronobags.
 void removeVisualizationListener(IVisualizationListener listener)
           
 void reviewActiveIntentions(ArrayList<String> list)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sem

public Semaphore sem

visualize

public static boolean visualize
Parameter determining if the visualization components should be displayed while agent's memory is running.

Constructor Detail

AgentMemory

public AgentMemory()
Method Detail

addVisualizationListener

public void addVisualizationListener(IVisualizationListener listener)

removeVisualizationListener

public void removeVisualizationListener(IVisualizationListener listener)

fireVisualizationEvent

public void fireVisualizationEvent(VisualizationEvent event)

getDecisionTree

public DecisionTree getDecisionTree()
Getter method for the decisionTree.

Returns:
Returns the reference to DecisionTree structure in agent's memory.

getIdGenerator

public IdGenerator getIdGenerator()

initialize

public void initialize(Collection<Intention> topLevelGoals)
Creates the decision tree structure based on the trees representing decision plans for top-level goals received in a parameter. IDs for all the nodes in new decision trees are created and visualization structures are also initialized.

Specified by:
initialize in interface IAgentMemory
Parameters:
topLevelGoals - List of Intention structures representing possible top-level goals of agent. They are roots of already complete trees consisting of intentions, actions and atomic actions.

initVisualizers

public void initVisualizers()

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 Episode. It invokes the equivalent method in current chronobag and pass it all the parameters, then 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.

Specified by:
addNewNode in interface IAgentMemory
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,
                          String time,
                          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 invokes the equivalent method in current chronobag and pass it all the parameters, then 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.

In case agent has started the sleep action for the first time in a day memory reorganization process is also triggered.

All visualizations are refreshed according to new contents of agent's memory.

Parameters:
atomicAction - Name of an atomic action that was executed.
trace - List of names of decision nodes that lead to the atomic action executed. Parent of atomic action is first in the list and top-level goal is last item in the list.
time - String containing information about the time of execution of the atomic action. Its format should be: "Fr, 03:44, day 12."
affordances - List of AffordanceUsed objects. Each object represent one filled affordance slot that was needed for the execution of current atomic action.

nodeFinished

public boolean nodeFinished(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 of current chronobags 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.

registerNewPastChronobag

public void registerNewPastChronobag(Chronobag c)
Each time new past chronobag is created it has to be added to the set of all past chronobags. This method does so and it is also responsible for updating the pastSequenceEnds references.

Parameters:
c - Reference to the newly created chronobag.

getSchemaBag

public SchemaBag getSchemaBag()

reviewActiveIntentions

public void reviewActiveIntentions(ArrayList<String> list)

getChronobags

public Collection<Chronobag> getChronobags()

getChronobagSequenceEnds

public Map<Integer,Chronobag> getChronobagSequenceEnds()

getPresentChronobag

public Chronobag getPresentChronobag()

getPastChrononags

public HashSet<Chronobag> getPastChrononags()

generateStatistics

public void generateStatistics(String fileName)
Generates a csv file with information how different goals were satisfied. Generated data is based on the actual events from the simulation. All actions performed to satisfy certain goal are assigned percentages providing distribution how often the goal was satisfied with each action.


getLastEpisodeId

public Integer getLastEpisodeId()


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