Re: JESS: RE: Cross post from the CLIPS user group - k closest partial matches

"Wolfgang Laun" <[email protected]>
Newsgroups gmane.comp.java.jess
Message-ID <4989_1284985428_o8KCIwNd006730_AANLkTi=FoOXGVGA+OVKdL0aMhj5SH4O7vxtEJCWX+PMz@mail.gmail.com>
IIRC from my dallyings with Jess, and assuming that the facts and
rules in question are all following the same simple model as the
presented ones:

iterate over all facts in WM and create a set S of fact names with
existing facts.

iterate over all rules in Rete.listDefrules()
   iterate over its ConditionalElements
      if it is a Pattern,
         get the Fact name
         count
   end
   compute match count/pattern count
end

Basically simple if my assumptions are met. Otherwise, a not very well
defined problem anyway.

-W

On 19 September 2010 19:34, Jason Morris <[email protected]> wrote:
> Hi all,
> I was skimming the CLIPS user group, saw this question, and thought it
> interesting enough to toss to the Jess group.  It's not my personal
> post :-)
>
> The CLIPS user asked:
>
> "...What is the most efficient way to find the first K-nearest rules
> partially matching the current facts? For example, if a rule has 2
> patterns, and only one pattern matches the current facts, then that
> rule would be assigned a fitness of 1/2.
>
> Ideally, I'd like to do something like:
> e.g.
> (defrule rule-1
> (myfact ?value1)
> (otherfact ?value2)
> (mylastfact ?value3)
> =>
> (assert (sumfact (+ ?value1 ?value2 ?value3)))
> )
> (defrule rule-2
> (myfact ?value1)
> (otherfact ?value2)
> =>
> (assert (sumfact (+ ?value1 ?value2 ?value3)))
> )
> (deffacts startup (myfact 123))
> (reset)
> (run)
> (find-k-nearest-matches 5)
> => (rule-2 0.5 rule-1 0.333333)
>
> Obviously, I could use the (matches rule-1) function, and parse the
> results to get the match fitness. However, in order to find the K-
> nearest, I'd need to do this for every rule in existence, which would
> be prohibitively expensive. Is there any way to take advantage of
> Clips' internal representation of the rules (via RETE), to do this
> search more efficiently?"
>
> Cheers,
> Jason
> ------------------------------------------------------
> Morris Technical Solutions LLC
> [email protected]
> (517) 304-5883
>
>
> --------------------------------------------------------------------
> 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].
> --------------------------------------------------------------------
>
>




--------------------------------------------------------------------
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].
--------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.