Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.able.rules
Class AblePatternMatchNetwork

    java.lang.Object
      com.ibm.able.rules.AblePatternMatchNetwork

All Implemented Interfaces:
  AbleClearable, AbleWorkingMemory, java.io.Serializable

public class AblePatternMatchNetwork
extends java.lang.Object
implements AbleWorkingMemory, AbleClearable, java.io.Serializable

This class is the run-time instance of a Rete' network and associated working memory constructed and used by the AblePatternMatchEngine.

The AblePatternMatchNetwork class plays two roles, first as the compiled sorting network (Rete' network) of alpha and beta nodes (AblePatternMatchNodes and subclasses), and as an AbleWorkingMemory or object data store.

A single AbleRuleBlock or set of AblePatternMatchRules is compiled into the Rete' network structure. Subsequent assert, retract, or modify operations against the AblePatternMatchNetwork cause Tokens to be created and passed through the network for processing.

See Also:
  `AblePatternMatchRule`, `AblePatternMatchEngine`, Serialized Form

Field Summary
`protected java.util.HashSet` | `allTerminalNodes`
`protected int` | `index`
`protected java.util.Hashtable` | `joinNodes` Holds all of the positive, negative, and And Join nodes with beta memories
`protected AbleRuleSet` | `myRuleSet`
`protected AbleLogger` | `myTracer`
`protected static AbleExpression` | `myTrueExpression`
`protected boolean` | `noDuplicates`
`protected java.util.Hashtable` | `rootNodeHash`
`protected java.util.Hashtable` | `selectorVarHash`
`protected java.util.Hashtable` | `terminalNodes` Holds the associated Terminal node for each selector (pattern) and rule
`protected AbleWorkingMemory` | `workingMemory`

Constructor Summary
`AblePatternMatchNetwork(AbleRuleSet theRuleSet, AbleRuleBlock theRules, AbleLogger theTracer, AbleWorkingMemory memory)`

Method Summary
`boolean` | `asserta(java.lang.Object fact)` Place a fact into the working memory at front.
`void` | `assertAll(java.util.List theList)` Assert all elements in the list into working memory.
`boolean` | `assertFact(java.lang.Object fact)` A new memory element was added to the working memory -- update the PM network
`boolean` | `assertz(java.lang.Object fact)` Place a fact into the database at end.
`void` | `clear()` Remove all objects stored in this working memory
`protected void` | `compileNetwork(AbleRuleBlock theRules)` Build a pattern match network from a set of when/do rules
`void` | `dumpNetwork()` Debugging method to output structure of PatternMatch Network after compilation.
`protected void` | `dumpNode(com.ibm.able.rules.AblePatternMatchNode node)` Recursively display Nodes connected to this one.
`boolean` | `exists(java.lang.Object fact)` Test if the specified object exists in the working memory.
`java.lang.Object` | `find(AbleSelector query)` Given a query which is a pattern match rule Return the first object that matches the constraints
`java.util.AbstractCollection` | `findAll(AbleSelector query)` Given a query which is a pattern match rule Return the all objects that match the constraints
`java.util.AbstractCollection` | `findAllInstances(java.lang.String className)` Find all objects that match the class
`protected com.ibm.able.rules.AblePatternMatchNode` | `generateAndJoinNode(com.ibm.able.rules.AblePatternMatchNode parentNode1, com.ibm.able.rules.AblePatternMatchNode parentNode2, AbleExpression testExpression, AbleVariable selectorVar, java.util.Vector selectorVars)` Create a two-input AND (join) pattern match node
`protected com.ibm.able.rules.AblePatternMatchNode` | `generateDummyJoinNode(com.ibm.able.rules.AblePatternMatchNode parentNode2, AbleExpression testExpression, AbleVariable selectorVar, java.util.Vector selectorVars)` Create a two-input dummy (join) pattern match node Note: parentNode1 is always null
`protected com.ibm.able.rules.AblePatternMatchNode` | `generateJoinNode(com.ibm.able.rules.AblePatternMatchNode parentNode1, com.ibm.able.rules.AblePatternMatchNode parentNode2, AbleExpression testExpression, AbleVariable selectorVar, java.util.Vector selectorVars)` Create a two-input (join) pattern match node
`protected com.ibm.able.rules.AblePatternMatchNode` | `generateNegativeSelectorNodes(com.ibm.able.rules.AblePatternMatchRootNode theRootNode, com.ibm.able.rules.AblePatternMatchNode theLastNode, AbleSelector lastSelector, AbleSelector theSelector, java.util.Vector selectorVars)` Generate the PatternMatchNodes for this negative selector (pattern)
`protected com.ibm.able.rules.AblePatternMatchNode` | `generateNegJoinNode(com.ibm.able.rules.AblePatternMatchNode parentNode1, com.ibm.able.rules.AblePatternMatchNode parentNode2, AbleExpression testExpression, AbleVariable selectorVar, java.util.Vector selectorVars)` Create a two-input (join) pattern match node
`protected com.ibm.able.rules.AblePatternMatchNode` | `generatePositiveSelectorNodes(com.ibm.able.rules.AblePatternMatchRootNode theRootNode, com.ibm.able.rules.AblePatternMatchNode theLastNode, AbleSelector lastSelector, AbleSelector theSelector, java.util.Vector selectorVars)` Generate the PatternMatchNodes for this positive selector (pattern)
`protected void` | `generateRuleNodes(AblePatternMatchRule theRule)` Generate the PatternMatchNodes for this rule
`protected com.ibm.able.rules.AblePatternMatchNode` | `generateRuleTerminalNode(com.ibm.able.rules.AblePatternMatchNode parentNode, AblePatternMatchRule theRule)` Create a rule terminal node
`protected com.ibm.able.rules.AblePatternMatchNode` | `generateTerminalNode(com.ibm.able.rules.AblePatternMatchNode parentNode, AbleVariable selectorVar)` Create a terminal node
`protected com.ibm.able.rules.AblePatternMatchNode` | `generateTestNode(com.ibm.able.rules.AblePatternMatchNode parentNode, AbleExpression testExpression, AbleVariable selectorVar)` Create a one-input (test) pattern match node
`protected com.ibm.able.rules.AblePatternMatchNode` | `generateTestNodes(com.ibm.able.rules.AblePatternMatchNode parentNode, AbleExpression testExpression, AbleVariable selectorVar)` Create a sequence of ANDed one-input (test) pattern match nodes
`java.util.Enumeration` | `getClasses()` Retrieve all classes (types) stored in this working memory
`protected int` | `getNumInputs(AbleExpression expression, java.util.Vector selectorVars)`
`boolean` | `isEmpty()` Returns true if the working memory is empty (contains no objects)
`void` | `modify(java.lang.Object fact)` Modify or change an existing memory element A memory element was changed in the the working memory - update the PM net
`void` | `modifyFact(java.lang.Object fact)` Modify or change an existing fact in the database
`void` | `retract(java.lang.Object fact)` A memory element was removed from the working memory - update the PM Network
`void` | `retractAll(java.util.List theList)` Retract all elements in the list from working memory.
`void` | `retractFact(java.lang.Object fact)` Remove a fact from the database
`protected void` | `setReplacementVars(java.util.Vector selectorVars, java.util.Hashtable replacementVars, java.util.Vector newSelectorVars)`
`java.lang.Object[]` | `toArray()` Format the contents of working memory as an array of String[] Able array variables Note: this is an expensive operation
`java.lang.String` | `toString()` Format the contents of working memory into a String For display in an Inspector

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### rootNodeHash

    protected java.util.Hashtable rootNodeHash

### workingMemory

    protected AbleWorkingMemory workingMemory

### index

    protected int index

### selectorVarHash

    protected java.util.Hashtable selectorVarHash

### noDuplicates

    protected boolean noDuplicates

### terminalNodes

    protected java.util.Hashtable terminalNodes

  Holds the associated Terminal node for each selector (pattern) and rule

### allTerminalNodes

    protected java.util.HashSet allTerminalNodes

### joinNodes

    protected java.util.Hashtable joinNodes

  Holds all of the positive, negative, and And Join nodes with beta memories

### myTracer

    protected AbleLogger myTracer

### myRuleSet

    protected AbleRuleSet myRuleSet

### myTrueExpression

    protected static final AbleExpression myTrueExpression

Constructor Detail

### AblePatternMatchNetwork

    public AblePatternMatchNetwork(AbleRuleSet theRuleSet,
                                   AbleRuleBlock theRules,
                                   AbleLogger theTracer,
                                   AbleWorkingMemory memory)
                            throws AbleException

Method Detail

### compileNetwork

    protected void compileNetwork(AbleRuleBlock theRules)
                           throws AbleException

  Build a pattern match network from a set of when/do rules

  Throws:
    `AbleException`

### generateRuleNodes

    protected void generateRuleNodes(AblePatternMatchRule theRule)
                              throws AbleException

  Generate the PatternMatchNodes for this rule

  Throws:
    `AbleException`

### generatePositiveSelectorNodes

    protected com.ibm.able.rules.AblePatternMatchNode generatePositiveSelectorNodes(com.ibm.able.rules.AblePatternMatchRootNode theRootNode,
                                                                                    com.ibm.able.rules.AblePatternMatchNode theLastNode,
                                                                                    AbleSelector lastSelector,
                                                                                    AbleSelector theSelector,
                                                                                    java.util.Vector selectorVars)
                                                                             throws AbleDataException

  Generate the PatternMatchNodes for this positive selector (pattern)

  Throws:
    `AbleDataException`

### getNumInputs

    protected int getNumInputs(AbleExpression expression,
                               java.util.Vector selectorVars)

### setReplacementVars

    protected void setReplacementVars(java.util.Vector selectorVars,
                                      java.util.Hashtable replacementVars,
                                      java.util.Vector newSelectorVars)

### generateNegativeSelectorNodes

    protected com.ibm.able.rules.AblePatternMatchNode generateNegativeSelectorNodes(com.ibm.able.rules.AblePatternMatchRootNode theRootNode,
                                                                                    com.ibm.able.rules.AblePatternMatchNode theLastNode,
                                                                                    AbleSelector lastSelector,
                                                                                    AbleSelector theSelector,
                                                                                    java.util.Vector selectorVars)
                                                                             throws AbleDataException

  Generate the PatternMatchNodes for this negative selector (pattern)

  Throws:
    `AbleDataException`

### generateTestNodes

    protected com.ibm.able.rules.AblePatternMatchNode generateTestNodes(com.ibm.able.rules.AblePatternMatchNode parentNode,
                                                                        AbleExpression testExpression,
                                                                        AbleVariable selectorVar)

  Create a sequence of ANDed one-input (test) pattern match nodes

### generateTestNode

    protected com.ibm.able.rules.AblePatternMatchNode generateTestNode(com.ibm.able.rules.AblePatternMatchNode parentNode,
                                                                       AbleExpression testExpression,
                                                                       AbleVariable selectorVar)

  Create a one-input (test) pattern match node

### generateDummyJoinNode

    protected com.ibm.able.rules.AblePatternMatchNode generateDummyJoinNode(com.ibm.able.rules.AblePatternMatchNode parentNode2,
                                                                            AbleExpression testExpression,
                                                                            AbleVariable selectorVar,
                                                                            java.util.Vector selectorVars)

  Create a two-input dummy (join) pattern match node Note: parentNode1 is always null

### generateAndJoinNode

    protected com.ibm.able.rules.AblePatternMatchNode generateAndJoinNode(com.ibm.able.rules.AblePatternMatchNode parentNode1,
                                                                          com.ibm.able.rules.AblePatternMatchNode parentNode2,
                                                                          AbleExpression testExpression,
                                                                          AbleVariable selectorVar,
                                                                          java.util.Vector selectorVars)

  Create a two-input AND (join) pattern match node

### generateJoinNode

    protected com.ibm.able.rules.AblePatternMatchNode generateJoinNode(com.ibm.able.rules.AblePatternMatchNode parentNode1,
                                                                       com.ibm.able.rules.AblePatternMatchNode parentNode2,
                                                                       AbleExpression testExpression,
                                                                       AbleVariable selectorVar,
                                                                       java.util.Vector selectorVars)

  Create a two-input (join) pattern match node

### generateNegJoinNode

    protected com.ibm.able.rules.AblePatternMatchNode generateNegJoinNode(com.ibm.able.rules.AblePatternMatchNode parentNode1,
                                                                          com.ibm.able.rules.AblePatternMatchNode parentNode2,
                                                                          AbleExpression testExpression,
                                                                          AbleVariable selectorVar,
                                                                          java.util.Vector selectorVars)

  Create a two-input (join) pattern match node

### generateTerminalNode

    protected com.ibm.able.rules.AblePatternMatchNode generateTerminalNode(com.ibm.able.rules.AblePatternMatchNode parentNode,
                                                                           AbleVariable selectorVar)

  Create a terminal node

### generateRuleTerminalNode

    protected com.ibm.able.rules.AblePatternMatchNode generateRuleTerminalNode(com.ibm.able.rules.AblePatternMatchNode parentNode,
                                                                               AblePatternMatchRule theRule)

  Create a rule terminal node

### assertFact

    public boolean assertFact(java.lang.Object fact)

  A new memory element was added to the working memory -- update the PM network

  Specified by:
    `assertFact` in interface `AbleWorkingMemory`

### asserta

    public boolean asserta(java.lang.Object fact)

  Description copied from interface: `AbleWorkingMemory`
  Place a fact into the working memory at front. Return true if a new fact.

  Specified by:
    `asserta` in interface `AbleWorkingMemory`

### assertz

    public boolean assertz(java.lang.Object fact)

  Description copied from interface: `AbleWorkingMemory`
  Place a fact into the database at end. Return true if a new fact.

  Specified by:
    `assertz` in interface `AbleWorkingMemory`

### assertAll

    public void assertAll(java.util.List theList)

  Assert all elements in the list into working memory. The list is unchanged.

  Specified by:
    `assertAll` in interface `AbleWorkingMemory`
  Parameters:
    `theList` - The list from which elements are to be asserted.

### retractFact

    public void retractFact(java.lang.Object fact)

  Description copied from interface: `AbleWorkingMemory`
  Remove a fact from the database

  Specified by:
    `retractFact` in interface `AbleWorkingMemory`

### retract

    public void retract(java.lang.Object fact)

  A memory element was removed from the working memory - update the PM Network

  Specified by:
    `retract` in interface `AbleWorkingMemory`

### retractAll

    public void retractAll(java.util.List theList)

  Retract all elements in the list from working memory. The list is unchanged.

  Specified by:
    `retractAll` in interface `AbleWorkingMemory`
  Parameters:
    `theList` - The list from which elements are to be retracted.

### modifyFact

    public void modifyFact(java.lang.Object fact)

  Description copied from interface: `AbleWorkingMemory`
  Modify or change an existing fact in the database

  Specified by:
    `modifyFact` in interface `AbleWorkingMemory`

### modify

    public void modify(java.lang.Object fact)

  Modify or change an existing memory element A memory element was changed in the the working memory - update the PM net

  Specified by:
    `modify` in interface `AbleWorkingMemory`

### exists

    public boolean exists(java.lang.Object fact)

  Test if the specified object exists in the working memory.

  Specified by:
    `exists` in interface `AbleWorkingMemory`
  Parameters:
    `fact` - The object we are looking for in the working memory.
  Returns:
    true if the object was found, false otherwise

### find

    public java.lang.Object find(AbleSelector query)
                          throws AbleDataException

  Given a query which is a pattern match rule Return the first object that matches the constraints

  Specified by:
    `find` in interface `AbleWorkingMemory`
  Throws:
    `AbleDataException`

### findAll

    public java.util.AbstractCollection findAll(AbleSelector query)
                                         throws AbleDataException

  Given a query which is a pattern match rule Return the all objects that match the constraints

  Specified by:
    `findAll` in interface `AbleWorkingMemory`
  Throws:
    `AbleDataException`

### findAllInstances

    public java.util.AbstractCollection findAllInstances(java.lang.String className)

  Find all objects that match the class

  Specified by:
    `findAllInstances` in interface `AbleWorkingMemory`

### getClasses

    public java.util.Enumeration getClasses()

  Retrieve all classes (types) stored in this working memory

  Specified by:
    `getClasses` in interface `AbleWorkingMemory`

### clear

    public void clear()

  Remove all objects stored in this working memory

  Specified by:
    `clear` in interface `AbleWorkingMemory`

### isEmpty

    public boolean isEmpty()

  Returns true if the working memory is empty (contains no objects)

  Specified by:
    `isEmpty` in interface `AbleWorkingMemory`

### dumpNetwork

    public void dumpNetwork()

  Debugging method to output structure of PatternMatch Network after compilation. Trace assumed on.

### dumpNode

    protected void dumpNode(com.ibm.able.rules.AblePatternMatchNode node)

  Recursively display Nodes connected to this one. Assumes trace on.

### toString

    public java.lang.String toString()

  Format the contents of working memory into a String For display in an Inspector

### toArray

    public java.lang.Object[] toArray()
                               throws AbleDataException

  Format the contents of working memory as an array of String[] Able array variables Note: this is an expensive operation

  Specified by:
    `toArray` in interface `AbleWorkingMemory`
  Throws:
    `AbleDataException`

Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

(C) Copyright IBM Corporation 1999, 2005