<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br></div><div><br></div><blockquote type="cite"><div><b>From:</b> "lin.lin [via Drools]" &lt;<a href="mailto:ml-node+s46999n4028540h77@n3.nabble.com">ml-node+s46999n4028540h77@n3.nabble.com</a>&gt;<br><b>Date:</b> March 5, 2014 at 10:47:14 AM CST<br><b>To:</b> "lin.lin" &lt;<a href="mailto:lin.lin@comcast.net">lin.lin@comcast.net</a>&gt;<br><b>Subject:</b> <b>Re: [rules-users] sliding window question</b><br><br></div></blockquote><blockquote type="cite"><div>

        Hi Walfgang,
<br><br>&nbsp; Thanks a lot for the pointers. My goal is to try detect a situation when readings about a user is consistent high for the last 30 seconds. The reading comes every 10 seconds. I have tried many different ways and still can not get it working. &nbsp;Here are a list of things that I found not working, I am wondering whether anyone has encountered some of this before or whether there is a known issue related to some of this or whether there is some configuration that I am missing in my environment. &nbsp;Also, what is a good way to find out whether a event has expired or still in working memory? &nbsp;I am stuck, please help.
<br><br>1) the following rule does not work, according to drools book, this should work.
<br><br>rule "rule1"
<br>&nbsp; &nbsp; &nbsp; &nbsp;dialect "mvel"
<br>&nbsp; &nbsp; &nbsp; &nbsp;when
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$user: mUser(status==true)
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;not (Reading ($user.userid== userid, reading&lt;=90) over window :time (30s) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; &nbsp;then
<br><br>2) the following rules work on its own, (that is if I only include one rule in the .drl file), but when I put both rules in the .drl file, &nbsp;only the acumtest rule works but nothing comes out from &nbsp;"rule1" &nbsp;
<br><br>rule "acumtest"
<br>dialect "mvel"
<br>&nbsp; when
<br>&nbsp; &nbsp;accumulate( Reading( $r:reading) over windiw:time(30s) from entry-point ReadingStream, $sum : sum($r))
<br>&nbsp; then
<br>&nbsp; &nbsp; System.out.print ("sum=" +$sum+"\n");
<br>end
<br><br>rule "rule1"
<br>dialect "mvel"
<br>&nbsp; &nbsp; when
<br>&nbsp; &nbsp; &nbsp; $user: mUser(status==true)
<br>&nbsp; &nbsp; &nbsp; $hr1 : Reading ($user.userid==$hr1.userid, reading&gt;90) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; $hr2 : Reading ($user.userid==$hr2.userid, reading&gt;90, this after [30s,30s] $hr1) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; not Reading ($user.userid == userid, reading&lt;=90, this after $hr1, this before $hr2) from entry-point ReadingStream
<br>&nbsp; &nbsp; then
<br><br>3) The following rule does not work, but if I comment out the accumulate line in the condition, it works. &nbsp;Somehow, the accumulate function does not work with other rules or making event expired ??
<br><br>rule "rule1"
<br>dialect "mvel"
<br>&nbsp; &nbsp; when
<br>&nbsp; &nbsp; &nbsp; $user: mUser(status==true)
<br>&nbsp; &nbsp; &nbsp; $hr1 : Reading ($user.userid==$hr1.userid, reading&gt;90) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; $hr2 : Reading ($user.userid==$hr2.userid, reading&gt;90, this after [30s,30s] $hr1) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; not Reading ($user.userid == userid, reading&lt;=90, this after $hr1, this before $hr2) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; $test: Number( doubleValue&gt;0 ) from accumulate ( Reading( userid==$user.userid, $r:reading) over window:time(30s) from entry-point ReadingStream, sum($r))
<br>&nbsp; &nbsp; then
<br><br>4) This does work, but if I uncomment out the $hr4 line, then it does not work anymore
<br>rule "rule1"
<br>dialect "mvel"
<br>&nbsp; &nbsp; when
<br>&nbsp; &nbsp; &nbsp; $user: mUser(status==true)
<br>&nbsp; &nbsp; &nbsp; $hr1 : Reading ($user.userid==$hr1.userid, reading&gt;90) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; $hr2 : Reading ($user.userid==$hr2.userid, reading&gt;90, this after [10s,10s] $hr1) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; $hr3 : Reading ($user.userid==$hr3.userid, reading&gt;90, this after [10s,10s] $hr2) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; // $hr4 : Reading ($user.userid==$hr4.userid, reading&gt;90, this after [10s,10s] $hr3) from entry-point ReadingStream
<br>&nbsp; &nbsp; &nbsp; $test: Number( doubleValue&gt;0 ) from accumulate ( Reading( userid==$user.userid, $r:reading) over window:time(30s) from entry-point ReadingStream, sum($r))
<br>&nbsp; &nbsp; then
<br><br><br>Thanks &nbsp;a lot!
<br><br>Lin

        
        
        
        <br>
        <br>
        <hr noshade="noshade" size="1" color="#cccccc">
        <div style="color:#444; font: 12px tahoma,geneva,helvetica,arial,sans-serif;">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://drools.46999.n3.nabble.com/sliding-window-question-tp4028367p4028540.html">http://drools.46999.n3.nabble.com/sliding-window-question-tp4028367p4028540.html</a>
        </div>
        <div style="color:#666; font: 11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from sliding window question, <a href="http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&amp;node=4028367&amp;code=bGluLmxpbkBjb21jYXN0Lm5ldHw0MDI4MzY3fC0xODk3NDMyNjQ3">click here</a>.<br>
                <a href="http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&amp;id=instant_html%21nabble%3Aemail.naml&amp;base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&amp;breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif">NAML</a>
        </div></div></blockquote></body></html>