Drools:如何将缩写条件符号与更多条件一起使用?

Drools: how to use abbreviated condition notation together with further conditions?

使用 Drools 6.5。0.Final

我想结合附加条件使用缩写组合关系条件(例如 Person( age > 30 && < 40 ))。 我试过了,结果规则执行了不止一次

我有一个小例子,其中检查了温度与设定点的偏差,允许的偏差取决于设定点。允许的偏差由 Param 个事实配置,见下文。 如果我执行示例 (fire-all-rules):

我对缩写符号的使用是错误的还是这是一个错误?

示例规则:

declare Param
    from : float
    to : float
    low : float
    high : float
end

declare TemperatureEvent
@role( event )
    id : String
    setpoint : float
    t : float
end

rule "Init abbreviated conditions test"
when
then
    insert(new Param(0, 10, 1, 1));
    insert(new Param(10,20, 2, 3));
    insert(new TemperatureEvent("id1", 13.7f,11.5f));
    // rule 1 and rule 2 should fire exactly once
end

rule "rule 1"
when
    $p: Param()
    $x : TemperatureEvent($p.from <= setpoint && < $p.to, (t < setpoint+$p.low || t > setpoint+$p.high))
then
    System.out.println("rule 1: "+$x.getId()+" "+$x.getSetpoint()+" "+$x.getT());
end

rule "rule 2"
when
    $p: Param()
    $x : TemperatureEvent($p.from <= setpoint, setpoint < $p.to, (t < setpoint+$p.low || t > setpoint+$p.high))
then
    System.out.println("rule 2: "+$x.getId()+" "+$x.getSetpoint()+" "+$x.getT());
end

缩写限制

 $p.from <= setpoint && < $p.to

等同于

 $p.from <= setpoint && $p.from < $p.to

你要的是

 setpoint >= $p.from && < $p.to