<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]" <<a href="mailto:ml-node+s46999n4028540h77@n3.nabble.com">ml-node+s46999n4028540h77@n3.nabble.com</a>><br><b>Date:</b> March 5, 2014 at 10:47:14 AM CST<br><b>To:</b> "lin.lin" <<a href="mailto:lin.lin@comcast.net">lin.lin@comcast.net</a>><br><b>Subject:</b> <b>Re: [rules-users] sliding window question</b><br><br></div></blockquote><blockquote type="cite"><div>
        Hi Walfgang,
<br><br> 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. 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. Also, what is a good way to find out whether a event has expired or still in working memory? 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> dialect "mvel"
<br> when
<br> $user: mUser(status==true)
<br> not (Reading ($user.userid== userid, reading<=90) over window :time (30s) from entry-point ReadingStream
<br> 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, only the acumtest rule works but nothing comes out from "rule1"
<br><br>rule "acumtest"
<br>dialect "mvel"
<br> when
<br> accumulate( Reading( $r:reading) over windiw:time(30s) from entry-point ReadingStream, $sum : sum($r))
<br> then
<br> System.out.print ("sum=" +$sum+"\n");
<br>end
<br><br>rule "rule1"
<br>dialect "mvel"
<br> when
<br> $user: mUser(status==true)
<br> $hr1 : Reading ($user.userid==$hr1.userid, reading>90) from entry-point ReadingStream
<br> $hr2 : Reading ($user.userid==$hr2.userid, reading>90, this after [30s,30s] $hr1) from entry-point ReadingStream
<br> not Reading ($user.userid == userid, reading<=90, this after $hr1, this before $hr2) from entry-point ReadingStream
<br> then
<br><br>3) The following rule does not work, but if I comment out the accumulate line in the condition, it works. Somehow, the accumulate function does not work with other rules or making event expired ??
<br><br>rule "rule1"
<br>dialect "mvel"
<br> when
<br> $user: mUser(status==true)
<br> $hr1 : Reading ($user.userid==$hr1.userid, reading>90) from entry-point ReadingStream
<br> $hr2 : Reading ($user.userid==$hr2.userid, reading>90, this after [30s,30s] $hr1) from entry-point ReadingStream
<br> not Reading ($user.userid == userid, reading<=90, this after $hr1, this before $hr2) from entry-point ReadingStream
<br> $test: Number( doubleValue>0 ) from accumulate ( Reading( userid==$user.userid, $r:reading) over window:time(30s) from entry-point ReadingStream, sum($r))
<br> 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> when
<br> $user: mUser(status==true)
<br> $hr1 : Reading ($user.userid==$hr1.userid, reading>90) from entry-point ReadingStream
<br> $hr2 : Reading ($user.userid==$hr2.userid, reading>90, this after [10s,10s] $hr1) from entry-point ReadingStream
<br> $hr3 : Reading ($user.userid==$hr3.userid, reading>90, this after [10s,10s] $hr2) from entry-point ReadingStream
<br> // $hr4 : Reading ($user.userid==$hr4.userid, reading>90, this after [10s,10s] $hr3) from entry-point ReadingStream
<br> $test: Number( doubleValue>0 ) from accumulate ( Reading( userid==$user.userid, $r:reading) over window:time(30s) from entry-point ReadingStream, sum($r))
<br> then
<br><br><br>Thanks 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&node=4028367&code=bGluLmxpbkBjb21jYXN0Lm5ldHw0MDI4MzY3fC0xODk3NDMyNjQ3">click here</a>.<br>
                <a href="http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&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>