2016-10-20 3 views
0

두 번째 모듈 끝에서 세 개의 모듈이있는 클립에 프로젝트가 있습니다. 이전 답변 중 하나를 취소하려는 경우 사용자에게 물어 봅니다. 두 번째 모듈의 대답 중 두 번째 모듈의 모든 대답을 취소하고 다시 질문해야합니다. 내가 두 번째 모듈의 모든 해답을 철회 한 후, 나는이 규칙이CLIPS 규칙이 일치하지 않음 (실행하지 않음) 후퇴

(defrule SECONDMODULE::domanda-esperto 
    (declare (salience ?*highest-priority*)) 
     (livello-utente (livello esperto)) ;;assert in FIRSTMODULE and not retract 
     => 
     (something) 
    ) 

활성화 될 것으로 기대하지만이 규칙은 activeted 결코 그것을하지 LHS 일치하는 사실이의 존재도 경우 의제에 apper 사실 목록.

죄송합니다.

EDIT. 사용자 asnwers에 따라에 사용자

(defrule PROFILO::livello-utente 
?a<-(domanda (nome possiede-auto) (domanda ?) (risposta ?)) 
?b<-(domanda (nome anni-possesso-patente) (domanda ?) (risposta ?)) 
?c<-(domanda (nome conoscenza-meccanica-auto) (domanda ?) (risposta ?)) 
?d<-(domanda (nome kit-riparazione-rapida) (domanda ?) (risposta ?)) 
?e<-(domanda (nome frequenza-utilizzo-auto) (domanda ?) (risposta ?)) 
=> 

(switch (fact-slot-value ?a risposta) 
    (case TRUE then (bind ?*punteggio* (+ ?*punteggio* 1))) 
) 
(switch (fact-slot-value ?d risposta) 
    (case TRUE then (bind ?*punteggio* (+ ?*punteggio* 1))) 
) 
(switch (fact-slot-value ?b risposta) 
    (case <1 then (bind ?*punteggio* (+ ?*punteggio* 1))) 
    (case 1-5 then (bind ?*punteggio* (+ ?*punteggio* 2))) 
    (case >5 then (bind ?*punteggio* (+ ?*punteggio* 3))) 
) 
(switch (fact-slot-value ?c risposta) 
    (case 1 then (bind ?*punteggio* (+ ?*punteggio* 1))) 
    (case 2 then (bind ?*punteggio* (+ ?*punteggio* 2))) 
    (case 3 then (bind ?*punteggio* (+ ?*punteggio* 3))) 
    (case 4 then (bind ?*punteggio* (+ ?*punteggio* 4))) 
    (case 5 then (bind ?*punteggio* (+ ?*punteggio* 5))) 
) 
(switch (fact-slot-value ?e risposta) 
    (case 1-2 then (bind ?*punteggio* (+ ?*punteggio* 1))) 
    (case 3-5 then (bind ?*punteggio* (+ ?*punteggio* 2))) 
    (case 5-7 then (bind ?*punteggio* (+ ?*punteggio* 3))) 
) 
(bind ?f ?*punteggio*) 
(if (> ?f 9) then (assert (livello-utente (livello esperto)))) 
(if (< ?f 6) then (assert (livello-utente (livello principiante)))) 
(if (and (> ?f 5) (< ?f 10)) then (assert (livello-utente(livello medio)))) 

) 

의 프로필을 서술하는 것이 내가 규칙을 발사 이후

(defrule starting-rule 
(declare (salience ?*highest-priority*) (auto-focus TRUE)) 
    => 
(printout t "***Inizio***" crlf) 
(focus PROFILO) 
(set-strategy random)) 

(defrule PROFILO::chiedi-se-possiede-auto 
(not (domanda (nome possiede-auto) (domanda ?) (risposta ?))) 
=> 
(bind ?risposta (si-o-no "L'auto e' tua? ")) 
(assert (domanda (nome possiede-auto) (domanda "L'auto e' tua? ") (risposta ?risposta))) 
) 

