Skip to: Site menu | Main content

Drools

Java Rules Engine

Alpha and Beta memory Print

Implementing Alpha and beta memory

The last few days I've finally gotten back to implementing the new RETE for Drools and was double checking how CLIPS implements alpha and beta memory. From the CLIPS documentation it states the following:

The function Drive handles high-level updating of the join network when a fact is asserted. If the join being updated is a terminator join (i.e., the last join of a rule which connects the join to the actions of a rule), a rule activation has occurred. An activation is added to the agenda and the current level of recursive descent into the join network is terminated. If the join was entered from the LHS, the partial match is stored in the beta memory of the join. Partial matches entering from the RHS are already stored in the alpha memory in the pattern network.

If the join being updated is a single-entry join (i.e. the join associated with the first conditional element in a rule), then the single-entry join algorithm is used for updating the join network. First, it is determined if the primary join expression evaluates to TRUE or FALSE. If no expression exists, the evaluation is automatically TRUE. If the expression is FALSE, the join update is completed.

If LHS entry is from a pattern conditional element, a copy of the alpha partial match is made and sent to all the child joins of the current join using the Drive algorithm.

If I interpret this correctly, it means the following for a join node.

  • a join from the left hand is stored in a beta memory
  • a join from the right hand is stored in an alpha memory
  • a terminating node in CLIPS is the last join

For the new implementation I plan to make a terminating node. This also means the new rule compiler will need to generate the nodes correctly.