<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Short circuiting evaluations on LHS</TITLE>
<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=450403707-07042008><FONT face=Arial
color=#0000ff size=2>All facts are matched against all patterns upon insertion
into working memory. The (Drools) techniques you describe affect the execution
of activations (i.e. RHS) not pattern matching.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008><FONT face=Arial
color=#0000ff size=2>I think (but it's a vague recollection) however that the
sequence of patterns has an affect (so you want most restrictive first and least
restrictive last). So my thought would be to try to add a pattern to the start
of each rule that checks whether there are more than one survivor before the
other (more expensive) patterns. Just a thought from what I recall - I haven't
tried it:-</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008><FONT face=Arial
color=#0000ff size=2>rule "expensive"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008> <FONT
face=Arial color=#0000ff size=2>when</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008><FONT face=Arial
color=#0000ff size=2> ArrayList( size
> 1 ) from collect( SuperClassOfAllFacts( ) )</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=450403707-07042008> <FONT
face=Arial color=#0000ff size=2>someExpensivePattern( )</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008> <FONT
face=Arial color=#0000ff size=2>then</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=450403707-07042008> <FONT
face=Arial color=#0000ff size=2>something();</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008> <FONT
face=Arial color=#0000ff size=2>end</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=450403707-07042008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV><BR>
<BLOCKQUOTE dir=ltr 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>Newman,
Jason<BR><B>Sent:</B> 03 April 2008 20:07<BR><B>To:</B>
rules-users@lists.jboss.org<BR><B>Subject:</B> [rules-users] Short circuiting
evaluations on LHS<BR></FONT><BR></DIV>
<DIV></DIV><!-- Converted from text/rtf format -->
<P><FONT face=Arial size=2>I am currently using Drools 4.0 to determine the
best choice out of a data set based on business rules. The rules eliminate
(retract) facts until a single fact survives, and is used for additional
processing. I have found Drools to be a great solution for this problem, and
plan to role it out for additional survivor rules. My problem is in
optimization - this is essentially a batch processing application, and speed
is very important (of course it is - show me the case where it isn't,
right?).</FONT></P>
<P><FONT face=Arial size=2>Some of the later evaluations in the rules are
fairly expensive (invoking complex queries from the database), and generally
apply to only a small set of the use cases. For most use cases, the survivor
will have been determined after the first or second rule, so I only want to
perform the expensive evaluations if necessary. I have not found a way to
avoid or schedule the LHS evaluations from firing when inserting the fact into
the working memory. I have played around with agenda groups and rule flows,
but haven't had any luck. The only way I can think of at this point is to
break my rules into separate rule bases, and "manually" copy survivors from
one working memory to the next, performing my own short circuiting outside of
the rules being fired. </FONT></P>
<P><FONT face=Arial size=2>Is there any other technique that I have missed?
From a maintenance standpoint, I would prefer to be able to use one rule
base/rule flow to manage the rules (there are only about 10 total rules, so
the base is not very large - and I would have to break it into 4 or 5
different rule bases, which seems like it will be a pain across the 5
different areas I need to implement the rules.)</FONT></P>
<P><FONT face=Arial size=2>Thanks,</FONT> </P>
<P><FONT face=Arial size=2>-Jason</FONT> </P><BR><PRE>The information transmitted (including attachments) is
covered by the Electronic Communications Privacy Act,
18 U.S.C. 2510-2521, is intended only for the person(s) or
entity/entities to which it is addressed and may contain
confidential and/or privileged material. Any review,
retransmission, dissemination or other use of, or taking
of any action in reliance upon, this information by persons
or entities other than the intended recipient(s) is prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
</PRE></BLOCKQUOTE></BODY></HTML>