[rules-users] How to write rules with optional parts?

Edward Johnson ejohnson at coderyte.com
Fri Jul 22 12:20:07 EDT 2011


Thanks for your help.  I'll look in to doing it as a state machine, perhaps I am making things more complex than they really are.

Edward.


----- Original Message -----
> In this particular case you can do
> 
> $p1:person (name=="Alice")
> $p3:person (name=="David", this after[0,1] $p1)
> not person (name != "Bob", this after[0,1] $p1 && before[0,1] $p3 )
> 
> A more general approach should be possible by monitoring states rather
> than event sequences, especially if you process events in real time.
> 
> 1) Alice => state := A
> 2a) David => OK
> 2b) Bob => state := AB
> 2c) Edward => state := _
> 
> And so on.
> -W
> 
> 
> 
> 
> On 20 July 2011 22:21, Edward Johnson < ejohnson at coderyte.com > wrote:
> 
> 
> How do you do rules that are a sequence of events where some of them
> are optional?
> 
> Example:
> 
> Alert if DAVID enters a room after ALICE or after ALICE and BOB
> If it were a string, this is roughly equivalant to the regex /ALICE(
> BOB)? DAVID/
> 
> So:
> Alice then David => alert
> Alice then Bob then David => alert
> Alice then Charles then David => no alert
> 
> I could write this as two rules but as the rules get more complex it
> could by hard to manage the resulting combatorial explosion. Here it
> is as two rules:
> 
> Rule 1:
> $p1:person (name=="Alice")
> $p2:person (name=="David", this after[0,1] $p1)
> 
> Rule 2:
> $p1:person (name=="Alice")
> $p2:person (name=="Bob", this after[0,1] $p1)
> $p3:person (name=="David", this after[0,1] $p2)
> _______________________________________________
> 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



More information about the rules-users mailing list