<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face=Arial
color=#0000ff size=2>I'm not sure as LHS's are evaluated when facts are inserted
not when fireAllRules (or execute) is called.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face=Arial
color=#0000ff size=2>You can prevent the RHS from activating by using (for lack
of a better name) "flag facts" (but this doesn't solve your problem); for
example:-</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face="Courier New"
color=#0000ff size=2>rule "avoid expense"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT
face="Courier New"> <FONT color=#0000ff
size=2>when</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT
face="Courier New"> <FONT
color=#0000ff size=2>not exists Flag()</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT
face="Courier New"> <FONT
color=#0000ff size=2>AnotherFact( ) from
someExpensiveServiceCall</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT
face="Courier New"> <FONT color=#0000ff
size=2>then</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT
face="Courier New"> <FONT
color=#0000ff size=2>// Do something</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT
face="Courier New"> <FONT color=#0000ff
size=2>end</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face="Courier New"
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face=Arial
color=#0000ff size=2>Don't forget though that if you share LHS patterns across
multiple rules they will share the same nodes in the RETE network, so although
you might be aware that the expensive calls are not required for some rules they
might be required for other rules and hence you'll need to perform the expensive
call when the facts are inserted in order for the other rules to activate.
Perhaps if you better describe your use-case there might be a better
solution.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face=Arial
color=#0000ff size=2>With kind regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=314420309-06022008><FONT face=Arial
color=#0000ff size=2>Mike</FONT></SPAN></DIV><BR>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Jai
Vasanth<BR><B>Sent:</B> 05 February 2008 19:35<BR><B>To:</B> Rules Users
List<BR><B>Subject:</B> Re: [rules-users] Grouping rules<BR></FONT><BR></DIV>
<DIV></DIV>I had another question on these lines. Is there a way to preven
even the LHS from evaluating for certain cases ? A few of my LHS computation
involve some expensive service calls and I would like to avoid unless and
until it is asolutely necessary.<BR><BR>Thanks <BR><BR>Jai <BR><BR>
<DIV class=gmail_quote>On Feb 1, 2008 8:35 AM, Jai Vasanth <<A
href="mailto:jaivasanth@gmail.com">jaivasanth@gmail.com</A>> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Thanks.
That helped.
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c><BR><BR>
<DIV class=gmail_quote>On Feb 1, 2008 7:31 AM, Anstis, Michael (M.) <<A
href="mailto:manstis1@ford.com" target=_blank>manstis1@ford.com</A>>
wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Excuse
me if you already understand but there is a difference between rule
patterns being evaluated and their consequence
running.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Rules
LHS are evaluated when objects are inserted into working memory whereas
the consequence fires when you call fireAllRules();</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>The
rules whose activations are executed are those in the given Agenda Group;
thereafter those not in any agenda group execute. So if all rules are in
an Agenda Group you should be OK.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Of
course they don't prevent all rule patterns from being checked as
objects are inserted into WM (which has a performance impact) but this is
what the RETE network was designed to optimise. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>You
could try another configuration (but I think Agenda Groups are
probably the preference by design). This gives complete isolation - but I
haven't tried it so it might not even be possible ;-)</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>global WorkingMemory wm;</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>global RuleBase rbX;</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT color=#0000ff size=2>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>global RuleBase rbY;</FONT></SPAN></DIV></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>rule "Group X"</FONT></SPAN></DIV>
<DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT color=#0000ff
size=2>when</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT
color=#0000ff size=2>Fact( attribute == "condition1"
)</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT color=#0000ff
size=2>then</FONT></FONT></SPAN></DIV></DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT
color=#0000ff size=2>wm =
rbX.newStatefulSession();</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT
color=#0000ff size=2>wm.fireAllRules();</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>end</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>rule "Group Y"</FONT></SPAN></DIV>
<DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT color=#0000ff
size=2>when</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT
color=#0000ff size=2>Fact( attribute == "condition2"
)</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT color=#0000ff
size=2>then</FONT></FONT></SPAN></DIV></DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT
color=#0000ff size=2>wm =
rbY.newStatefulSession();</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT
face="Courier New"> <FONT
color=#0000ff size=2>wm.fireAllRules();</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>end</FONT></SPAN></DIV></SPAN></DIV></BLOCKQUOTE>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Good
luck.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Mike</FONT></SPAN></DIV><BR>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2>
<DIV><B>From:</B> <A href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A>] <B>On Behalf Of
</B>Jai Vasanth<BR></DIV><B>Sent:</B> 01 February 2008
15:07<BR><B>To:</B> Rules Users List<BR><B>Subject:</B> Re:
[rules-users] Grouping rules<BR></FONT><BR></DIV>
<DIV>
<DIV></DIV>
<DIV>
<DIV></DIV><BR>Thanks for responding <BR>Yes, I did consider
agenda groups, but I thought agenda groups only ordered execution in a
particular fashion, so if Rule "pick group X" fires then it would make
sure that rules in Agenda Group X fire first before the remaining but
the remaining would fire eventually. Is my understanding correct
?<BR>I am looking for a solution for completely isolating a rule
set conditioned on an object attribute.<BR><BR>
<DIV class=gmail_quote>On Feb 1, 2008 12:46 AM, Anstis, Michael (M.)
<<A href="mailto:manstis1@ford.com"
target=_blank>manstis1@ford.com</A>> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>What about Agenda Groups?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>Rule "pick group X"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>when</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT
size=2> <FONT color=#0000ff>Fact( attribute =
"condition1" )</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>then</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT
size=2> <FONT color=#0000ff>drools.setFocus("Group
X")</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>end</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>Rule "pick group Y"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>when</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT
size=2> <FONT color=#0000ff>Fact( attribute =
"condition2" )</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>then</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT
size=2> <FONT color=#0000ff>drools.setFocus("Group
Y")</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>end</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>Rule "Group X1"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>Agenda Group "Group X"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>when</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT
size=2> <FONT color=#0000ff>Smurf(
)</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>then</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT
size=2> <FONT color=#0000ff>// Do
something</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>end</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>Rule "Group X2"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>Agenda Group "Group X"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>when</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT
size=2> <FONT color=#0000ff>Smurfette(
)</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>then</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT
size=2> <FONT color=#0000ff>// Something
else</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>end</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>etc</FONT></SPAN></DIV><BR>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A>] <B>On Behalf
Of </B>Jai Vasanth<BR><B>Sent:</B> 31 January 2008
19:45<BR><B>To:</B> <A href="mailto:rules-users@lists.jboss.org"
target=_blank>rules-users@lists.jboss.org</A><BR><B>Subject:</B>
[rules-users] Grouping rules<BR></FONT><BR></DIV>
<DIV>
<DIV></DIV>
<DIV>
<DIV></DIV>Hi,<BR><BR><BR> I am building a system where I would
need to fire different sets of rules based on some attribute in the
fact object. <BR><BR>Here are someways which I thought of, I
was wondering if there was something better than that.<BR><BR>1) I
could do this by creating different sessions based on the data
attrbute (different sessions would have different rule packages
based on the attribute)<BR><BR>or <BR><BR>2) Have all the rules fire
(all the different sets of rules) irrespective of the attribute and
have them insert fact new objects into the working memory. In the
second round of rules, collect the (newly made) fact objects
based on the attribute and take that action.<BR><BR><BR><BR>Thanks
<BR><BR>Jai
<BR><BR><BR><BR><BR></DIV></DIV></BLOCKQUOTE></DIV><BR>_______________________________________________<BR>rules-users
mailing list<BR><A href="mailto:rules-users@lists.jboss.org"
target=_blank>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><BR></BLOCKQUOTE></DIV><BR></DIV></DIV></BLOCKQUOTE></DIV><BR>_______________________________________________<BR>rules-users
mailing list<BR><A href="mailto:rules-users@lists.jboss.org"
target=_blank>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><BR></BLOCKQUOTE></DIV><BR></DIV></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>