Hello,
I need help for this example that I have made with backward-chaining.
We use a template named Parral with 3 slots:
(deftemplate Parral (slot Estado_Fenologico) (slot Numero_Brotes) (slot Dias_Hasta_Recoleccion))
We have a rule named Arana_Madurez that uses two slots Estado_Fenologico and Dias_Hasta_Recoleccion of the Parral fact.
(defrule Arana_Madurez (Parral (Estado_Fenologico ?e) (Dias_Hasta_Recoleccion ?d)) (test (eq (str-compare "N" ?e) 0)) (test (< (integerp ?d) 21)) => (printout t "HOLA" crlf) (assert (Estado_Cultivo (Estado_Planta "MADUREZ"))) )
Using backward-chaining we ask the user for these values, in the rules create-Estado_Fenologico and create-Dias_Hasta_Recoleccion.
(defrule create-Estado_Fenologico (need-Parral (Estado_Fenologico ?)) => (printout t "Estado Fenologico: ") (assert (Parral (Estado_Fenologico (upcase (read))))) )
(defrule create-Dias_Hasta_Recoleccion (need-Parral (Dias_Hasta_Recoleccion ?)) => (printout t "Dias hasta recoleccion: ") (assert (Parral (Dias_Hasta_Recoleccion (read)))) )
However, I have an error in the Arana_Madurez rule because when the create-Estado_Fenologico asserts the Parral fact, this fact only stores the value of Estado_Fenologico slot. The fact Parral exists now, and the Arana_Madurez rule is evaluated, producing an error because the Dias_Hasta_Recoleccion remains with a nil value and it isn4t a numeric value. Instead of evaluating the rule, the backward-chaining might fire the rule which ask for the Dias_Hasta_Recoleccion value.
The general idea is how to ask to the users the unknown slots which appear in the LHS rules, using backward-chaining. And how to assert the slots values of a fact in a independent way.
Thanks for any help.
The complete example is as follows:
; DEFINICION DE PLANTILLAS ;; ************************
(deftemplate Parral (slot Estado_Fenologico) (slot Numero_Brotes) (slot Dias_Hasta_Recoleccion))
(deftemplate Estado_Cultivo (slot Estado_Planta))
;; DEFINICION DE REGLAS ;; ******************** (do-backward-chaining Parral )
(defrule create-Estado_Fenologico (need-Parral (Estado_Fenologico ?)) => (printout t "Estado Fenologico: ") (assert (Parral (Estado_Fenologico (upcase (read))))) )
(defrule create-Dias_Hasta_Recoleccion (need-Parral (Dias_Hasta_Recoleccion ?)) => (printout t "Dias hasta recoleccion: ") (assert (Parral (Dias_Hasta_Recoleccion (read)))) )
(defrule create-Numero_Brotes (need-Parral (Numero_Brotes ?)) => (printout t "Numero de brotes: ") (assert (Parral (Numero_Brotes (read)))) )
(defrule Arana_Madurez (Parral (Estado_Fenologico ?e) (Dias_Hasta_Recoleccion ?d)) (test (eq (str-compare "N" ?e) 0)) (test (< (integerp ?d) 21)) => (printout t "HOLA" crlf) (assert (Estado_Cultivo (Estado_Planta "MADUREZ"))) )
(defrule Arana_Vigilar (Parral (Estado_Fenologico ?e)) (test (eq (str-compare ?e "A") 0)) => (assert (Estado_Cultivo (Estado_Planta "VIGILAR"))) )
-------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
