2014-12-22 5 views
0

저는 Drools에 비교적 새로운입니다. 2, 3, 아무 일도 발생하지 않는 규칙에 대한추론이 작동하지 않습니다.

rule "Add Marque Polynesie extention taxe" 
no-loop true 
lock-on-active true 
when 
    $d : Demarche(extPolynesie == true) 
    IsMarque(demarche == $d) 
then 
    $d.listTaxes.put(17, 1); 
    System.out.println("marque"); 
end 



rule "Add Not Marque Polynesie extention taxe" 
no-loop true 
lock-on-active true 
when 
    $d : Demarche(extPolynesie == true) 
    not(IsMarque(demarche == $d)) 
then 

    System.out.println("not marque"); 
end 

:

import models.Demarche; 
declare IsMarque 
demarche : Demarche 
end 

rule "Add type Marque taxe" 
salience 2 
no-loop true 
lock-on-active true 
when 
    $d : Demarche(typeDemarche == "Marque") 
then 
    modify($d){ 
     listTaxes.put(14, 1) 
    } 
    insert(new IsMarque($d)); 
    System.out.println("infer marque"); 
end 

그리고 : 나는 그 규칙이 있습니다. 그 중 하나는 사실이어야하지만, 추론 된 IsMarque를 평가할 수없는 것처럼 인쇄 된 것은 없습니다. 이 IsMaqrue 평가가 작동하고 있다고 말하면 콘솔에 인쇄 된 메시지를 볼 수 있습니다. 아이디어가 있으십니까?

+0

Lock-on-active를 사용하게 만드는 요소는 무엇입니까? 이것을 제거하십시오. - 그 외에도 extPolynesie가 true 인 Demarche에서 첫 번째 규칙이 실행되고 규칙 # 2와 # 3에 필요하다는 것을 확신 할 수 없습니다. 잠금 - 온 - 액티브 제거에 여전히 문제가있는 경우 : 코드 삽입 사실을 추가하십시오. – laune

+0

lock-on-active를 제거하면 내 규칙이 무한 루프에 있습니다. 그리고 내 demarche는 extPolynesie = true라고 확신합니다. 내 DB에는 단 하나의 demarche 만 있습니다. (extPolynesie가 true 인 경우) – Lempkin

+0

Loop : 그렇다면 오른쪽에서 수행 한 작업을 모두 표시하지 않았습니다. . -1 – laune

답변

0

이 규칙은 당신이 모든 것을 표시 한 경우

rule "Add type Marque taxe" 
when 
    $d : Demarche(typeDemarche == "Marque", $t: listTaxes) // I AM GUESSING HERE 
    not IsMarque(demarche == $d) 
then 
    modify($t){ 
     put(14, 1) 
    } 
    insert(new IsMarque($d)); 
    System.out.println("infer marque"); 
end 

없이 no-loop truelock-on-active true로 다시 작성해야합니다. 당신이

rule "Add type Marque taxe" 
when 
    $d : Demarche(typeDemarche == "Marque") 
then 
    $d.getListTaxes().put(14, 1); 
    insert(new IsMarque($d)); 
    System.out.println("infer marque"); 
end 

경우 (단 경우) listTaxes 속성을 참조 CE를 같은 다른 규칙으로도 첫 번째 규칙을 작성할 수

참고. 규칙 "Add Marque Polynesie extention taxe"에이 "더티 업데이트"를 사용 했으므로 OK입니다.

전체 규칙을 게시하십시오 - # 1은 컴파일되지 않습니다.

+0

Thx, 사실 세금을 추가하기 위해 글로벌 목록을 사용했는데 이것은 좋은 방법이었습니다. 평가를 업데이트하지 않았습니다. 객체를 생성하고 no 루프를 삭제하고 활성 상태로 고정합니다. 고마워 :) – Lempkin