(defrule PROFILO::frequenza-utilizzo-auto 
(not(domanda (nome frequenza-utilizzo-auto) (domanda ?) (risposta ?))) 
=> 
(bind ?risposta (risposte-range "Quante volte a settimana in media utilizzi l'auto? " 0 1-2 3-5 5-7)) 
(assert (domanda (nome frequenza-utilizzo-auto) (domanda "Quante volte a settimana in media utilizzi l'auto? ") (risposta ?risposta))) 
) 

(defrule PROFILO::conoscenza-meccanica-auto 
(not (domanda (nome conoscenza-meccanica-auto) (domanda ?) (risposta ?))) 
=> 
(bind ?risposta (risposte-range "Quanto ti consideri esperto della meccanica dell'auto?" 0 1 2 3 4 5)) 
(assert (domanda (nome conoscenza-meccanica-auto) (domanda "Quanto ti consideri esperto della meccanica dell'auto?") (risposta ?risposta))) 
) 

(defrule PROFILO::kit-riparazione-rapida 
(not (domanda (nome kit-riparazione-rapida) (domanda ?) (risposta ?))) 
=> 
(bind ?risposta (si-o-no "Possiedi un kit di riparazione rapida?")) 
(assert (domanda (nome kit-riparazione-rapida) (domanda "Possiedi un kit di riparazione rapida?") (risposta ?risposta))) 
) 

(defrule PROFILO::anni-possesso-patente 
(not(domanda (nome anni-possesso-patente) (domanda ?) (risposta ?))) 
=> 
(bind ?risposta (risposte-range "Da quanti anni possiedi la patente? " <1 1-5 >5)) 
(assert (domanda (nome anni-possesso-patente) (domanda "Da quanti anni possiedi la patente? ") (risposta ?risposta))) 
) 

: 모든 @Gary 우선 나는이 있는지, 사용자에게 5 질문 그 후 난이 두 룰 중 하나 일 후 주먹 모듈

(defrule DIAGNOSI::domanda-esperto 
    (declare (salience ?*highest-priority*)) 
    (livello-utente (livello esperto)) 
    => 
    (bind ?risposta (risposte-range "In quale tra le seguenti aree e' presente il problema?" Olio-motore Olio-freni Acqua Carburante Altro)) 
    (assert (domanda (nome area-problema) (domanda "In quale tra le seguenti aree e' presente il problema?") (risposta ?risposta))) 
) 

(defrule DIAGNOSI::domanda-medio 
    (declare (salience ?*highest-priority*)) 
    (livello-utente (livello medio)) 
    => 
    (bind ?risposta (si-o-no "Sapresti indicare l'area di provenienza del problema tra le seguenti: Olio motore, Olio freni, Acqua, Carburante, Altro?")) 
    (assert (domanda (nome domanda-area-problema) (domanda "Sapresti indicare l'area di provenienza del problema tra le seguenti: Olio motore, Olio freni, Acqua, Carburante, Altro?") (risposta ?risposta))) 
    (if (eq ?risposta TRUE) 
    then (bind ?risposta (risposte-range "In quale tra le seguenti aree e' presente il problema?" Olio-motore Olio-freni Acqua Carburante Altro)) 
      (assert (domanda (nome area-problema) (domanda "In quale tra le seguenti aree e' presente il problema?") (risposta ?risposta))) 
) 

에 한정된 사용자의 프로파일에있어서, 상기 제 actived 아이오와 모듈 갈 내가 사용자에게하는 일련의 다른 질문이있다. 그 후 나는 그가이 중 하나를 철회하기를 원하는지 물어 본다. 그리고 그가 두 가지를 선택한다면 (domanda-medio, domanda-esperto) 나는 두 번째 모듈의 모든 대답을 철회해야한다. 두 번째 모듈의 모든 답안을 철회 한 후이 두 규칙은 결코 활성화되지 않으며 LHS와 일치하는 사실이 사실 목록 (livello-utente (livello?))에있는 경우에도 동의하지 않습니다.

+0

문제의 재현 가능한 예를 제공해야합니다. –

+0

@GaryRiley 좋습니다. 첫 번째 게시물을 수정 해보세요. – Hunter

답변

0
두 개의 규칙이 작업에`

(not (diagnosi (nome ?)))` 

를 추가하는 이유하지만

@GaryRiley는 확인 모르겠어.