<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 &quot;<font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">If
a customer login within 5 minutes from two different locations, mark the user invalid.&quot;<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 &quot;</span></font><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">If
the customer location is not on a list of valid locations, mark the user
invalid&quot;<br>when<br>      $l : CustomerLogin( location not memberOf $validLocations )<br>then<br>      // mark the user invalid<br>end<br></span></font><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;"> <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 </span></font><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">“Customer login
from more than 5 locations in the last one month”<br>when<br>    $customer : Customer( $id : id )<br>    $locations : Set( size &gt; 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><br><div class="gmail_quote">
2009/5/19 Bhushan Bhangale <span dir="ltr">&lt;<a href="mailto:bhushan_bhangale@kaleconsultants.com">bhushan_bhangale@kaleconsultants.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">












<div link="blue" vlink="purple" lang="EN-US">

<div>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Hi,</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; 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: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Take for example,</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p style="margin-right: 0in; margin-left: 0.25in; margin-bottom: 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">If
a customer login within 5 minutes from two different locations, mark the user invalid.</span></font></p>

<p style="margin: 0in 0in 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">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 0in 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;"> </span></font></p>

<p style="margin: 0in 0in 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">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: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">For example,</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p style="margin-right: 0in; margin-left: 0.25in; margin-bottom: 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">If
the customer location is not on a list of valid locations, mark the user
invalid.</span></font></p>

<p style="margin: 0in 0in 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;"> </span></font></p>

<p style="margin: 0in 0in 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">For the above rule I need to pass a
list of valid locations as well.</span></font></p>

<p style="margin: 0in 0in 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;"> </span></font></p>

<p style="margin: 0in 0in 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">Now how about “Customer login
from more than 5 locations in the last one month”?</span></font></p>

<p style="margin: 0in 0in 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;"> </span></font></p>

<p style="margin: 0in 0in 0.0001pt; line-height: 150%;"><font color="black" size="2" face="Arial"><span style="font-size: 11pt; line-height: 150%;">Thanks</span></font></p>

<table style="width: 240pt;" border="0" cellpadding="0" cellspacing="0" width="320">
 <tbody><tr>
  <td style="padding: 0in;">
  <p><b><font color="#4e81c4" size="1" face="Verdana"><span style="font-size: 8pt; font-family: Verdana; color: rgb(78, 129, 196); font-weight: bold;">Mr.
  Bhangale Bhushan</span></font></b><font color="#4e81c4" size="1" face="Verdana"><span style="font-size: 8pt; font-family: Verdana; color: rgb(78, 129, 196);"><br>
  <i><span style="font-style: italic;">Associate Manager</span></i><br>
  <b><b><font face="Verdana"><span style="font-family: Verdana;">Kale
  Consultants Ltd.</span></font></b></b><br>
  <a href="mailto:bhushan_bhangale@kaleconsultants.com" target="_blank"><font color="#4e81c4"><span style="color: rgb(78, 129, 196); text-decoration: none;">bhushan_bhangale@kaleconsultants.com</span></font></a><br>
  tel: <a href="http://www.plaxo.com/click_to_call?lang=en&amp;src=jj_signature&amp;To=%2B91+%280%29206+608+3777&amp;Email=bhushan_bhangale@kaleconsultants.com" title="Click to call. Cheap rates &amp; no headset required!" target="_blank"><font color="#4e81c4"><span style="color: rgb(78, 129, 196); 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: rgb(78, 129, 196); text-decoration: none;">http://www.kaleconsultants.com</span></font></a>
  </span></font></p>
  </td>
  <td style="padding: 0in;">
  <p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>
  </td>
 </tr>
 <tr style="height: 7.5pt;" height="10">
  <td colspan="2" style="padding: 0in; height: 7.5pt;" height="10">
  <p><font size="1" face="Times New Roman"><span style="font-size: 8pt;"> </span></font></p>
  </td>
 </tr>
 <tr>
  <td colspan="2" style="padding: 0in;">
  <p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </span></font></p>
  </td>
 </tr>
</tbody></table>

<p><font size="3" face="Times New Roman"><span style="font-size: 12pt;"> </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 <a href="http://www.kaleconsultants.com" target="_blank">www.kaleconsultants.com</a> 

----------


</pre><br></div>


<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>
<br></blockquote></div><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><br>