Thanks to you both. Unfortunately, as I tried to emphasize below, the apparent structure in the values being matched is an artifact of the data generation, and will not hold in general.
The case I'm testing, where I have large numbers of rules with an exceedingly simple structure, is just one special case of a more general problem. I have already considered the possibility of solving this use case in a different way, such as through database or hashtable lookup, and am in the process of determining whether that is necessary by doing performance testing on Jess and other search engines. Given that rules engines work great for most of my other use cases, where there is a natural branching structure, it would obviously be best for me if I could use the same tool everywhere. Let's say I'm stuck with a ruleset structure similar to the one below. Is the best matching time I can hope for from Jess linear in the number of rules? I know Jess has tuning parameters, such as the node index hash value mentioned in Dr. Friedman-Hill's book, which can affect performance of different kinds of rules. Are there any parameters that might help here? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Orchard, Bob Sent: Friday, June 16, 2006 8:20 PM To: [email protected] Subject: RE: JESS: Jess performance question As Dave says it's not clear what you are trying to do but one rule could do all of this and I suspect there would be performance gains ... (defrule oneRule (R (a ?a) (_r ?o)) => (?o a (integer (sub-string 2 (str-length ?a) ?a))) ) Simpler if slot 'a' contains an integer, then (defrule oneRule (R (a ?a) (_r ?o)) => (?o a ?a) ) BUT with assumption that you really have strings that are always "annnnn" in slot a ... with 'a' as the first character of the string and then the rest of the characters are digits. Bob Orchard -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Friday, June 16, 2006 5:03 PM To: [email protected] Subject: Re: JESS: Jess performance question Hello, It is unclear what your intentions are, but it may be that you are simply using the wrong tool for the task. Another possibility is that you have inverted the use of facts and rules with respect to your problem. (I.e., usually facts are used to represent data, rather than rules.) To understand why you're seeing such poor performance, you should study how the Rete algorithm works. It is the basis for efficient pattern matching in JESS. Loosely speaking, a large ruleset will perform better if the patterns can grow the Rete network into a heavily branching tree. In your case, the automated ruleset generation appears to be tending a plush lawn of grass. The result is that every fact asserted is being compared to each and every blade! You'll need to partition your ruleset by adding additional patterns so that facts are quickly matched against entire branches at once. Look on the web site for tips on writing and ordering rule patterns. Hope this helps, Dave Barnett On Fri, 16 Jun 2006, Adair, John wrote: > I have a ruleset that looks like this: > (deftemplate MAIN::R > (slot _r (type OBJECT)) > (slot a (type STRING))) > (defrule rule-0 (R (a "a0") (_r ?o)) => (?o a 0)) > .. > (defrule rule-499999 (R (a "a499999") (_r ?o)) => (?o a 499999)) > > The fact that the numeric part of the rule name and the int argument > in the method call are the same is not a coincidence, but the > particular value of the "a" slot that I'm matching on is because of > the data I generated the ruleset from, not because the rules will > always look like this. > > I seem to be spending a lot of time asserting facts, the main time > cost of which I assume to be in pattern matching. When I have 5,000 > rules, it takes about 32 seconds to assert 100,000 facts. When I have > 20,000 rules, it takes about 160 seconds. This worse-than-linear > degradation continues as I add rules approaching my target of 500,000 > rules (which I haven't been able to run successfully yet). > > Is there anything I can do to my ruleset to improve performance? > ---------------------------------------------------------------------- > -- > <John S. Adair><[EMAIL PROTECTED]><It's turtles all the way down.> > ------------------------------------------------------------------------ > > > -------------------------------------------------------------------- > 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] -------------------------------------------------------------------- -------------------------------------------------------------------- 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] --------------------------------------------------------------------
