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 <jason.c.mor...@gmail.com> 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
> consult...@morris-technical-solutions.com
> (517) 304-5883
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
> in the BODY of a message to majord...@sandia.gov, NOT to the list
> (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
> --------------------------------------------------------------------
>
>




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------

Reply via email to