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

Reply via email to