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

Package class diagram package EpisodeNode
java.lang.Object
  extended by cz.cuni.amis.pogamut.episodic.episodes.EpisodeNode
All Implemented Interfaces:
Serializable, Comparable<EpisodeNode>

public class EpisodeNode
extends Object
implements Serializable, Comparable<EpisodeNode>

The EpisodeNode is what represents the memory of an action being executed. Episode node is memorized equivalent of Intention, Action or AtomicAction from decision tree.

It can have several subnodes. Node wihout subnodes is an atomic action. Node without parent is a top-level goal. Actions and intentions may have associated affordance slots that have to be filled in order to successfully finish the action.

A tree made of EpisodeNodes is what makes the basis of any Episode.

Author:
Michal Cermak
See Also:
Serialized Form

Field Summary
 boolean finished
          Indicator whether this node was correctly finished.
 boolean succeeded
          Indicator whether this node was successfully finished.
 
Constructor Summary
EpisodeNode(EpisodeNode other, EpisodeNode parent, Episode e)
           
EpisodeNode(String _name, EpisodeNode _parent, Episode _root, Node associated)
          Instantiate the class by providing its name, reference to a parent EpisodeNode, parent Episode and associated decision node.
 
Method Summary
 boolean addChildNode(String name)
          This method adds a new subnode to the list of node's children.
 boolean addChildNode(String name, String time)
           
 void addSlot(String type)
          A method that attaches new affordance slot to the current episodic node.
 double calculateScore()
          Method used to compute new score of a node.
 int compareTo(EpisodeNode o)
          Compares two episode nodes based on the timeStart attribute.
 EpisodeNode createCopy(EpisodeNode parent, Episode e)
           
 void deleteNode()
           
 void deleteNode(boolean skipChecks)
           
 EpisodeNode deriveChildrenAndSlots(Collection<SchemaEpisodeNode> traceSchemaNodes, Collection<SlotContent> schemaContents)
           
 EpisodeNode deriveNodeTrace()
           
 void fillSlot(String type, String item)
          Fills specified slot with a specified item.
 boolean finishNode(String node, ArrayList<String> trace, boolean _succeeded)
          Marks specified episodic node as finished.
 void fullDelete(boolean episodeDeleted)
          Deletes the node and all its subnodes.
 Node getAssociatedNode()
          Getter method for the id variable.
 EpisodeNode getChild(String name)
          Method that returns specified EpisodeNodes that is direct subnode of this node in the episode tree.
 Collection<EpisodeNode> getChildrenNodes()
          Returns all EpisodeNodes that are subnodes of this node in the episode tree.
 Episode getEpisodeRoot()
          Getter method for the root variable.
 Map<Integer,EpisodeNode> getFirstChild()
          Getter method for the firstChild variable.
 int getId()
          Getter method for the id variable.
 String getName()
          Getter method for the name variable.
 int getNumberOfSubNodes()
           
 int getNumberOfSubNodesWithObjects()
           
 ObjectSlot getObjectSlot(String type)
          Method returning one specified objectSlot attached to this episodic node.
 Collection<ObjectSlot> getObjectSlots()
          Getter method for the slots variable.
 EpisodeNode getParent()
          Getter method for the id variable.
 Map<Integer,EpisodeNode> getPredecessor()
          Getter method for the predecessor variable.
 double getScore()
          Getter method for the score variable.
 int getStartTime()
           
 Map<Integer,EpisodeNode> getSuccessor()
          Getter method for the successor variable.
 EpisodeNode mergeWith(EpisodeNode other)
          Merges current node with other node.
 int numberOfCommonSubNodesWithObjects(EpisodeNode other)
          Calculates number of common episodic subnodes and common objects used in slots on these nodes.
 void recalculateTreeSize(boolean validate)
           
 String toString()
          Returns a String object representing this EpisodeNode's info.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

finished

public boolean finished
Indicator whether this node was correctly finished. Node is finished when an agent decides to throw it out of short-term memory, because it was completed or could not be completed.

Nodes in finished episodes can contain unfinished nodes if they were interrupted in an unusual way (top-level goal suddenly disappeared from short-term memory).


succeeded

public boolean succeeded
Indicator whether this node was successfully finished.

Constructor Detail

EpisodeNode

public EpisodeNode(String _name,
                   EpisodeNode _parent,
                   Episode _root,
                   Node associated)
Instantiate the class by providing its name, reference to a parent EpisodeNode, parent Episode and associated decision node.

The ID of a chronobag is also generated in constructor.

Parameters:
_name - Name of the node.
_parent - Reference to parent EpisodeNode.
_root - Reference to parent Episode.
associated - Reference to associated decision node.

EpisodeNode

public EpisodeNode(EpisodeNode other,
                   EpisodeNode parent,
                   Episode e)
Method Detail

toString

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

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

finishNode

public boolean finishNode(String node,
                          ArrayList<String> trace,
                          boolean _succeeded)
Marks specified episodic node as finished. The node has to be in episode subtree represented by current node. Remaining path to the node is stored in a trace parameter. Returns true if node was successfully located.

Parameters:
node - Name of a node that was finished.
trace - Names of traces nodes that lead to the finished node, beginning with child of current node. Should be empty if node to be finished is current node.
succeeded - True if node was finished successfully.
Returns:
Returns true node was successfully located and marked, false otherwise.

getId

public int getId()
Getter method for the id variable.

Returns:
Returns ID of this node. Used as an ID of vertex representing this node when visualizing Chronobag View.

numberOfCommonSubNodesWithObjects

