cz.cuni.amis.pogamut.episodic.schemas
Class SchemaBag

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

public class SchemaBag
extends Object
implements Serializable

The SchemaBag is one of the important classes when it comes to agent's memories. It does not hold any particular episode, insteas it is responsible for creating an average episodes, so called schemas. It accumullates all different experiences instances of one episode into one aggregated schema. Apart from the capability to retrieve universal episodes it gives us a way how to tell what sub-episodes happen more often that others and it helps us to more efficiently store the concrete episodes by providing a way to derive some of the nodes from what is only a part of complete episode tree.

Schemabag consist of SchemaEpisodeNodes which are equivalent to EpisodeNodes and SchemaObjectNodes which are equivalent to ObjectNodes. Counters are kept for number of experiences containing particular nodes and for all set of nodes up to specified size. Theses SchemaCounters are kept in SchemaBag and indexed in a way that it is always fast to find all the counters representing subsets or supersets of a set of nodes represented by a specified counter.

Author:
Michal Cermak
See Also:
Serialized Form

Nested Class Summary
 class SchemaBag.SchemaMessageCommand
          Because counters in the schemabag are updated more often than the individual nodes, it is convenient not to redraw all whole schemabag visualization each time they are increased.
 
Field Summary
 int id
          ID of the schemabag.
 SchemaBag.SchemaMessageCommand schemaMessageCommand
          Instantion of a SchemaMessageCommand class that is passed to visualizer so that it can recieve up to date information about SchemaCounters.
 
Constructor Summary
SchemaBag(IdGenerator idGen, AgentMemory mem)
          Instantiate the class by providing references to a common ID generator and parent AgentMemory structure.
 
Method Summary
 void generateStatistics(String fileName)
           
 Collection<SchemaCounter> getAllExistingSubSets(Collection<SchemaEpisodeNode> schemaNodes, Collection<SlotContent> objectNodes, int maxSize)
           
 Integer getCount(Collection<SchemaEpisodeNode> schemaNodes, Collection<SlotContent> objectNodes)
          Retrieve the current total count of collective appearences of a set of specified schema nodes.
 SchemaCounter getCounter(Collection<SchemaEpisodeNode> schemaNodes, Collection<SlotContent> objectNodes, int maxCombination)
          Retrieve the counter representing total count of collective appearences of a set of specified schema nodes.
 int getNumberOfNodes()
          Getter method for the numberOfNodes variable.
 SchemaEpisodeNode getSchemaENode(String name)
          Method used to return a single SchemaEpisodicNode.
 Collection<SchemaEpisodeNode> getSchemaENodes()
          Basically a getter method for the schemaENodes variable.
 Collection<SchemaObjectNode> getSchemaONodes()
          Basically a getter method for the schemaONodes variable.
 String toString()
          Returns a String object representing the SchemaBag's info.
 void updateSchema(String atomicAction, ArrayList<String> trace, ArrayList<AffordanceUsed> affordances)
          The main method of SchemaBag is the updateSchema method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

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


schemaMessageCommand

public SchemaBag.SchemaMessageCommand schemaMessageCommand
Instantion of a SchemaMessageCommand class that is passed to visualizer so that it can recieve up to date information about SchemaCounters.

See Also:
SchemaBag.SchemaMessageCommand
Constructor Detail

SchemaBag

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

The ID of the schemabag is also generated in constructor.

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

toString

public String toString()
Returns a String object representing the SchemaBag's info. It is used to provide detailed information about schemabag when it is invoked from the visualizion structures.

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

getNumberOfNodes

public int getNumberOfNodes()
Getter method for the numberOfNodes variable.

Returns:
Returns the count the total number of nodes in the schemabag. Used mostly to determine whether there was new node added since last refresh of schemabag visualization, so that it can be redrawed.

getSchemaENode

public SchemaEpisodeNode getSchemaENode(String name)
Method used to return a single SchemaEpisodicNode. Schema episodic nodes are indexed by IDs of associated decision nodes.

Returns:
Returns a SchemaEpisodicNode specified by the id in paremeter.

getSchemaENodes

public Collection<SchemaEpisodeNode> getSchemaENodes()
Basically a getter method for the schemaENodes variable.

Returns:
Returns a collection of all SchemaEpisodicNodes in the SchemaBag.

getSchemaONodes

public Collection<SchemaObjectNode> getSchemaONodes()
Basically a getter method for the schemaONodes variable.

Returns:
Returns a collection of all SchemaObjectNodes in the SchemaBag.

getCount

public Integer getCount(Collection<SchemaEpisodeNode> schemaNodes,
                        Collection<SlotContent> objectNodes)
Retrieve the current total count of collective appearences of a set of specified schema nodes.

Parameters:
schemaNodes - Set of SchemaEpisodeNodes of the counter.
objectNodes - Set of SlotContents of the counter.
Returns:
Returns the total count of collective appearences of specified nodes. If no counter for specified set of nodes exists in schemabag, it means there is too much nodes in the set or that no counter was created because the specified nodes did not appear collectively in short-term memory when performing agent's action. Based on the reason the method returns either null when the set of nodes can never contribute to one counter or zero when the set of nodes did not happen collectively yet.

getCounter

public SchemaCounter getCounter(Collection<SchemaEpisodeNode> schemaNodes,
                                Collection<SlotContent> objectNodes,
                                int maxCombination)
Retrieve the counter representing total count of collective appearences of a set of specified schema nodes.

Parameters:
schemaNodes - Set of SchemaEpisodeNodes of the counter.
objectNodes - Set of SlotContents of the counter.
Returns:
Returns the reference to a SchemaCounter representing count of collective appearences of specified nodes. If no counter for specified set of nodes exists in schemabag, it means there is too much nodes in the set or that no counter was created because the specified nodes did not appear collectively in short-term memory when performing agent's action. Based on the reason the method returns either null when the set of nodes can never contribute to one counter or zero when the set of nodes did not happen collectively yet.

getAllExistingSubSets

public Collection<SchemaCounter> getAllExistingSubSets(Collection<SchemaEpisodeNode> schemaNodes,
                                                       Collection<SlotContent> objectNodes,
                                                       int maxSize)

updateSchema

public void updateSchema(String atomicAction,
                         ArrayList<String> trace,
                         ArrayList<AffordanceUsed> affordances)
The main method of SchemaBag is the updateSchema method. It is the only method that should be called from outside structures apart from the getter methods. Calling this method ensures all necessary schema information are added to the memory.

Parameters are the same as the ones that are used to call addNewNode method in AgentMemory. They specifies the atomic action that was executed and its trace nodes and all the affordances used on the trace nodes.

With the use of associated decision nodes this method locates all the SchemaEpisodeNodes that were in short-term memory during the execution of atomic action and it slot locates all necessary SlotContent nodes for all the items that were used. When both sets of nodes are aquired, increaseCounts method is called ensuring all necessary counts will be updated.

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.

generateStatistics

public void generateStatistics(String fileName)


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