规则编译错误Drools action column, variable cannot be resolved

Rules compilation error Drools action column, variable cannot be resolved

我对 Drools 和探索 drools 决定 tables 的功能还很陌生。我已经下载了 Drools 6.2.0 示例并修改了为决定 table 提供的示例。因为我想删除政策条件,如下图所示

这里的策略只需要是结果对象,但我遇到了以下错误。

text=Rule Compilation error policy cannot be resolved or is not a field

我不确定在第一个 ACTION 列下写什么才能使其正常工作,因为我尝试了不同的值,例如 policy:Policy、政策等

下面是我针对上述决定 table 布局收到的 drl 输出。

// rule values at C10, header at C5
rule "Pricing bracket_10"
    when
        Driver(age >= 18, age <= 24, locationRiskProfile == "LOW", priorClaims == "1")
    then
        policy.setBasePrice(450);
end

我已尝试查看文档,但无法找到任何方法使其正常工作。请注意,我没有修改示例源代码中的任何内容。仅更改 excel 中的决策 table 布局。

任何指点都会有所帮助。

您需要将 class 策略的对象绑定到变​​量策略。一种可能性是插入一个 Policy 对象,并使其具有一个模式。 DRL 中的规则应如下所示:

rule "Pricing bracket_10"
when
    Driver( age >= 18, age <= 24, locationRiskProfile == "LOW", priorClaims == "1")
    policy: Policy()
then
    policy.setBasePrice(450);
end

在决策中 table 您可以使用如下所示的条件列:

CONDITION
policy: Policy()
/*$param*/
match a Policy fact
x

您需要在每一行中有一个 'x',或者加入单元格以凑合使用单个 'x'。