hi,


I defined the following Fact:

(deftemplate triple
    (slot subject)
    (slot property)
    (slot object))


Now I have the following 2 rules:

;rule1:
(defrule RULE-1
    (and
        (triple (subject ?X) (property "Weblog.entry") (object ?Y))
        (triple (subject ?Y) (property "Entry.tag") (object ?T)))
    =>
    (assert
        (triple (subject ?X) (property "Weblog.tag") (object ?T))))

;rule2:
(defrule RULE-2
                 
        (triple (subject ?X) (property "Weblog.tag") (object ?T))
        (triple (subject ?T) (property "Tag.value") (object ?V))
        (triple (subject ?Y) (property "Weblog.tag") (object ?G))
        (triple (subject ?G) (property "Tag.value") (object ?V))
    =>
        (assert
            (triple (subject ?X) (property "Weblog.related") (object ?Y))))


As you can see, if rule1 fires, rule2 can fire as well, because rule1 creates new facts which match the head of rule2.
I´m currently experiencing a performance problem, if I use this rules under the same module (under MAIN).

In my usecase it would be semanticly correct if rule1 fires first until no other facts are available and then rule2. So I need an execution Control.
Therefore I tried to use Modules but for some reason they didnt improve the performance. The moduled version looks like this:


(deftemplate triple
    (slot subject)
    (slot property)
    (slot object))

(defmodule M-RULE-1)
(defrule RULE-1
    (and
        (MAIN::triple (subject ?X) (property "Weblog.entry") (object ?Y))
        (MAIN::triple (subject ?Y) (property "Entry.tag") (object ?T)))
    =>
    (assert
        (MAIN::triple (subject ?X) (property "Weblog.tag") (object ?T))))

(defmodule M-RULE-2)
(defrule RULE-2
                 
        (MAIN::triple (subject ?X) (property "Weblog.tag") (object ?T))
        (MAIN::triple (subject ?T) (property "Tag.value") (object ?V))
        (MAIN::triple (subject ?Y) (property "Weblog.tag") (object ?G))
        (MAIN::triple (subject ?G) (property "Tag.value") (object ?V))
    =>
        (assert
            (MAIN::triple (subject ?X) (property "Weblog.related") (object ?Y))))

(focus M-RULE-2)
(focus M-RULE-1)


So I would like to execute Module M-Rule-1 first and M-Rule-2 second.
Im I doing something wrong ?


thanx in advance,
Andreas

Reply via email to