Menu

#19 Duplicate Class-Tests in RETE-ROOTS

open
nobody
None
5
2008-02-21
2008-02-21
No

In RELEASE_3_2 duplicate class tests to be added to RETE-ROOTS.

To see this, try evaluating the following code which makes 100 identical rules, then displays RETE-ROOTS, which shows that 100 identical class-tests have been added to the network:

(in-package :lisa-user)

(clear)
(reset)
(defclass x () (a b c))

(defclass y () (a b c))

(loop for i from 1 to 100
for rule-name = (intern (format nil "R~A" i))
do (eval `(defrule ,rule-name ()
(x (a ?v))
=>
(princ "!"))))

(format t "(lisa::rete-roots (lisa:rete-network (lisa:current-engine)))~%~
=> ~S~%"
(lisa::rete-roots (lisa:rete-network (lisa:current-engine))))

The last form will produce

(lisa::rete-roots (lisa:rete-network (lisa:current-engine)))
=> #<EQL Hash Table{100} 200DF7C7>

It seems that this problem is due to a recent change made to src/rete/reference/rete-compiler.lisp to address a problem reported by Andrew Philpot (9/6/2007). It seems that COPY-NODE-TEST-TABLE always receives an empty hash-table. As a result, FIND-TEST always creates a new class-test.

Since add-token to network loops over all the class-tests, this can add some overhead to networks where many rules match patterns of the same class.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB