Java 2 Platform
v1.3

edu.umich.visualsoar.datamap
Class SoarWorkingMemoryModel

java.lang.Object
  |
  +--edu.umich.visualsoar.datamap.SoarWorkingMemoryModel

public class SoarWorkingMemoryModel
extends java.lang.Object

This is a model of Soar's Working Memory represented by a directed graph structure


Field Summary
private  java.util.LinkedList listeners
           
private  java.util.Map properties
           
private  edu.umich.visualsoar.graph.DirectedGraph rep
           
 
Constructor Summary
SoarWorkingMemoryModel(boolean isNew, java.lang.String name)
          Creates a default model of working memory
 
Method Summary
 void addProperty(java.lang.String name, edu.umich.visualsoar.graph.SoarVertex sv)
           
 void addTriple(edu.umich.visualsoar.graph.SoarVertex v0, java.lang.String attribute, edu.umich.visualsoar.graph.SoarVertex v1)
          Adds a triple to working memory
 void addTriple(edu.umich.visualsoar.graph.SoarVertex v0, java.lang.String attribute, edu.umich.visualsoar.graph.SoarVertex v1, boolean generated, edu.umich.visualsoar.operatorwindow.OperatorNode current, int lineNumber)
          Adds a triple to working memory Also denotes that this triple was created by the automatic DataMap generator.
 void addTriple(edu.umich.visualsoar.graph.SoarVertex v0, java.lang.String attribute, edu.umich.visualsoar.graph.SoarVertex v1, int generated, java.lang.String comment)
          Adds a triple to working memory Also sets a comment to the edge that the triple creates.
 void addVertex(edu.umich.visualsoar.graph.Vertex v)
          This is only needed by the reader, in the future this will only be package accessible regular users should go through the factory create methods
 void addWorkingMemoryListener(edu.umich.visualsoar.datamap.WorkingMemoryListener l)
          Adds a listener to working memory, to receive working memory events
 void changeProperty(java.lang.String name, edu.umich.visualsoar.graph.SoarVertex value)
           
 java.util.List checkGenerateProduction(edu.umich.visualsoar.graph.SoarIdentifierVertex sv, edu.umich.visualsoar.parser.SoarProduction sp, edu.umich.visualsoar.operatorwindow.OperatorNode current)
          Used by the Generate Productions actions to look for holes in Working Memory and fix those holes.
 java.util.List checkProduction(edu.umich.visualsoar.graph.SoarIdentifierVertex sv, edu.umich.visualsoar.parser.SoarProduction sp)
          Used to determine if a soar production matches Working Memory
 java.util.List checkProductionLog(edu.umich.visualsoar.graph.SoarIdentifierVertex sv, edu.umich.visualsoar.parser.SoarProduction sp, java.io.FileWriter fw)
          Used to determine if a soar production matches Working Memory This function will also generate a log file to keep track of production checking
 edu.umich.visualsoar.graph.EnumerationVertex createNewEnumeration(java.lang.String s)
          Create a new EnumerationVertex with a string that represents the only acceptable value for that enumeration
 edu.umich.visualsoar.graph.EnumerationVertex createNewEnumeration(java.util.Vector s)
          Create a new EnumerationVertex with a vector of strings that represent possible values for that enumeration
 edu.umich.visualsoar.graph.FloatRangeVertex createNewFloat()
          Create Float Vertex with default (unbounded) range
 edu.umich.visualsoar.graph.FloatRangeVertex createNewFloatRange(float low, float high)
          Create Float Vertex with specified range
 edu.umich.visualsoar.graph.IntegerRangeVertex createNewInteger()
          Create Integer Vertex with default (unbounded) range
 edu.umich.visualsoar.graph.IntegerRangeVertex createNewIntegerRange(int low, int high)
          Create Integer Vertex with specified range
 edu.umich.visualsoar.graph.SoarIdentifierVertex createNewSoarId()
          Create a basic soar Identifier Vertex
 edu.umich.visualsoar.graph.SoarIdentifierVertex createNewStateId(edu.umich.visualsoar.graph.SoarIdentifierVertex superstate, java.lang.String name)
          Called to create the Vertex and appropriate identifiers for a high-level operator
 edu.umich.visualsoar.graph.StringVertex createNewString()
          Create a StringVertex attribute
 edu.umich.visualsoar.graph.SoarVertex createVertexCopy(edu.umich.visualsoar.graph.SoarVertex orig)
          Returns an exact copy of a SoarVertex with a new id
 java.util.Enumeration emanatingEdges(edu.umich.visualsoar.graph.Vertex v)
          Returns an enumeration of all the edges that are emanating/leaving from a particular vertex.
 java.util.Set getEntrySet()
           
 java.util.Enumeration getIncidentEdges(edu.umich.visualsoar.graph.Vertex v)
           
 edu.umich.visualsoar.graph.SoarVertex getMatchingParent(edu.umich.visualsoar.graph.SoarVertex sv)
           
