no-loop prevents working memory changes made on the right-hand-side of
a rule from reactivating that same rule. Here, it is the retractions
done by the rule retract-vague-ocr-amount-allocations which are
reactivating allocate-ocr; this is just how things are supposed to
work.
On Mar 5, 2009, at 11:27 AM, yuping he wrote:
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
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012 [email protected]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
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].
--------------------------------------------------------------------