Have you tried salience?<br><br><div class="gmail_quote">On 23 June 2011 20:20, Joe Ammann <span dir="ltr">&lt;<a href="mailto:joe@pyx.ch">joe@pyx.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Stumbled over this today in a specific case, but my question is about a<br>
general practice (I&#39;m quite new to Drools, 5.2.0.M2 btw). I have a<br>
knowledge session with a fair amount of facts (0.5 Mio) and mostly<br>
simple rules. One rule has a LHS expression that I know will be<br>
expensive to execute, in the example that I encountered this it looks like:<br>
<br>
rule &quot;Count facts&quot;<br>
    when<br>
        all : Number() from accumulate (s : X(), count(s))<br>
        blacklisted : Number() from accumulate (s : X(status ==<br>
X.BLACKLISTED), count(s))<br>
        ....<br>
    then<br>
        ....<br>
end<br>
<br>
I want to execute this rule only after other rules have already executed<br>
(and changed the status of most of the X facts). There&#39;s quite a number<br>
of X facts (~200&#39;000). Most of them have their status modified during<br>
execution of other rules. If I run the rule base without the above<br>
rules, performance is perfect, some tens of seconds. If I activate the<br>
rule, execution never finishes (I stop it after a few minutes, never saw<br>
it finished).<br>
<br>
I *THINK* (correct me if I&#39;m wrong) what happens is that especially the<br>
second expression of the LHS gets executes over and over again whenever<br>
one of the facts is modified by one of the other rules. Makes sense, but<br>
I nevertheless want to try to avoid it.<br>
<br>
Until now I tried unsuccessfully:<br>
- &quot;protect&quot; the rule with a guard fact as the first expression, which is<br>
inserted only late in the processing<br>
- move the rule to another ruleflow-group (or agenda-group) and activate<br>
it only at the end of the processing<br>
- use the rule in a second independent knowledge base and session, and<br>
insert the facts once the first has finished<br>
<br>
I&#39;m perfectly aware that I could solve this specific problem of counting<br>
facts with different techniques, but my question is more general (as the<br>
subject says). Because I have other cases where (as a last resort) I<br>
need to go to a database or online service to get the required<br>
information. It seems that others have similar problems<br>
(<a href="http://drools.46999.n3.nabble.com/Short-circuiting-evaluations-on-LHS-td56379.html" target="_blank">http://drools.46999.n3.nabble.com/Short-circuiting-evaluations-on-LHS-td56379.html</a>).<br>
But in my experience, that technique (&quot;protecting&quot; the expensive pattern<br>
in the LHS with a cheap one that evaluates to false until you really<br>
need the expensive one) does not work. I get the impression that<br>
(contrary to popular experience that a &quot;false&quot; value in an AND sequence<br>
terminates the whole sequence) the drools LHS are processed differently.<br>
<br>
Am I missing something really stupid?!<br>
<font color="#888888"><br>
--<br>
CU, Joe<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>