Episodic Memory Development - soartech/jsoar GitHub Wiki

This page is intended to facilitate collaboration during the refactor/redesign of the Episodic Memory codebase.

Classes

Below is an outline of the new classes and descriptions of their intended roles:

`

/**
 * Encapsulates data and queries pertaining to a specific single episode. 
 * Code responsible for doing the work of episode recreation should live 
 * here. This is also the interface through which the DNFGraph accesses
 * the data it needs to perform surface and graph matching evaluations.
 */
Episode
    long episode_id
    EpmemDataStore data_store
    WmeImpl root_wme
    Episode(long episode_id, EpmemDataStore data_store)
    WmeImpl getReconstructedEpisode()
    WmeImpl getReconstructedEpisode(WmeImpl filter)
    Set<EpmemNode> getNodesStartingThisEpisode()
    Set<EpmemNode> getNodesEndingThisEpisode()
    Episode getNextEpisode()
    Episode getPreviousEpisode()
    
/**
 * Responsible for maintaining the collections of wme additions and removals
 * between storage events so that they can be "committed" as a batch to form
 * a new episode. Ideally, inclusions/exclusions will be accounted for here,
 * but they may need to exist in the WorkingMemoryGraph object and be applied
 * during the actual commits.
 */
EpmemDiff
    Set<WmeImpl> additions
    Set<WmeImpl> removals
    EpmemDiff(Set<WmeImpl> inclusions, Set<WmeImpl> exclusions)
    void addWme(WmeImpl wme)
    void removeWme(WmeImpl wme)
    Set<WmeImpl> getAddedWmes()
    Set<WmeImpl> getRemovedWmes()
     
/**
 * Responsible for "node level" interactions with the epmem.
 * database. Methods returning sets of nodes might be replaced with
 * a class representing "partial nodes" - nodes with some known values
 * which are insufficient to uniquely identify a single specific node.
 * The functions in this class would then be replaced with factory 
 * methods for such objects.
 */
EpmemDataStore
    void updateNode(EpmemNode node)
    void addNode(EpmemNode node)
    SortedSet<EpmemNode> getNodesActiveDuringInterval(Interval interval)
    SortedSet<EpmemNode> getNodesWhere(long parent_id, attr_id, child_id)
    SortedSet<EpmemNode> getNodesWhere(long parent_id, attr_id)
    
/**
 * Provides access to data belonging to a specific "node" in epmem.
 */
EpmemNode (abstract base class)
    long wme_id
    long parent_slot_id
    long attr_slot_id
    long value_slot_id
    SortedSet<Interval> intervals
    EpmemNode getAttr()
    EpmemNode getValue()
EpmemIdentifierNode extends EpmemNode
EpmemValueNode extends EpmemNode

/**
 * Represents a node of the RIT. This will be incorporated into either
 * the EpmemDataStore class, or whichever classes are created to
 * represent partially-specified nodes (or more accurately, non-uniquely
 * specified nodes). 
 */
Interval
    long start
    long end
    long rit_id
        
/**
 * Responsible for "episode level" interactions with the epmem
 * database. New episodes are created from "diffs" and added
 * to the epmem data store, reusing existing nodes where
 * possible. It might be more appropriate to think of this class
 * as a factory for Episode and CandidateSet objects
 */
WorkingMemoryGraph
    EpmemDataStore data_store
    void addNewEpisode(EpmemDiff diff)
    Episode getEpisode(long episode_id)
    CandidateSet getCandidateSet(DNFGraph dnf_graph)

/**
 * Base class/interface for objects representing each epmem
 * command.
 */ 
EpmemCommand<T>
    T getCommandMetadata()
QueryCommand implements EpmemCommand<WmeImpl>
    QueryType query_type
    WmeImpl cue_wmes 
StoreCommand implements EpmemCommand<WmeImpl>
    WmeImpl episode_wmes
RetrieveCommand implements EpmemCommand<Long>
    long episode_id

/**
 * Responsible for creating DNFClauses from cue wmes and performing
 * graph and surface matching on episodes.
DNFGraph
    Set<DNFClause> clauses
DNFGraphBuilder
    DNFGraph build()
    DNFGraphBuilder addQuery(QueryCommand query)
DNFClause
    Set<DNFLiteral> literals
    boolean isSatisfied()
DNFLiteral
    WmeImpl cue_wme
    Set<EpmemNode> matches
    

/**
 * Represents a set of episodes that successfully pass a surface
 * match evaluation. In practice, evaluation is performed lazily
 * as each episode is considered.
 */
CandidateSet implements SortedSet<Episode>
    CandidateSet(DNFGraph dnf_graph, EpmemDataStore data_store)
    Comparator<Episode> comparator()
    Episode first()
    Episode last()
    SortedSet<Episode> headSet(Episode toEpisode)
    SortedSet<Episode> tailSet(Episode fromEpisode)
    SortedSet<Episode> subSet(Episode from, Episode to)

/**
 * Collection of methods for parsing various kinds of input into
 * usable structures/objects.
 */
EpmemParser
    Lexer lexer
    Set<WmeImpl> parse_chunk
    Set<WmeImpl> parse_string
    Set<WmeImpl> parse_file

/**
 * The top-level interface to the epmem module.
EpisodicMemory
    boolean epmem_enabled()
    void epmem_close()
    void initializeNewContext(WorkingMemory wm, IdentifierImpl id)
    void epmem_reset(IdentifierImpl state)
    void epmem_go()
    void epmem_go(boolean allow_store)
    boolean encodeInOutputPhase()
    boolean encodeInSelectionPhase()
    long epmem_validation()
    boolean addIdRefCount(long id, WmeImpl w)
    void addWme(IdentifierImpl id)
    void removeWme(WmeImpl w)
    void processIds()

`

⚠️ **GitHub.com Fallback** ⚠️