algorithm - 您将如何在 Rete 网络中构建具有在其他规则中找到的两个条件的规则的 Alpha 节点?
问题描述
假设我有三个规则:
- 当Object的foo属性为1时,输出“foo”
- 当Object的bar属性为1时,输出“bar”
- 当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"
还是其他方式?
解决方案
如果您要共享节点并保留测试属性的顺序,则如下所示:
bar == 1 - "bar"
root <
"foo"
foo == 1 <
bar == 1 - "both foo and bar"
推荐阅读
- python - 使用python将信息从Linux文件解析到Windows
- ansible - Ansible 从结果中检索多个数组值
- pyspark - 如何在 PySpark collect_list 中维护排序顺序并收集多个列表
- mysql - MySql:使用连接从表中删除
- dynamics-crm - 是否可以使用 Dynamics 365 Customer Engagement Web API 替换所有 XRM 调用?
- awk - 使用 'sed' 或 'awk' 在文件中添加前导零到日期
- single-page-application - 无法阻止显示自动 PWA 安装提示?
- c++ - 为什么 C++ 不允许从有效地址和类型创建有效指针?
- python - 在python中使用实例变量
- php - 动态生成的表单无法识别不同的行