2016-12-20 7 views
1

Droolsを使用する6.5.0.FinalDrools:簡略化された条件記法をさらに条件と併用する方法は?

私は、追加の条件と組み合わせて短縮組み合わせ条件(例えば、Person(age > 30 && < 40))を使用したいと考えています。 私はそれを試しましたが、結果のルールは複数回実行されます。

私は、設定点からの温度偏差がチェックされ、許容偏差が設定点に依存する小さな例があります。許容される偏差は、Paramのファクトで構成されます(下記を参照)。 Iは、例えば(fire-all-rules)を実行する場合:

  • ルール回(略して表記なし)予想通り1火災二度(バグ?)
  • 則2件の火災。

私の短縮形表記の使い方は間違っていますか、これはバグですか?

例ルール:

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 

答えて

0

略し制限

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

は何をしたい

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

と同等です

setpoint >= $p.from && < $p.to 
です
関連する問題