The Rete algorithm used by Jess allows for multiple different indices and filters at different points in the discrimination network. You can read something about what Jess does in the manual itself, in the chapter on the Rete algorithm.

But as far as indexing for joins like the below: Jess does neither of your two alternatives. It indexes not on all the slots, nor just the first slot; it indexes adaptively on one or more slots that are used in a particular join. So in your rule below, the join between the first two patterns indexes the "first" slot in "s", and the "second" slot in "hyp". The next join indexes "first" in hyp, and "first" in "s".


On Oct 10, 2008, at 5:22 PM, Baxter Young wrote:

Dear Sir,
I am new to Jess and I am not sure how Jess indexes tuples.

It seems that it indexes on all arguments and not only the first
argument (like many prolog systems). I just want to check if this is
correct.

For instance, I have the program below that finds all hyponyms of all
words in english in WordNet.
The find_testAllHyponyms rule, uses the template
        (hyp (first ?synset_id2) (second ?synset_id1))
where the second argument is bound, where the first one is bound.
I get the same time if I compute all the hyponyms (first argument
bound) or all the hypernyms (second argument bound), which brought me
to the conclusion that Jess indexes on both arguments.

Regards,
Paul Fodor

; define templates
(deftemplate s (slot first) (slot second))
(deftemplate hyp (slot first) (slot second))
(deftemplate testAllHyponyms (slot first) (slot second))

(defrule find_testAllHyponyms
        (s (first ?synset_id1) (second ?word1))
        (hyp (first ?synset_id2) (second ?synset_id1))
        (s (first ?synset_id2) (second ?word2))
        =>
        (assert (testAllHyponyms (first ?word1) (second ?word2)))
)

(defquery query-testAllHyponyms
         (testAllHyponyms (first ?first) (second ?second))
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(printout t crlf "wn_s.clp" crlf)
(reset)
(load-facts "wn_s.clp")
;(facts)
(printout t crlf "wn_hyp.clp" crlf)
(load-facts "wn_hyp.clp")
;(facts)
(bind ?tmx (call java.lang.management.ManagementFactory getThreadMXBean)) (deffunction cputime () (return (* (?tmx getCurrentThreadCpuTime) 1E-9)))
; get times
(bind ?starttime_wall (time))
(bind ?starttime_cpu (cputime))
(run)
(bind ?testAllHyponyms_result (run-query* query-testAllHyponyms))
(bind ?count 0)
(while (?testAllHyponyms_result next)
      (printout t "")
      (++ ?count)
)
(printout t "the number of answers = " ?count crlf)
(bind ?endtime_cpu (cputime))
(bind ?endtime_wall (time))
(bind ?walltime (- ?endtime_wall ?starttime_wall))
(bind ?cputime (- ?endtime_cpu ?starttime_cpu))
(printout t "Cpu time = " ?cputime crlf)
(printout t "Wall time= " ?walltime crlf crlf)
;(facts)


--------------------------------------------------------------------
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] .
--------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, 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]
--------------------------------------------------------------------

Reply via email to