首页 > 解决方案 > 您将如何在 Rete 网络中构建具有在其他规则中找到的两个条件的规则的 Alpha 节点?

问题描述

假设我有三个规则:

  1. 当Object的foo属性为1时,输出“foo”
  2. 当Object的bar属性为1时,输出“bar”
  3. 当Object的foo属性为1,bar属性为1时,输出“both foo and bar”

在这种情况下,alpha 节点的结构会是什么样子?我见过一些例子,在给定规则 1 和 2 的情况下,它可能看起来像:

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

并且,给定 3:

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

并且,给定 3 和 1:

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

给定 3、2 和 1,它看起来像:

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

或者

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

还是其他方式?

标签: algorithmrulesbusiness-rulesrete

解决方案


如果您要共享节点并保留测试属性的顺序,则如下所示:

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

推荐阅读