An additional rule will be necessary to discard obsolete PatternConsumer facts.<br><br>And I think that this may cause hefty Cartesian products to accumulate until<br>progress in Rete is stopped ny the &quot;not&quot; CE; so the &quot;not&quot; may have to be<br>
written three times, once after each $aN: EventA() pattern.<br><br>-W<br><br><div class="gmail_quote">2010/10/25 Michael Anstis <span dir="ltr">&lt;<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">You could try this too; if you don&#39;t want lots of new attributes for your model:-<div class="im">
<br><br>rule &quot;three A&quot;<br>when<br>&nbsp; $a1: EventA( $index : index )<br>
&nbsp; $a2: EventA( index == $index )<br>&nbsp; $a3: EventA( index == $index )</div><div>&nbsp; not PatternConsumer( name == &#39;AAA&#39;, events contain $a1 || contais $a2 || contains $a3)<div class="im"><br>
&nbsp; not EventB( this after[0ms] $a1 &amp;&amp; before[0ms] $a3, index == $index )<br>
then<br>&nbsp; // ... match<br></div>&nbsp; PatternConsumer pc = new PatternConsumer(&quot;AAA&quot;, $a1, $a2, $a3 );<br>&nbsp; insert(pc);<br></div>end<div><div></div><div class="h5"><br><br><br><div class="gmail_quote">2010/10/25 Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Giving those other rules a higher salience is one way, but I think<br>it is better to add a boolean field &quot;usedForAAA&quot; to class EventA. <br>

<br>rule &quot;three A&quot;<br>when<br>&nbsp; $a1: EventA( $index : index, usedForAAA == false )<br>
&nbsp; $a2: EventA( index == $index, usedForAAA == false )<br>&nbsp; $a3: EventA( index == $index, usedForAAA == false )<div><br>

&nbsp; not EventB( this after[0ms] $a1 &amp;&amp; before[0ms] $a3, index == $index )<br>
then<br>&nbsp; // ... match<br></div>&nbsp; modify( $a1 ){ setUsedForAAA( true ) }<br>&nbsp; modify( $a2 ){ setUsedForAAA( true ) } <br>&nbsp; modify( $a3 ){ setUsedForAAA( true ) }<div><div></div><div><br>end<br><br>-W<br><br><br>
<div class="gmail_quote">2010/10/25 ΥΤΩ©Ω© <span dir="ltr">&lt;<a href="mailto:kevin223@gmail.com" target="_blank">kevin223@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thanks Wolfgang,<div><br></div><div>It now starts to make sense to me. However, is it possible that I don&#39;t retract those matched eventA? All those events might be used to evaluate against other rules.</div>


<div><br></div>
<div>Thanks again,</div><div>Kevin Zhao</div><div><br><div class="gmail_quote">2010/10/25 Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</span><br>


<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I assume you are using Fusion, using a session clock so that temporal operators are available.<br><br>rule &quot;three A&quot;<br>when<br>&nbsp; $a1: EventA( $index : index )<br>&nbsp; $a2: EventA( index == $index )<br>&nbsp; $a3: EventA( index == $index )<br>




&nbsp; not EventB( this after[0ms] $a1 &amp;&amp; before[0ms] $a3, index == $index )<br>
then<br>&nbsp; // ... match<br>&nbsp; retract( $a1 );<br>&nbsp; retract( $a2 );<br>&nbsp; retract( $a3 );<br>end<br><br>-W<br><br><div class="gmail_quote">2010/10/25 ΥΤΩ©Ω© <span dir="ltr">&lt;<a href="mailto:kevin223@gmail.com" target="_blank">kevin223@gmail.com</a>&gt;</span><br>





<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>Hello,<div><br></div><div>I&#39;m still quite new to the drools stuffs just getting the examples running. I&#39;m sorry if my question is too basic.</div>





<div>I have a system that will continuously to receive events sent from some other system. Basically I have&nbsp;two types of events, eventA and eventB.&nbsp;</div>
<div>Both eventA and eventB have two properties, index and timestamp.</div><div><br></div><div>What I want is to capture a pattern to meet the following conditions</div><div><br></div><div>1. every 3 consecutive eventsA without any eventB in between&nbsp;having a same index value&nbsp;ordering by their timestamp.&nbsp;</div>






<div><br></div><div>2. all events in a matched pattern will have the same value of property index.</div><div><br></div><div>3. if a pattern is matched, any of the events in this pattern should not be used again for a new matching.</div>






<div><br></div><div>there are some examples below, the number after a colon stands for the value of its index number and assume those events are already ordered by their timestamp.</div><div><br></div><div>eventB:2 &nbsp; &nbsp;eventA:1 &nbsp; &nbsp; eventA:1 &nbsp; &nbsp; eventA:1 &nbsp;eventB:3 &nbsp; &nbsp; &nbsp;--------- one successful match, we have three eventA with same index value 1 in a row</div>






<div><br></div><div>eventB:2 &nbsp; &nbsp;eventA:1 &nbsp; &nbsp; eventA:1 &nbsp; &nbsp; eventB:1 &nbsp;eventA:1 &nbsp; &nbsp; &nbsp;--------- no match because there&#39;s an eventB in between</div><div><br></div><div>eventB:2 &nbsp; &nbsp;eventA:1 &nbsp; &nbsp; eventA:1 &nbsp; &nbsp; eventB:2 &nbsp;eventA:1 &nbsp; &nbsp; &nbsp;--------- one successful match because the in-between eventB has a different index value</div>






<div><br></div><div>eventA:1 &nbsp; &nbsp;eventA:1 &nbsp; &nbsp; eventA:1 &nbsp; &nbsp; eventA:1 &nbsp;eventA:1 &nbsp; &nbsp; &nbsp;--------- only one match, because once matched, the events can not be used for a second match again.</div><div><br></div><div><br></div><div>






I just don&#39;t know how to write a rule like this. Is there anyone who can shed some lights on?</div><div><br></div><div>Best Regards,</div><div>Kevin</div><div><br></div><div><br></div>
<br></div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div><br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div><br>
</div></div><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>
<br></blockquote></div><br>