How would you structure Alpha Nodes in a Rete Network that has a rule with two conditions found in other rules?

62 views Asked by At

Let's say I have three rules:

  1. When Object's foo property is 1, output "foo"
  2. When Object's bar property is 1, output "bar"
  3. When Object's foo property is 1 and bar property is 1, output "both foo and bar"

What would the structure of alpha nodes look like for this scenario? I've seen examples where, given rules 1 and 2, it might look like:

      foo == 1 - "foo"
root<
      bar == 1 - "bar"

And, given 3:

root - foo == 1 - bar == 1 - "both foo and bar"

And, given 3 and 1:

                  "foo"
root - foo == 1 <
                  bar == 1 - "both foo and bar"

Given 3, 2 and 1, would it look something like:

       foo == 1 - "foo"
root <           
                  "bar"
       bar == 1 < 
                  foo == 1 - "both foo and bar"

or

       foo == 1 - "foo"
     /
root-- bar == 1 - "bar"
     \
       foo == 1 - bar == 1 - "both foo and bar"

Or some other way?

1

There are 1 answers

0
Gary Riley On BEST ANSWER

If you are sharing nodes and preserving the order in which properties are tested it would look like this:

       bar == 1 - "bar"
root <           
                  "foo"
       foo == 1 < 
                  bar == 1 - "both foo and bar"