public int numberOfCommonSubNodesWithObjects(EpisodeNode other)
Calculates number of common episodic subnodes and common objects used in slots on these nodes.

Parameters:
other - Root of the other subtree. (This node being root of the first one).
Returns:
Returns count of common nodes and objects.

getName

public String getName()
Getter method for the name variable.

Returns:
Returns name of the intention, action or atomic action that is represented by this node. Same as the name of an associated node.

getParent

public EpisodeNode getParent()
Getter method for the id variable.

Returns:
Returns a reference to a parent EpisodeNode in the episode tree. Only top-level goal (root of an episode) does not have a parent.

getAssociatedNode

public Node getAssociatedNode()
Getter method for the id variable.

Returns:
Returns a reference to equivalent of this node in the decision tree. It is a reference to the node that was chosen to be performed and a way to access the associated SchemaEpisodicNode.

getObjectSlots

public Collection<ObjectSlot> getObjectSlots()
Getter method for the slots variable.

Returns:
Returns a collection of all affordance slots that attached to this node.

getObjectSlot

public ObjectSlot getObjectSlot(String type)
Method returning one specified objectSlot attached to this episodic node.

Returns:
Returns a one specified affordance slots that attached to this node. Returns null if no slot of specified type is attached to this node.

addChildNode

public boolean addChildNode(String name)
This method adds a new subnode to the list of node's children. If such node already exists there, it does nothing. It is responsible for initializing all the necessary variables of a newly created node and of maintaining correct sequence of child nodes of a parent node.

Parameters:
name - Name of a subnode to be added.
Returns:
True if new node was created. False if subnode with such name already existed in the children map.

addChildNode

public boolean addChildNode(String name,
                            String time)

getChild

public EpisodeNode getChild(String name)
Method that returns specified EpisodeNodes that is direct subnode of this node in the episode tree. Node cannot have two children with identical name, so there will not be a conflict between several children.

Parameters:
name - Specifies the name of the subnode to be returned.
Returns:
Returns direct child of this node with specified name, null if there is no such child.

getChildrenNodes

public Collection<EpisodeNode> getChildrenNodes()
Returns all EpisodeNodes that are subnodes of this node in the episode tree. Node without children is an atomic action.

Returns:
A collection of all EpisodeNodes that are direct subnodes of this node.

getEpisodeRoot

public Episode getEpisodeRoot()
Getter method for the root variable.

Returns:
Reference to the Episode structure representing whole episode this node belongs to. Via this reference it is possible to access outer memories.

addSlot

public void addSlot(String type)
A method that attaches new affordance slot to the current episodic node. Slots are indexed by their type, there cannot be two slots of the same type attached to one node, so if the slot of specified type already exists under this node, no new slot is added.

Parameters:
type - String representing the type of the affordance needed to fill the new slot.

fillSlot

public void fillSlot(String type,
                     String item)
Fills specified slot with a specified item. Both ObjectSlot and ObjectNode representing item must be already created when calling this method.

Parameters:
type - String specifying the type of affordance used.
item - Name of an item that will fill the object slot.

getSuccessor

public Map<Integer,EpisodeNode> getSuccessor()
Getter method for the successor variable.

Returns:
Reference to a sibling node (node with same parent) that was executed first after this node. Used to provide the correct temporal sequence of child nodes.

getPredecessor

public Map<Integer,EpisodeNode> getPredecessor()
Getter method for the predecessor variable.

Returns:
Reference to a sibling node (node with same parent) that was executed last before this node. Used to provide the correct temporal sequence of child nodes.

getFirstChild

public Map<Integer,EpisodeNode> getFirstChild()
Getter method for the firstChild variable.

Returns:
Reference to a direct child node that was executed first. Used to provide the correct temporal sequence of child nodes.

getScore

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

Returns:
Returns actual score of a node. Used to determine whether the node can be deleted and forgotten.

calculateScore

public double calculateScore()
Method used to compute new score of a node. Used to determine whether the node can be forgotten.

Returns:
Returns the new score value of this node.

createCopy

public EpisodeNode createCopy(EpisodeNode parent,
                              Episode e)

fullDelete

public void fullDelete(boolean episodeDeleted)
Deletes the node and all its subnodes. Recursively calls delete node on all children and on the node itself.

Parameters:
episodeDeleted - True if this is part of process of deleting an entire episode, False otherwise.

deleteNode

public void deleteNode()

deleteNode

public void deleteNode(boolean skipChecks)

mergeWith

public EpisodeNode mergeWith(EpisodeNode other)
Merges current node with other node. Both nodes must represent same action/goal. New node will be the union of this node and node in parameter. Node in parameter (other node) will be destroyed in the process.

Parameters:
other - Node to be merged to current one. (will be destroyed during process)
Returns:
A reference to the merged node = this, once other node is merged into this one.

deriveNodeTrace

public EpisodeNode deriveNodeTrace()

deriveChildrenAndSlots

public EpisodeNode deriveChildrenAndSlots(Collection<SchemaEpisodeNode> traceSchemaNodes,
                                          Collection<SlotContent> schemaContents)

getNumberOfSubNodes

public int getNumberOfSubNodes()

getNumberOfSubNodesWithObjects

public int getNumberOfSubNodesWithObjects()

getStartTime

public int getStartTime()

compareTo

public int compareTo(EpisodeNode o)
Compares two episode nodes based on the timeStart attribute.

Specified by:
compareTo in interface Comparable<EpisodeNode>

recalculateTreeSize

public void recalculateTreeSize(boolean validate)


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