Hi all,

I'm trying to group facts based on an attribute. In order to do that, I am creating some baskets (based on values of that attribute) from within the rules, matching the attribute of the facts and dropping the facts in corresponding baskets.
Here's an example:

(defrule II672_Groupby_ "Creates baskets"
(declare (salience 205))
(and
(myobjects_Foo (OBJECT ?Foo_obj)
(industry ?anyvalue)
)
(not
(myobjects_Foobasket (OBJECT ?Foobasket_obj)
(attributevalue ?anyvalue)
)))

=>

(bind ?FB (new myobjects.Foobasket))
(call ?FB setAccountnumber ?acct_no)
(call ?FB setAttributevalue ?anyvalue)
(definstance myobjects_Foobasket ?FB)
)

The 'not' condition ensures that when I run into one value of industry, say 'Manufacturing', it's basket is created, but not again, for another few hundred possible matches on Manufacturing. This works, but I don't think this is the best way to do it.

I know that 'not' CE's are very expensive (I think) when compared to a regular match. I looked up unique CE and 2.8.9 tells me "...unique CE is providing a hint to Jess that.....once it has found the person that matches a given tax form, it doesn't need to look any further. In practice, this can result in performance gains of 20-30% on real problems." Sounded perfect to me. Then I explored the list archives and I found "If you use unique when in fact there actually are multiple matches for a pattern, the results are undefined." So that's not going to work. (Would be nice if this line was added to 2.8.9)

Is there a better way to achieve this.

Appreciate all your help.

Dheeraj

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