Well, it&#39;s definitely not forbidden to do a little computational work on the RHS, too.<br><br>Bind the result to a variable:<br>    Number( $times : intValue &gt; 10 )...<br>and, on the RHS, do<br>    for( int i = 1; i &lt;= $times % 10; i++ ) shout( &quot;alarm&quot; );<br>
or whatever.<br><br>-W<br><br><br><div class="gmail_quote">On Thu, May 21, 2009 at 4:21 PM,  <span dir="ltr">&lt;<a href="mailto:hrishikesh.varma@wipro.com">hrishikesh.varma@wipro.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
<br>
Temporal Reasoning with Accumulate - (like 3- rule &quot;Customer login from<br>
more than 5 locations in the last one month&quot;)<br>
<br>
What if I want to reset my count for accumulate within the time<br>
specified sliding window.So that I can have the RHS triggered for every<br>
10times the event occurs in the same window.<br>
For Example:<br>
<br>
when<br>
    $customer : Customer( $id : id )<br>
     Number( intValue &gt; 10 ) from accumulate(<br>
                     CustomerLogin( loginStatus==&quot;Failed&quot;, customerId ==<br>
$id,$cusId:customerId)<br>
over window:time( 30s ),<br>
                     count( $ cusId) )<br>
then<br>
    // do something as the customer had abnormal number of failed<br>
violations in last 30 secs.<br>
end<br>
<br>
<br>
Right now am doing something similar, but using a manual approach -of<br>
explicitly counting.<br>
<br>
Any Light on this?<br>
<br>
Regards<br>
Rishi<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Tue, 19 May 2009 11:17:41 -0400<br>
From: Edson Tirelli &lt;<a href="mailto:tirelli@post.com">tirelli@post.com</a>&gt;<br>
Subject: Re: [rules-users] can drools support complex rules<br>
To: Rules Users List &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>
Message-ID:<br>
        &lt;<a href="mailto:e6dd5ba30905190817q33d15b9er5efee64bc74cdb0e@mail.gmail.com">e6dd5ba30905190817q33d15b9er5efee64bc74cdb0e@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;windows-1252&quot;<br>
<br>
     Your question is funny. First you ask if Drools is capable of<br>
managing<br>
complex rules and then you mention examples of extremely simple rules?<br>
:)<br>
<br>
     Drools is FOL complete and so can represent any well formed First<br>
Order<br>
Logic expression. Anyway, I will use this message to advertise some of<br>
the<br>
temporal reasoning features that we have on Drools 5 for the benefit of<br>
anyone interested.<br>
<br>
     There are several ways of authoring such rules, depending on how<br>