protected  int getNextVertexId()
          Each Vertex in Working Memory has a unique ID, function returns the next available Vertex ID
 int getNumberOfVertices()
          Returns the number of vertices in Working Memory
 java.util.List getParents(edu.umich.visualsoar.graph.SoarVertex sv)
          Return all parents of a vertex
 edu.umich.visualsoar.graph.SoarVertex getProperty(java.lang.String name)
           
 edu.umich.visualsoar.graph.SoarIdentifierVertex getTopstate()
           
 edu.umich.visualsoar.graph.SoarVertex getVertexForId(int i)
          For a particular id, returns the corresponding soar vertex
 java.util.List matches(edu.umich.visualsoar.graph.SoarIdentifierVertex sv, edu.umich.visualsoar.parser.SoarProduction sp, java.lang.String variable)
          Function finds the set of variables within a productions that matches a given string
protected  void notifyListenersOfAdd(edu.umich.visualsoar.graph.NamedEdge ne)
          Notifies the listeners to refresh the screen
protected  void notifyListenersOfRemove(edu.umich.visualsoar.graph.NamedEdge ne)
          Notifies the listeners to refresh the screen
 int numberOfEdges()
          Returns the total number of edges contained in working memory
 int numberOfVertices()
          Returns the number of vertices contained in working memory
 void reduce(java.util.List startVertices)
           
 void removeProperty(java.lang.String name)
           
 void removeTriple(edu.umich.visualsoar.graph.SoarVertex v0, java.lang.String attribute, edu.umich.visualsoar.graph.SoarVertex v1)
          Removes the requested triple from Working Memory
 void removeWorkingMemoryListener(edu.umich.visualsoar.datamap.WorkingMemoryListener l)
          removes a listener from working memory, to make it stop receiving working memory events
 void resolve()
           
 void setTopstate(edu.umich.visualsoar.graph.SoarIdentifierVertex siv)
          This sets the topstate, this should only be called by trusted members
 void write(java.io.Writer graphWriter)
          Writes out information for the datamap file (.dm file) .dm datamap file is in the format of: number of vertices
write out all vertices:    |vertex type|    |vertex id int|    |number of enumerations|    |enumeration strings .....|
number of edges
write out all edges:    | left vertex |    |name of edge|    |right vertex|
 void writeComments(java.io.Writer commentWriter)
          Writes all of the edge comments to the writer to create the comment file and whether a datamap entry is generated or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rep

private edu.umich.visualsoar.graph.DirectedGraph rep

listeners

private java.util.LinkedList listeners

properties

private java.util.Map properties
Constructor Detail

SoarWorkingMemoryModel

public SoarWorkingMemoryModel(boolean isNew,
                              java.lang.String name)
Creates a default model of working memory

Parameters:
isNew - only create if model is new
name - name used for the topstate
See Also:
addTriple(SoarVertex,String,SoarVertex), addProperty(String,SoarVertex)
Method Detail

addProperty

public void addProperty(java.lang.String name,
                        edu.umich.visualsoar.graph.SoarVertex sv)

changeProperty

public void changeProperty(java.lang.String name,
                           edu.umich.visualsoar.graph.SoarVertex value)

getProperty

public edu.umich.visualsoar.graph.SoarVertex getProperty(java.lang.String name)

removeProperty

public void removeProperty(java.lang.String name)

getEntrySet

public java.util.Set getEntrySet()

setTopstate

public void setTopstate(edu.umich.visualsoar.graph.SoarIdentifierVertex siv)
This sets the topstate, this should only be called by trusted members


getVertexForId

public edu.umich.visualsoar.graph.SoarVertex getVertexForId(int i)
For a particular id, returns the corresponding soar vertex


addWorkingMemoryListener

public void addWorkingMemoryListener(edu.umich.visualsoar.datamap.WorkingMemoryListener l)
Adds a listener to working memory, to receive working memory events


removeWorkingMemoryListener

public void removeWorkingMemoryListener(edu.umich.visualsoar.datamap.WorkingMemoryListener l)
removes a listener from working memory, to make it stop receiving working memory events


addTriple

public void addTriple(edu.umich.visualsoar.graph.SoarVertex v0,
                      java.lang.String attribute,
                      edu.umich.visualsoar.graph.SoarVertex v1)
