I
On 05/03/2014, lin.lin <lin.lin(a)comcast.net> wrote:
Hi Walfgang,
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.
1) the following rule does not work, according to drools book, this
should
work.
rule "rule1"
dialect "mvel"
when
$user: mUser(status==true)
not (Reading ($user.userid== userid, reading<=90) over window
:time
(30s) from entry-point ReadingStream
then
Works for me, using 5.5.0-Final (and after fixing the syntax error).
You'll have to provide the code how you start the session and insert
the facts.
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"
Rule "rule1" below doesn't work in 5.3.0 and 5.5.0, apparently due to
a bug in connection with not and something else, perhaps temporal
operators.
rule "acumtest"
dialect "mvel"
when
accumulate( Reading( $r:reading) over windiw:time(30s) from entry-point
ReadingStream, $sum : sum($r))
then
System.out.print ("sum=" +$sum+"\n");
end
rule "rule1"
dialect "mvel"
when
$user: mUser(status==true)
$hr1 : Reading ($user.userid==$hr1.userid, reading>90) from
entry-point ReadingStream
$hr2 : Reading ($user.userid==$hr2.userid, reading>90, this after
[30s,30s] $hr1) from entry-point ReadingStream
not Reading ($user.userid == userid, reading<=90, this after $hr1,
this before $hr2) from entry-point ReadingStream
then
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 ??
Since 2) doesn't work for me, I can't comment on this.
rule "rule1"
dialect "mvel"
when
$user: mUser(status==true)
$hr1 : Reading ($user.userid==$hr1.userid, reading>90) from
entry-point ReadingStream
$hr2 : Reading ($user.userid==$hr2.userid, reading>90, this after
[30s,30s] $hr1) from entry-point ReadingStream
not Reading ($user.userid == userid, reading<=90, this after $hr1,
this before $hr2) from entry-point ReadingStream
$test: Number( doubleValue>0 ) from accumulate ( Reading(
userid==$user.userid, $r:reading) over window:time(30s) from entry-point
ReadingStream, sum($r))
then
4) This does work, but if I uncomment out the $hr4 line, then it does not
work anymore
I'd be *very* careful with operators such as after[10s,10s]. This
requires that one event is *exactly* 10s or 10000ms after the other
one, and I doubt very much that you'll have a timing as precise as
that.
-W
rule "rule1"
dialect "mvel"
when
$user: mUser(status==true)
$hr1 : Reading ($user.userid==$hr1.userid, reading>90) from
entry-point ReadingStream
$hr2 : Reading ($user.userid==$hr2.userid, reading>90, this after
[10s,10s] $hr1) from entry-point ReadingStream
$hr3 : Reading ($user.userid==$hr3.userid, reading>90, this after
[10s,10s] $hr2) from entry-point ReadingStream
// $hr4 : Reading ($user.userid==$hr4.userid, reading>90, this after
[10s,10s] $hr3) from entry-point ReadingStream
$test: Number( doubleValue>0 ) from accumulate ( Reading(
userid==$user.userid, $r:reading) over window:time(30s) from entry-point
ReadingStream, sum($r))
then
Thanks a lot!
Lin
--
View this message in context:
http://drools.46999.n3.nabble.com/sliding-window-question-tp4028367p40285...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users