首页 > 解决方案 > Select a single rule (based on attribute weights) from multiple rules matched in Drools

问题描述

I want to be able to select 1 off the multiple rules which match the input. Logic to pickup the best match should be based on weights provided for each attribute.

eg:

Attrib1_Weight = 1
Attrib2_Weight = 4
Attrib3_Weight = 1

Rule1 = Attrib1, Attrib3
Rule2 = Attrib2

So if a condition meets both Rule1 and Rule2 -- Rule2 will be selected as Attrib2 is having weight = 4. For Rule1 total weight is 2.

I am using decision table excel.

标签: drools

解决方案


您可以为表示权重的每个规则添加一个新约束。然后,您需要将重量作为事实插入到引擎中。


推荐阅读