Hi!

Considering your first question I have only used backward chaining with unordered facts and it worked well. You have to make sure, though, that the deftemplate is defined before (!) issuing the (do-backward-chaining my-template) command. Otherwise, Jess will automatically create a template for an ordered fact.

The difference between your approach and mine is that I never (!) use ordered facts. So I played with your rules and - bingo - it worked as soon as I made (person) an unordered fact, too. Here is your modified example:

(deftemplate person
        (slot id))
       
(deftemplate something
                 (slot id))

(do-backward-chaining something)

(defrule create-something
                 (need-something (id ?i))
=>
                 (assert (something (id ?i)))
)

(defrule test-rule
                 (person (id ?i))
                 (something (id ?i))
=>
                 (assert (foo 1 2))
                 (printout t "Created something: " ?i crlf)
)

(reset)
(assert (person (id test-person)))
(run)


I don't know why the extended version works and your's does not. Might be a bug or a feature ;-)

Greetings

Thomas

________________________________

Dipl.-Inform. Thomas Barnekow

Fraunhofer IAO, Competence Center Software Technology
mail: Nobelstra�e 12, D-70569 Stuttgart, Germany
phone: +49 (0) 711 / 970 - 2346
fax: +49 (0) 711 / 970 - 2300
mobile: +49 (0) 172 / 7126018
email: [EMAIL PROTECTED]
web: http://www.swt.iao.fhg.de




Ryan Eberhard <[EMAIL PROTECTED]>
Gesendet von: [EMAIL PROTECTED]

02.03.00 15:37
Bitte antworten an Ryan Eberhard

       
        An:        "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
        Kopie:        
        Thema:        JESS: Unordered facts and backward chaining



Can backward chaining be used with unordered facts, i.e. facts that have
slots and where the "need" matches on the necessary slot values?  This seems
to work, but there are instances where I expect rules to be active (and to
fire), but they are not.

For example,

(deftemplate something
                (slot id))

(do-backward-chaining something)

(defrule create-something
                (need-something (id ?i))
=>
                (assert (something (id ?i)))
)

(defrule test
                (person ?i)
                (something (id ?i))
=>
                (printout t "Created something: " ?i crlf)
)

(reset)
(assert (person test-person))
(run)

After the "assert", create-something is on the agenda.  After the run, the
facts are:

f-0   (initial-fact)
f-1   (person test-person)
f-2   (need-something (id test-person))
f-3   (something (id test-person))
For a total of 4 facts.

However, the test rule is not on the agenda and has not fired.  Is this the
correct behavior or am I missing something?

Also, do deftemplates that extend from reactive deftemplates automatically
become reactive?

Thanks again,
Ryan Eberhard
---------------------------------------------------------------------
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]
---------------------------------------------------------------------



Reply via email to