You technical description isn’t at all accurate.
You need to read up on Rete Trees, I’m still a bit vague on them myself but a hopefully slightly more accurate description is as follows:
When the rules are compiled each of their conditions is converted to a node on the graph. If rules share the same initial set of conditions then they will share those nodes in the tree. These nodes contain
references to the data in the working memory that they match against. When an object is added or updated in working memory then the knowledge of this allows just the relevant nodes to be re-evaluated trickling down the tree. If a leaf node is reached with
a particular set of Objects then this means that the rule can then be placed on the activation queue with that set of data.
This Rete graph is designed to solve the problem you are describing which is why we have a rules engine rather than doing the naive procedural implementation of ‘firing rules’. Of course if all your rules are
disjoint but rely on the same set of Objects then there isn’t any choice but to evaluate all the rules, after all they may all do different things and normally you want multiple rules to fire.
How you write your rules can also have a massive impact on performance and the shape of the graph (which you can see in eclipse), are you worrying about this purely from a theoretical viewpoint or are you having
a concrete performance problem?
Hope this helps your understanding,
Thomas
From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
On Behalf Of Nikhil S. Kulkarni
Sent: 11 June 2010 12:27
To: rules-users@lists.jboss.org
Subject: [rules-users] How to break the rules execution if one has been satisfied ??
Hi,
In rules, in a particular rule set, all the when’s are executed. In technical terms, the activation is first created. For all the rules in a rule set the when condition is first evaluated and if the when condition is
satisfied for any rule then the rule is marked as ready to fire. Once all the when part for all the rules are evaluated then all the ones that were marked for fire are fired.
The performance issue that if there are some 1500 rows. Hence, when the rule is fired there are 1500 when conditions that are firstly checked. And only after this the then part is fired. There is no way to break the when
checks on successful satisfaction of a particular rule when.
Example:
If I have say a group of 1000 rules as mentioned below
Rule_1
Salience 1000
When
Some_Conditions_1
Then
Some_Actions_1
Rule_2
Salience 999
When
Some_Conditions_2
Then
Some_Actions_2
.
.
.
Rule_1000
Salience 1
When
Some_Conditions_1000
Then
Some_Actions_1000
Let’s assume that Some_conditions_2 = true
Now even though I have an ordering using salience, the rule engine will still execute all the when conditions (Some_Conditions_1 .. Some_Conditions_1000)
Is it possible for me to break this when evaluation even if one has been satisfied?
Thanks & Regards,
Nikhil S. Kulkarni
|