In this particular case you can do<br><br> $p1:person (name=="Alice")<br>
$p3:person (name=="David", this after[0,1] $p1)<br> not person (name != "Bob", this after[0,1] $p1 && before[0,1] $p3 ) <br><br>A more general approach should be possible by monitoring states rather than event sequences, especially if you process events in real time. <br>
<br>1) Alice => state := A<br>2a) David => OK<br>2b) Bob => state := AB<br>2c) Edward => state := _<br><br>And so on.<br>-W<br><br><br><br><div class="gmail_quote">On 20 July 2011 22:21, Edward Johnson <span dir="ltr"><<a href="mailto:ejohnson@coderyte.com">ejohnson@coderyte.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">How do you do rules that are a sequence of events where some of them are optional?<br>
<br>
Example:<br>
<br>
Alert if DAVID enters a room after ALICE or after ALICE and BOB<br>
If it were a string, this is roughly equivalant to the regex /ALICE( BOB)? DAVID/<br>
<br>
So:<br>
Alice then David => alert<br>
Alice then Bob then David => alert<br>
Alice then Charles then David => no alert<br>
<br>
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:<br>
<br>
Rule 1:<br>
$p1:person (name=="Alice")<br>
$p2:person (name=="David", this after[0,1] $p1)<br>
<br>
Rule 2:<br>
$p1:person (name=="Alice")<br>
$p2:person (name=="Bob", this after[0,1] $p1)<br>
$p3:person (name=="David", this after[0,1] $p2)<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>