Hi, I had a rule that has a (not)  pattern and (no-loop TRUE) on the RHS,
but no-loop TRUE is not preventing the rule from reactivation.
==> Activation: MAIN::allocate-ocr :  f-1,
FIRE 4 MAIN::allocate-ocr f-1,
 ==> f-4 (MAIN::allocation-entity (source ocr) (page 0) (entity nil))
 <== Focus MAIN
4
Can anyone explains to me should/why this rule is reactivated.
Thanks in advance.

YP



-------------------------------------TEST
CODE--------------------------------------------------------------
(clear)
(reset)
(watch all)

(deftemplate amount-value (declare (slot-specific TRUE)) (slot page) (slot
text) )
(deftemplate allocation-amount (declare (slot-specific TRUE)) (slot page)
(slot amount) )
(deftemplate allocation-entity (declare (slot-specific TRUE)) (slot source)
(slot page) (slot entity) )

(assert (amount-value (page 0) (text 0) ) )

(defrule allocate-ocr
    (declare (no-loop true))
        ?amount-value <- (amount-value (page ?page) (text ?text) )
        (not (exists (allocation-entity (page ?page) (source ocr) ) ) )
=>
    (assert (allocation-entity (page ?page) (source ocr) ) )
)

(defrule allocate-amount
    ?amount-value <- (amount-value (page ?page) (text ?text) )
=>
    (assert (allocation-amount (page ?page) (amount ?text) ) )
)

(defrule retract-vague-ocr-amount-allocations
    (declare (salience -80))
    ?allocation-amount <- (allocation-amount (page ?page) (amount ?amount) )
    ?allocation-entity <- (allocation-entity (page ?page) (source ocr)
(entity ?entity) )

    (test
        (and
            (eq* (str-cat ?amount) "0")
            (eq* ?entity nil)
        )
    )
=>
    (printout t "retract zero amount + nil ocr allocation"crlf)
    (retract ?allocation-amount)
    (retract ?allocation-entity)
)

(run)

-------------------------------------JESS
OUTPUT--------------------------------------------------------------
 ==> Focus MAIN
 ==> f-0 (MAIN::initial-fact)
 ==> f-1 (MAIN::amount-value (page 0) (text 0))
==> Activation: MAIN::allocate-ocr :  f-1,
MAIN::allocate-ocr: +1+1+1+1+2+a+2+a+2+a+2+t
==> Activation: MAIN::allocate-amount :  f-1
MAIN::allocate-amount: =1=1+t
MAIN::retract-vague-ocr-amount-allocations: +1+1=1=1+2+t
FIRE 1 MAIN::allocate-ocr f-1,
 ==> f-2 (MAIN::allocation-entity (source ocr) (page 0) (entity nil))
FIRE 2 MAIN::allocate-amount f-1
 ==> f-3 (MAIN::allocation-amount (page 0) (amount 0))
==> Activation: MAIN::retract-vague-ocr-amount-allocations :  f-3, f-2
FIRE 3 MAIN::retract-vague-ocr-amount-allocations f-3, f-2
retract zero amount + nil ocr allocation
 <== f-3 (MAIN::allocation-amount (page 0) (amount 0))
 <== f-2 (MAIN::allocation-entity (source ocr) (page 0) (entity nil))
==> Activation: MAIN::allocate-ocr :  f-1,
FIRE 4 MAIN::allocate-ocr f-1,
 ==> f-4 (MAIN::allocation-entity (source ocr) (page 0) (entity nil))
 <== Focus MAIN
4

Reply via email to