2016-10-20 10 views
0

3つのモジュールを持つクリップにプロジェクトがあります。前の回答の1つを取り消したい場合は、私は2番目のモジュールの答えのすべてを取り下げて、もう一度やり直す必要があります。私は第二のモジュールのすべての答えを撤回した後、私はこのルールが2回目のモジュールの最後にCLIPSルールが一致しない(起動しない)

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

を活性化されることが予想される。しかし、このルールはactivetedされることはありませんし、そうでないLHSと一致する事実がで存在している場合にもAGENDAに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 IA第二のモジュールに行きます私はユーザーに行う一連の他の質問がありますか?その後、私は彼がこのうちの1つを撤回したいかどうか尋ね、もし彼が2つのもの(domanda-medio、domanda-esperto)を選ぶなら、第2のモジュールのすべての回答を取り下げなければならない。 2番目のモジュールのすべての回答を取り下げた後、この2つのルールは決して活性化されず、LHSと一致する事実が事実リスト(livello-utente(livello?))の中にある場合にも議題に追加されません

+0

問題の再現可能な例を提供する必要があります。 –

+0

@GaryRiley大丈夫、最初の投稿を編集しよう。 – Hunter

答えて

0

は@GaryRiley [OK]を私はなぜ知っているが、2つのルール、それを仕事に `

(not (diagnosi (nome ?)))` 

を追加することはありません。

関連する問題