2

I'm trying to draw a Rete network for a sample rule which has no binding between variables in different patterns. I know that beta network is used to make sure that the bended variable in different patterns are consistent.

(defrule R1
  (type1 c1 c2)
  (type2 c3)
 =>
)

(defrule R2
  (type2 c3)
  (type3 c4 v1)
  (type4 c5 v1)
 =>
) 

In R1, there is no binded variables between the two patterns, how should I combine their result in the Rete network then? In R2, two rules have binded variable while the third has not. How to combine the three rules in the network? I searched for Rete network example for such a situation but didn't find any. I tried to draw the network and below is my network. Is it right?

UPDATE: New network based on Gary's answer

enter image description here Thanks

Salahuddin
  • 1,617
  • 3
  • 23
  • 37

1 Answers1

5

Beta nodes store partial matches regardless of whether there are variables specified in the patterns that need to be checked for consistency. The variables bindings just serve to filter the partial matches that are stored in the beta memory. If there are no variables, then all generated partial matches will be stored in the beta memories.

Your diagram should look like this:

a1    a2   a3   a4
  \  /  \  /    /
   b1    b2    /
   |       \  /
   r1       b3
            |
            r2
Gary Riley
  • 10,130
  • 2
  • 19
  • 34
  • Thanks Gary for answer. It clarifies the picture for me. Should there be a beta memory after every beta node, or only if there are more join operations? I mean, even with the last join node there must be a beta memory? I updated my question with a modified network, please tell me if this is right now. Many thanks – Salahuddin Aug 27 '17 at 04:47
  • 1
    I wouldn't say that there's a canonical implementation of the rete algorithm. There's a few things like node sharing and partial matches that need to be present, but various tools that implement rete use difference techniques. Doorenbos's "Production Matching for Large Learning Systems", http://reports-archive.adm.cs.cmu.edu/anon/1995/CMU-CS-95-113.pdf, has a really good overview of different implementations of rete. Every node in the beta network is going to have a beta memory associated with it regardless of whether the associated patterns contain variables. – Gary Riley Aug 27 '17 at 21:04