you<br>
model your problem domain. One possible way of doing them is:<br>
<br>
#1:<br>
rule &quot;If a customer login within 5 minutes from two different locations,<br>
mark the user invalid.&quot;<br>
when<br>
     $l1 : CustomerLogin( )<br>
     $l2 : CustomerLogin( userId == l1.$id, location != $<a href="http://l1.id" target="_blank">l1.id</a>,<br>
timestamp<br>
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<br>
memory, but you can easily query for the previous login in an external<br>
datasource, pulling the data from the previous login on-demand for the<br>
reasoning cycle.<br>
<br>
#2:<br>
rule &quot;If the customer location is not on a list of valid locations, mark<br>
the<br>
user invalid&quot;<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,<br>
but<br>
you can as easily model locations as being facts on your working memory<br>
or a<br>
service end point that you can call to validate the location.<br>
<br>
#3:<br>
rule &quot;Customer login from more than 5 locations in the last one month&quot;<br>
when<br>
    $customer : Customer( $id : id )<br>
    $locations : Set( size &gt; 5 ) from accumulate(<br>
                     CustomerLogin( customerId == $id, $loc : location )<br>
over window:time( 30d ),<br>
                     collectSet( $loc ) )<br>
then<br>
    // do something as the customer logged in from more than 5 locations<br>
in<br>
the last 30 days<br>
end<br>
<br>
In the previous rule I decided to use sliding windows, just to show how<br>
that<br>
feature can be used to simplify rules, but again, there are several ways<br>
of<br>
doing it.<br>
<br>
I strongly recommend you read Drools manual.<br>
<br>
<a href="http://www.jboss.org/drools/documentation.html" target="_blank">http://www.jboss.org/drools/documentation.html</a><br>
<br>
Cheers,<br>
Edson<br>
<br>
<br>
<br>
2009/5/19 Bhushan Bhangale &lt;<a href="mailto:bhushan_bhangale@kaleconsultants.com">bhushan_bhangale@kaleconsultants.com</a>&gt;<br>
<br>
&gt;  Hi,<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; I recently came across Drools. I gone through the documentation and<br>
the<br>
&gt; examples provide are quite simple. I want to know if it can be really<br>
&gt; applied to complex real world problems.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Take for example,<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; If a customer login within 5 minutes from two different locations,<br>
mark the<br>
&gt; user invalid.<br>
&gt;<br>
&gt; How can I write the above rule in drools? I have the data when the<br>
user<br>
&gt; last logged in and the data of current login. You can say two objects.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; May be my understanding is wrong but looks like based on rule I have<br>
to<br>
&gt; pass all the required data. How can then at real time new rules can be<br>
&gt; added?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; For example,<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; If the customer location is not on a list of valid locations, mark the<br>
user<br>
&gt; invalid.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; For the above rule I need to pass a list of valid locations as well.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Now how about &quot;Customer login from more than 5 locations in the last<br>
one<br>
&gt; month&quot;?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Thanks<br>
&gt;<br>
&gt; *Mr. Bhangale Bhushan*<br>
&gt; *Associate Manager*<br>
&gt; *Kale Consultants Ltd.*<br>
&gt; <a href="mailto:bhushan_bhangale@kaleconsultants.com">bhushan_bhangale@kaleconsultants.com</a><br>
&gt; tel: +91 (0)206 608<br>
3777&lt;<a href="http://www.plaxo.com/click_to_call?lang=en&amp;src=jj_signature&amp;To=%2B9%0A1+%280%29206+608+3777&amp;Email=bhushan_bhangale@kaleconsultants.com" target="_blank">http://www.plaxo.com/click_to_call?lang=en&amp;src=jj_signature&amp;To=%2B9<br>

1+%280%29206+608+3777&amp;Email=bhushan_bhangale@kaleconsultants.com</a>&gt;<br>
&gt; <a href="http://www.kaleconsultants.com" target="_blank">http://www.kaleconsultants.com</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Disclaimer: This email (including any attachments) is intended for the<br>
sole<br>
&gt; use of the recipient/s and may contain material that is CONFIDENTIAL.<br>
Any<br>
&gt; unauthorized disclosure / copying / distribution or forwarding of this<br>
message<br>
&gt; or part is STRICTLY PROHIBITED. If you have erroneously received this<br>
message,<br>
&gt; please delete it immediately and notify the sender. No liability is<br>
assumed for<br>
&gt; any errors and/or omissions in the contents of this message.<br>
Information in<br>
&gt; this message that does not relate to the official business of this<br>
Company<br>
&gt; shall be understood as neither given nor endorsed by it. If<br>
verification is<br>
&gt; required please request a hard-copy version.<br>
&gt;<br>
&gt; To know more about Kale Consultants, visit <a href="http://www.kaleconsultants.com" target="_blank">www.kaleconsultants.com</a><br>
&gt;<br>
&gt; ----------<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
--<br>
 Edson Tirelli<br>
 JBoss Drools Core Development<br>
 JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL:<br>
<a href="http://lists.jboss.org/pipermail/rules-users/attachments/20090519/4d4928%0A6d/attachment-0001.html" target="_blank">http://lists.jboss.org/pipermail/rules-users/attachments/20090519/4d4928<br>
6d/attachment-0001.html</a><br>
<br>
------------------------------<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>
<br>
<br>
End of rules-users Digest, Vol 30, Issue 56<br>
*******************************************<br>
<br>
Please do not print this email unless it is absolutely necessary.<br>
<br>
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.<br>

<br>
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.<br>

<br>
<a href="http://www.wipro.com" target="_blank">www.wipro.com</a><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>
</blockquote></div><br>