[rules-users] Absence Pattern question

Wolfgang Laun wolfgang.laun at gmail.com
Tue Jul 5 07:39:20 EDT 2011


2011/7/5 Michael Anstis <michael.anstis at gmail.com>

> Won't that just make the rule activate after 3 minutes?
>

That's the idea - only then will you know that there is no B within 3
minutes after A. If there is a B after A, the rule condition is false and
the rule does not fire.


>
> rule AnoB
>
> when
>     $a: A( status == "waiting for B" )
>     not B( this after [3m] $a )
>
>
I think this is true the moment another A arrives; Drools has no way of
knowing that the 3m extend into the future.

-W


> then
>     modify( $a ){ setStatus( "no B within 3m after me" ) }
> end
>
> Is this any good?
>
> Also "untested" ;)
>
>
>

> 2011/7/5 Wolfgang Laun <wolfgang.laun at gmail.com>
>
>> Try a rule with a timer:
>>
>> rule AnoB
>> timer( int: 3m )
>> when
>>     $a: A( status == "waiting for B" )
>>     not B( this after $a )
>> then
>>     modify( $a ){ setStatus( "no B within 3m after me" ) }
>> end
>>
>> Untested.
>> -W
>>
>>
>>
>> On 5 July 2011 13:00, wendy <w.mungovan at yahoo.com> wrote:
>>
>>> Hi,
>>>  I'm having trouble writing an absence pattern.  What I'm trying to do is
>>> detect when there is an A followed by no Bs for 3+minutes.  I don't care
>>> if
>>> there is more than one A.  What I'm running into is that when I try to
>>> use
>>> 'over window:time' the time within drools is the end time of the window.
>>>  So
>>> this means I need to write the no Bs for 3+ min first:
>>>
>>> not( $b: B() over window:time(3m))
>>>
>>> then try to find the A before it:
>>>
>>> $now: Long() from RuleUtilityFunctions.getSessionClockTime()
>>> $a: A( this before [3m] $now)
>>>
>>> then I should have to check to make sure that I don't have any Bs between
>>> $a's time and the start of the no B window:
>>>
>>> not( B( time >= $a.time,
>>>           time <= $now))
>>>
>>> This is not working.  I think that it has something to do with my
>>> function
>>> to get the session clock time
>>> (RuleUtilityFunctions.getSessionClockTime())
>>> and how things get evaluated within the Rete engine.  Because it does not
>>> seem like $now is getting re-evaluated on future calls that pass the $b
>>> condition.  If I replace $now with the call to getSessionClockTime()
>>> everything just seems to get weird.
>>>
>>> I've tried to write the rule forward too.  Look for A followed by no B
>>> but
>>> that does not seem to work because A is matched at the current time and
>>> the
>>> rule triggers because there is no B because the future B data has not be
>>> inserted into working memory yet.
>>>
>>> What is the right way to write this rule?   Is there a way to get the
>>> start
>>> and end time of the time window that met the over window:time()
>>> condition?
>>>
>>> Thank you,
>>> Wendy
>>>
>>>
>>> --
>>> View this message in context:
>>> http://drools.46999.n3.nabble.com/Absence-Pattern-question-tp3140377p3140377.html
>>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110705/21fd6efc/attachment.html 


More information about the rules-users mailing list