Adds a triple to working memory


addTriple

public void addTriple(edu.umich.visualsoar.graph.SoarVertex v0,
                      java.lang.String attribute,
                      edu.umich.visualsoar.graph.SoarVertex v1,
                      int generated,
                      java.lang.String comment)
Adds a triple to working memory Also sets a comment to the edge that the triple creates. This comment is read in by the SoarWorkingMemoryReader when the .dm file is loaded


addTriple

public void addTriple(edu.umich.visualsoar.graph.SoarVertex v0,
                      java.lang.String attribute,
                      edu.umich.visualsoar.graph.SoarVertex v1,
                      boolean generated,
                      edu.umich.visualsoar.operatorwindow.OperatorNode current,
                      int lineNumber)
Adds a triple to working memory Also denotes that this triple was created by the automatic DataMap generator. This will cause the dataMap entry of this triple to show up as colored text until the entry is validated by the user as acceptable.


getTopstate

public edu.umich.visualsoar.graph.SoarIdentifierVertex getTopstate()

emanatingEdges

public java.util.Enumeration emanatingEdges(edu.umich.visualsoar.graph.Vertex v)
Returns an enumeration of all the edges that are emanating/leaving from a particular vertex.

See Also:
NamedEdge

getIncidentEdges

public java.util.Enumeration getIncidentEdges(edu.umich.visualsoar.graph.Vertex v)

numberOfVertices

public int numberOfVertices()
Returns the number of vertices contained in working memory

See Also:
SoarVertex

numberOfEdges

public int numberOfEdges()
Returns the total number of edges contained in working memory

See Also:
NamedEdge

addVertex

public void addVertex(edu.umich.visualsoar.graph.Vertex v)
This is only needed by the reader, in the future this will only be package accessible regular users should go through the factory create methods


reduce

public void reduce(java.util.List startVertices)

removeTriple

public void removeTriple(edu.umich.visualsoar.graph.SoarVertex v0,
                         java.lang.String attribute,
                         edu.umich.visualsoar.graph.SoarVertex v1)
Removes the requested triple from Working Memory


createVertexCopy

public edu.umich.visualsoar.graph.SoarVertex createVertexCopy(edu.umich.visualsoar.graph.SoarVertex orig)
Returns an exact copy of a SoarVertex with a new id


createNewEnumeration

public edu.umich.visualsoar.graph.EnumerationVertex createNewEnumeration(java.util.Vector s)
Create a new EnumerationVertex with a vector of strings that represent possible values for that enumeration

Parameters:
s - the vector of strings that represent values
See Also:
EnumerationVertex

createNewEnumeration

public edu.umich.visualsoar.graph.EnumerationVertex createNewEnumeration(java.lang.String s)
Create a new EnumerationVertex with a string that represents the only acceptable value for that enumeration

Parameters:
s - string representing the value for that enumeration attribute
See Also:
EnumerationVertex

createNewInteger

public edu.umich.visualsoar.graph.IntegerRangeVertex createNewInteger()
Create Integer Vertex with default (unbounded) range

See Also:
IntegerRangeVertex

createNewIntegerRange

public edu.umich.visualsoar.graph.IntegerRangeVertex createNewIntegerRange(int low,
                                                                           int high)
Create Integer Vertex with specified range

Parameters:
low - the minimum limit of the integer attribute
high - the maximum limit of the integer attribute
See Also:
IntegerRangeVertex

createNewString

public edu.umich.visualsoar.graph.StringVertex createNewString()
Create a StringVertex attribute

See Also:
StringVertex

createNewFloat

public edu.umich.visualsoar.graph.FloatRangeVertex createNewFloat()
Create Float Vertex with default (unbounded) range

See Also:
FloatRangeVertex

createNewFloatRange

public edu.umich.visualsoar.graph.FloatRangeVertex createNewFloatRange(float low,
                                                                       float high)
Create Float Vertex with specified range

Parameters:
low - the minimum limit of the float attribute
high - the maximum limit of the float attribute
See Also:
FloatRangeVertex

createNewSoarId

public edu.umich.visualsoar.graph.SoarIdentifierVertex createNewSoarId()
Create a basic soar Identifier Vertex

See Also:
SoarIdentifierVertex

createNewStateId

public edu.umich.visualsoar.graph.SoarIdentifierVertex createNewStateId(edu.umich.visualsoar.graph.SoarIdentifierVertex superstate,
                                                                        java.lang.String name)
Called to create the Vertex and appropriate identifiers for a high-level operator

Parameters:
superstate - the parent operator of the operator
name - the name of the high-level operator
Returns:
SoarIdentifierVertex that is the dataMapId for that operator
See Also:
SoarIdentifierVertex

