<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 10 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
pre
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle19
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=blue>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I only spent a day reading about Drools.
The rules I presented looks simple but the idea was to know if the only
solution is to extract all the required data and pass to the rules engine. Or
the rules can be written in such a way that is can get the required data from
the raw data.</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Your and Wolfgang example shows that rules
can be written over raw data as well as rules can talk to database. I will go
through the documentation to grasp the power of drools.</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Thanks</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Bhushan</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b>
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Edson Tirelli<br>
<b><span style='font-weight:bold'>Sent:</span></b> Tuesday, May 19, 2009 8:48
PM<br>
<b><span style='font-weight:bold'>To:</span></b> Rules Users List<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [rules-users] can
drools support complex rules</span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><br>
Your question is funny. First you ask if Drools is
capable of managing complex rules and then you mention examples of extremely
simple rules? :) <br>
<br>
Drools is FOL complete and so can represent any well
formed First Order Logic expression. Anyway, I will use this message to
advertise some of the temporal reasoning features that we have on Drools 5 for
the benefit of anyone interested.<br>
<br>
There are several ways of authoring such rules, depending
on how you model your problem domain. One possible way of doing them is:<br>
<br>
#1: <br>
rule "</span></font><font size=2 color=black face=Arial><span
style='font-size:11.0pt;font-family:Arial;color:black'>If a customer login
within 5 minutes from two different locations, mark the user invalid."<br>
when<br>
$l1 : CustomerLogin( )<br>
$l2 : CustomerLogin( userId == l1.$id, location != $<a
href="http://l1.id">l1.id</a>, timestamp after[0s, 5m] $l1.timestamp )<br>
then<br>
// mark user as invalid <br>
end<br>
<br>
In the previous example I assumed both login objects would be in working memory,
but you can easily query for the previous login in an external datasource,
pulling the data from the previous login on-demand for the reasoning cycle.<br>
<br>
#2:<br>
rule "If the customer location is not on a list of valid locations, mark
the user invalid"<br>
when<br>
$l : CustomerLogin( location not memberOf
$validLocations )<br>
then<br>
// mark the user invalid<br>
end<br>
<br>
In the above rule, I assume the valid locations list is a global list, but you
can as easily model locations as being facts on your working memory or a
service end point that you can call to validate the location.<br>
<br>
#3:<br>
rule “Customer login from more than 5 locations in the last one
month”<br>
when<br>
$customer : Customer( $id : id )<br>
$locations : Set( size > 5 ) from accumulate(<br>
CustomerLogin( customerId == $id, $loc : location ) over window:time( 30d ),<br>
collectSet( $loc ) )<br>
then<br>
// do something as the customer logged in from more than 5
locations in the last 30 days<br>
end<br>
<br>
In the previous rule I decided to use sliding windows, just to show how that
feature can be used to simplify rules, but again, there are several ways of
doing it.<br>
<br>
I strongly recommend you read Drools manual. <br>
<br>
<a href="http://www.jboss.org/drools/documentation.html">http://www.jboss.org/drools/documentation.html</a><br>
<br>
Cheers,<br>
Edson<br>
<br>
<br>
</span></font></p>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>2009/5/19 Bhushan Bhangale <<a
href="mailto:bhushan_bhangale@kaleconsultants.com">bhushan_bhangale@kaleconsultants.com</a>></span></font></p>
<div link=blue vlink=purple>
<div>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>Hi,</span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> </span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>I
recently came across Drools. I gone through the documentation and the examples
provide are quite simple. I want to know if it can be really applied to complex
real world problems.</span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> </span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>Take
for example,</span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> </span></font></p>
<p style='margin-right:0in;margin-bottom:0in;margin-left:.25in;margin-bottom:
.0001pt;line-height:150%'><font size=2 color=black face=Arial><span
style='font-size:11.0pt;line-height:150%;font-family:Arial;color:black'>If a
customer login within 5 minutes from two different locations, mark the user
invalid.</span></font></p>
<p style='margin:0in;margin-bottom:.0001pt;line-height:150%'><font size=2
color=black face=Arial><span style='font-size:11.0pt;line-height:150%;
font-family:Arial;color:black'>How can I write the above rule in drools? I have
the data when the user last logged in and the data of current login. You can
say two objects.</span></font></p>
<p style='margin:0in;margin-bottom:.0001pt;line-height:150%'><font size=2
color=black face=Arial><span style='font-size:11.0pt;line-height:150%;
font-family:Arial;color:black'> </span></font></p>
<p style='margin:0in;margin-bottom:.0001pt;line-height:150%'><font size=2
color=black face=Arial><span style='font-size:11.0pt;line-height:150%;
font-family:Arial;color:black'>May be my understanding is wrong but looks like
based on rule I have to pass all the required data. How can then at real time
new rules can be added?</span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> </span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>For
example,</span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> </span></font></p>
<p style='margin-right:0in;margin-bottom:0in;margin-left:.25in;margin-bottom:
.0001pt;line-height:150%'><font size=2 color=black face=Arial><span
style='font-size:11.0pt;line-height:150%;font-family:Arial;color:black'>If the
customer location is not on a list of valid locations, mark the user invalid.</span></font></p>
<p style='margin:0in;margin-bottom:.0001pt;line-height:150%'><font size=2
color=black face=Arial><span style='font-size:11.0pt;line-height:150%;
font-family:Arial;color:black'> </span></font></p>
<p style='margin:0in;margin-bottom:.0001pt;line-height:150%'><font size=2
color=black face=Arial><span style='font-size:11.0pt;line-height:150%;
font-family:Arial;color:black'>For the above rule I need to pass a list of
valid locations as well.</span></font></p>
<p style='margin:0in;margin-bottom:.0001pt;line-height:150%'><font size=2
color=black face=Arial><span style='font-size:11.0pt;line-height:150%;
font-family:Arial;color:black'> </span></font></p>
<p style='margin:0in;margin-bottom:.0001pt;line-height:150%'><font size=2
color=black face=Arial><span style='font-size:11.0pt;line-height:150%;
font-family:Arial;color:black'>Now how about “Customer login from more
than 5 locations in the last one month”?</span></font></p>
<p style='margin:0in;margin-bottom:.0001pt;line-height:150%'><font size=2
color=black face=Arial><span style='font-size:11.0pt;line-height:150%;
font-family:Arial;color:black'> </span></font></p>
<p style='margin:0in;margin-bottom:.0001pt;line-height:150%'><font size=2
color=black face=Arial><span style='font-size:11.0pt;line-height:150%;
font-family:Arial;color:black'>Thanks</span></font></p>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=320
style='width:240.0pt'>
<tr>
<td style='padding:0in 0in 0in 0in'>
<p><b><font size=1 color="#4e81c4" face=Verdana><span style='font-size:8.0pt;
font-family:Verdana;color:#4E81C4;font-weight:bold'>Mr. Bhangale Bhushan</span></font></b><font
size=1 color="#4e81c4" face=Verdana><span style='font-size:8.0pt;font-family:
Verdana;color:#4E81C4'><br>
<i><span style='font-style:italic'>Associate Manager</span></i><br>
<b><span style='font-weight:bold'>Kale Consultants Ltd.</span></b><br>
<a href="mailto:bhushan_bhangale@kaleconsultants.com" target="_blank"><font
color="#4e81c4"><span style='color:#4E81C4;text-decoration:none'>bhushan_bhangale@kaleconsultants.com</span></font></a><br>
tel: <a
href="http://www.plaxo.com/click_to_call?lang=en&src=jj_signature&To=%2B91+%280%29206+608+3777&Email=bhushan_bhangale@kaleconsultants.com"
target="_blank" title="Click to call. Cheap rates & no headset required!"><font
color="#4e81c4"><span style='color:#4E81C4;text-decoration:none'>+91 (0)206
608 3777</span></font></a><br>
<a href="http://www.kaleconsultants.com" target="_blank"><font color="#4e81c4"><span
style='color:#4E81C4;text-decoration:none'>http://www.kaleconsultants.com</span></font></a>
</span></font></p>
</td>
<td style='padding:0in 0in 0in 0in'>
<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'> </span></font></p>
</td>
</tr>
<tr height=10 style='height:7.5pt'>
<td colspan=2 height=10 style='padding:0in 0in 0in 0in;height:7.5pt'>
<p><font size=1 face="Times New Roman"><span style='font-size:8.0pt'> </span></font></p>
</td>
</tr>
<tr>
<td colspan=2 style='padding:0in 0in 0in 0in'>
<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'> </span></font></p>
</td>
</tr>
</table>
<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'> </span></font></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
<pre><font size=2 face="Courier New"><span style='font-size:10.0pt'>Disclaimer: This email (including any attachments) is intended for the sole</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>use of the recipient/s and may contain material that is CONFIDENTIAL. Any</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>unauthorized disclosure / copying / distribution or forwarding of this message </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>or part is STRICTLY PROHIBITED. If you have erroneously received this message,</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>please delete it immediately and notify the sender. No liability is assumed for</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>any errors and/or omissions in the contents of this message. Information in </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>this message that does not relate to the official business of this Company</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>shall be understood as neither given nor endorsed by it. If verification is</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>required please request a hard-copy version. </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>To know more about Kale Consultants, visit <a
href="http://www.kaleconsultants.com" target="_blank">www.kaleconsultants.com</a> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>----------</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><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></span></font></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
<br clear=all>
<br>
-- <br>
Edson Tirelli<br>
JBoss Drools Core Development<br>
JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a></span></font></p>
</div>
<BR><PRE>
Disclaimer: This email (including any attachments) is intended for the sole
use of the recipient/s and may contain material that is CONFIDENTIAL. Any
unauthorized disclosure / copying / distribution or forwarding of this message
or part is STRICTLY PROHIBITED. If you have erroneously received this message,
please delete it immediately and notify the sender. No liability is assumed for
any errors and/or omissions in the contents of this message. Information in
this message that does not relate to the official business of this Company
shall be understood as neither given nor endorsed by it. If verification is
required please request a hard-copy version.
To know more about Kale Consultants, visit www.kaleconsultants.com
-=-=-=-=-=-=-=-=-=-
</pre><BR></body>
</html>