2016-10-20 4 views
0

Ich habe ein Projekt in Clips mit drei Modulen, am Ende des zweiten Moduls Ich frage den Benutzer, ob er eine der vorherigen Antwort zurückziehen möchte, wenn er einen zurückziehen von der Antwort des zweiten Moduls muss ich alle Antworten des zweiten Moduls zurückziehen und nochmals fragen. Nachdem ich alle Antworten des zweiten Moduls einfahren, erwarte ich, dass diese RegelCLIPS Regel unmatch (nicht feuern) nach dem Einfahren

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

Aber diese Regel activeted nie und es nicht in der AGENDA apper auch wenn die Tatsachen, die die LHS passen in die Gegenwart Faktenliste.

Sorry für mein schlechtes Englisch.

BEARBEITEN. @Gary Vor allem frage ich 5 Fragen an Benutzer, das sind dies:

(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))) 
) 

Danach i eine Regel ausgelöst, dass mit den Benutzer asnwers in entsprechend dem Profil des Benutzers

(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)))) 

) 

umreißen Danach gehe ich in dem zweiten Modul, in dem eine dieser beiden Regel ia in entsprechend mit dem Profil des Benutzers bestimmt in der Faust-Modul

(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))) 
) 

nach th actived gibt es eine Reihe von anderen Fragen, die ich tun, um Benutzer. Danach frage ich, ob er eines davon zurückziehen möchte, und wenn er eines der beiden auswählt (domanda-medio, domanda-esperto), muss ich alle Antworten des zweiten Moduls zurückziehen. Nachdem ich alle Antworten des zweiten Moduls eingezogen habe, wird diese Regel niemals aktiviert und auch nicht in der AGENDA angezeigt, wenn die Fakten, die mit der LHS übereinstimmen, in der Faktenliste (livello-utente (livello?))

+0

Sie müssen ein reproduzierbares Beispiel für das Problem angeben. –

+0

@GaryRiley ok ich versuche, bearbeiten Sie den ersten Beitrag. – Hunter

Antwort

0
vorhanden sind

@GaryRiley ok ich weiß nicht, warum, aber das Hinzufügen `

(not (diagnosi (nome ?)))` 

auf die beiden es Arbeit Regel.