getNextVertexId

protected int getNextVertexId()
Each Vertex in Working Memory has a unique ID, function returns the next available Vertex ID


notifyListenersOfAdd

protected void notifyListenersOfAdd(edu.umich.visualsoar.graph.NamedEdge ne)
Notifies the listeners to refresh the screen

Parameters:
ne - the edge that was added

notifyListenersOfRemove

protected void notifyListenersOfRemove(edu.umich.visualsoar.graph.NamedEdge ne)
Notifies the listeners to refresh the screen

Parameters:
ne - the edge that has been removed

write

public void write(java.io.Writer graphWriter)
           throws java.io.IOException
Writes out information for the datamap file (.dm file) .dm datamap file is in the format of: number of vertices
write out all vertices:    |vertex type|    |vertex id int|    |number of enumerations|    |enumeration strings .....|
number of edges
write out all edges:    | left vertex |    |name of edge|    |right vertex|

Parameters:
graphWriter - the file to be written too - .dm file
java.io.IOException

writeComments

public void writeComments(java.io.Writer commentWriter)
                   throws java.io.IOException
Writes all of the edge comments to the writer to create the comment file and whether a datamap entry is generated or not. Each line represents an entry of the datamap. Each line contains a 1 or a 0 that signifies if generates or not and is followed by a comment if there is one.

java.io.IOException

matches

public java.util.List matches(edu.umich.visualsoar.graph.SoarIdentifierVertex sv,
                              edu.umich.visualsoar.parser.SoarProduction sp,
                              java.lang.String variable)
Function finds the set of variables within a productions that matches a given string

Parameters:
sv - the SoarIdentifierVertex currently checking
sp - the SoarProduction to check for matching variables
variable - the string that function tries to match
Returns:
a List of matches, empty list if nothing found

checkProduction

public java.util.List checkProduction(edu.umich.visualsoar.graph.SoarIdentifierVertex sv,
                                      edu.umich.visualsoar.parser.SoarProduction sp)
Used to determine if a soar production matches Working Memory

Parameters:
sv - the SoarIdentifierVertex in WorkingMemory currently checking
sp - the Soar Production to check
Returns:
a list of errors
See Also:
DefaultCheckerErrorHandler, DataMapChecker#check(SoarWorkingMemoryModel,SoarIdentifierVertex,TriplesExtractor,DefaultCheckerErrorHandler)

checkProductionLog

public java.util.List checkProductionLog(edu.umich.visualsoar.graph.SoarIdentifierVertex sv,
                                         edu.umich.visualsoar.parser.SoarProduction sp,
                                         java.io.FileWriter fw)
Used to determine if a soar production matches Working Memory This function will also generate a log file to keep track of production checking

Parameters:
sv - the SoarIdentifierVertex in WorkingMemory currently checking
sp - the Soar Production to check
fw - the log file that is being written too - "CheckingProductions.log"
Returns:
a list of errors
See Also:
DefaultCheckerErrorHandler, DataMapChecker#check(SoarWorkingMemoryModel,SoarIdentifierVertex,TriplesExtractor,DefaultCheckerErrorHandler)

checkGenerateProduction

public java.util.List checkGenerateProduction(edu.umich.visualsoar.graph.SoarIdentifierVertex sv,
                                              edu.umich.visualsoar.parser.SoarProduction sp,
                                              edu.umich.visualsoar.operatorwindow.OperatorNode current)
Used by the Generate Productions actions to look for holes in Working Memory and fix those holes.

Parameters:
sv - the SoarIdentifierVertex in WorkingMemory currently checking
sp - the Soar Production to check
current - the node being examined
Returns:
a list of errors
See Also:
DefaultCheckerErrorHandler, DataMapChecker#complete(SoarWorkingMemoryModel,SoarIdentifierVertex,TriplesExtractor,DefaultCheckerErrorHandler,OperatorNode)

getParents

public java.util.List getParents(edu.umich.visualsoar.graph.SoarVertex sv)
Return all parents of a vertex

Parameters:
sv - the source vertex
Returns:
a list of all matching SoarVertex 's

getMatchingParent

public edu.umich.visualsoar.graph.SoarVertex getMatchingParent(edu.umich.visualsoar.graph.SoarVertex sv)
Returns:
first matching SoarVertex parent
See Also:
DirectedGraph.getMatchingParent(SoarWorkingMemoryModel, SoarVertex)

resolve

public void resolve()

getNumberOfVertices

public int getNumberOfVertices()
Returns the number of vertices in Working Memory


Java 2 Platform
v1.3