[rules-users] Question about length windows

Davide Sottara dsotty at gmail.com
Fri May 2 00:59:20 EDT 2014


On 05/01/2014 09:46 PM, Wolfgang Laun wrote:
> A window:length is filled depending on the constraints but independent
> of how old the participating facts are.
Currently only ALPHA constraints determine which facts are
filtered by a length window. There is a JIRA to include beta constraints,
but it has not yet been discussed.
So yes, if none of your facts had value > 102.352, it is possible for
(26) to be still in the window when (146) comes in.

Davide
>
> What you want to achieve can be done without windows:
>
>    t2_1 : Tick( value < 102.352 )
>    t1_1 : Tick( this before t2_1 , value >= 102.352 )
>    not Tick( this before t2_1 && after t1_1 )
>
> The last pattern ascertains that the preceding pair of facts is
> adjacent. (The three timestamps should be different.)
>
> You can also use rules based on an auxiliary fact maintaining state:
> While value < 102.352, state is set to "below"; as soon as a
> fact with value >= 102.352 matches state == "below", the
> threshold is passed and state is set to "above"...
>
> -W
>
>
> On 02/05/2014, Demian Calcaprina <calcacuervo at gmail.com> wrote:
>> Hi Guys, I have one question about how lenght windows will work.
>>
>> I have a rule like this. Basically, it is a "crosses" function, where the
>> value of my object crosses a value.
>>
>> rule "mytest"
>> dialect "mvel"
>> when
>> t2_1 : Tick( value < 102.352 ) over window:length (1)
>> t1_1 : Tick( this before t2_1 , value >= 102.352 ) over window:length (2)
>> then
>> //DO SOMETHING
>> end
>>
>> 23:51:32,150 INFO  [org.drools.core.audit.WorkingMemoryConsoleLogger]
>> (Camel (camel-1) thread #2 - JmsConsumer[]) ACTIVATION FIRED rule:mytest
>> activationId:berarrr_1 [0, 27, 26] declarations: t2_1=Tick [value=102.351,
>> tickTime=Fri May 02 05:51:31 ART 2014](27); t1_1=Tick [value=102.352,
>> tickTime=Fri May 02 05:51:12 ART 2014](26)
>>
>> 23:53:30,560 INFO  [org.drools.core.audit.WorkingMemoryConsoleLogger]
>> (Camel (camel-1) thread #2 - JmsConsumer[]) ACTIVATION CREATED rule:mytest
>> activationId:berarrr_1 [0, 146, 26] declarations: t2_1=Tick [value=102.349,
>> tickTime=Fri May 02 05:53:30 ART 2014](146); t1_1=Tick [value=102.352,
>> tickTime=Fri May 02 05:51:12 ART 2014](26)
>>
>> If you see, the first activation, the
>> window:length(1), matched the object 27
>> window:length(2), matched the object 26
>>
>> Then, after 2 minutes and some Ticks insertes in the WM
>> window:length(1), matched the object 146
>> but window:length(2), still matched the object 26
>>
>> I would expect, that, as object 26 was the first one to be inserted, then
>> it is outside the window:length(2).
>>
>> Is my understanding correct? Am I making something wrong? I am using Drools
>> 6.
>>
>> Thanks!
>>
>> Demian
>>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list