&gt;If no-loop is used with Rule 1 instead of lock-on-active, the rule will go<br>&gt;into an infinite loop. I don&#39;t understand why no-loop doesn&#39;t work. Any<br>&gt;guidance?<br>no-loop won&#39;t work because of Rule2. It modifies Stack and that reactivates Rule1. No-loop will ignore only modifications to current set of data (current tuple).<br>
<div><br>&gt;If lock-on-active is used on Rule 1 and Rule 2 (instead of no-loop), Rule 2<br>&gt;is never activated. It&#39;s interesting that no-loop works in Rule 2, but not<br>&gt;in Rule 1.</div><div>this is because both rules are part of the MAIN agenda-group. With the input data you have, when Rule1 increases the size of the Stack only then can Rule2 fire however it won&#39;t since lock-on-active will discard its activations.<br>
<br><div class="gmail_quote">On Mon, Jan 26, 2009 at 7:28 PM, Dan Seaver <span dir="ltr">&lt;<a href="mailto:dan.seaver@ge.com">dan.seaver@ge.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
I am familiar with both of these rule attributes. However, no-loop doesn&#39;t<br>
work in all cases, and lock-on-active needs a fairly fine-grained setup of<br>
activation groups or ruleflow groups in many circumstances. Also,<br>
lock-on-active can not block selective activations, it blocks all<br>
activations. So the activations you don&#39;t want to block have to go in a<br>
separate rule that doesn&#39;t have lock-on-active set.<br>
<br>
I think it would be useful for many in the group to see an example of<br>
appropriate use of these attributes, as well as possible solutions for when<br>
these attributes are inappropriate to use.<br>
<br>
Here are two rules that apply:<br>
rule &quot;Rule 1&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;lock-on-active true<br>
<div class="Ih2E3d"> &nbsp; &nbsp; &nbsp; &nbsp;when<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;board : Board (thickness == 1)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stack : Stack (location == &quot;A&quot;)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;then<br>
</div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stack.addBoard(board);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;update(stack);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.format (&quot;Sorted: %s added to Stack %s\n&quot;, board, stack);<br>
end<br>
<br>
rule &quot;Rule 2&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;salience 1<br>
 &nbsp; &nbsp; &nbsp; &nbsp;no-loop true<br>
 &nbsp; &nbsp; &nbsp; &nbsp;when<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stack : Stack (size &gt; 3)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;then<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stack.setStatus(&quot;Overflowing&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;update (stack);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.format (&quot;Stack %s\n&quot;, stack);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (Board stackBoard : stack.getBoards()) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.format (&quot;%20s\n&quot;, stackBoard);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
end<br>
<br>
I&#39;ve attached an Eclipse project that contains these rules for anyone that<br>
wants to play around with it.<br>
<br>
If no-loop is used with Rule 1 instead of lock-on-active, the rule will go<br>
into an infinite loop. I don&#39;t understand why no-loop doesn&#39;t work. Any<br>
guidance?<br>
<br>
If lock-on-active is used on Rule 1 and Rule 2 (instead of no-loop), Rule 2<br>
is never activated. It&#39;s interesting that no-loop works in Rule 2, but not<br>
in Rule 1.<br>
<br>
Dan<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
Mark Proctor wrote:<br>
&gt;<br>
&gt; see no-loop or the more powerful lock-on-active.<br>
&gt;<br>
&gt; Mark<br>
&gt; Dan Seaver wrote:<br>
&gt;&gt; Sounds like a very good idea. If you go forward with this, I&#39;d love to<br>
&gt;&gt; see<br>
&gt;&gt; your method for solving the following type of problem:<br>
&gt;&gt;<br>
&gt;&gt; I need to update a particular object without causing the rule to re-fire.<br>
&gt;&gt;<br>
&gt;&gt; Say I have two classes, Stack and Board. I need to choose the Stack to<br>
&gt;&gt; put<br>
&gt;&gt; each Board, so one of these sorting rulles would look like this:<br>
&gt;&gt;<br>
&gt;&gt; when<br>
&gt;&gt; &nbsp; &nbsp;board : Board (thickness == 1)<br>
&gt;&gt; &nbsp; &nbsp;stack : Stack (location == &quot;A&quot;)<br>
&gt;&gt; then<br>
&gt;&gt; &nbsp; &nbsp;board.setStack(stack);<br>
&gt;&gt; &nbsp; &nbsp;update(board);<br>
&gt;&gt; end<br>
&gt;&gt;<br>
&gt;&gt; The problem is the update statement puts the rule back in the Agenda to<br>
&gt;&gt; be<br>
&gt;&gt; fired again, thus an infinite loop. My solution in general has been to<br>
&gt;&gt; use a<br>
&gt;&gt; Collection to track boards that have been processed, but it seems to be<br>
&gt;&gt; alot<br>
&gt;&gt; of overhead. I&#39;m not pleased by my solution.<br>
&gt;&gt;<br>
&gt;&gt; when<br>
&gt;&gt; &nbsp; &nbsp;board : Board (thickness == 1)<br>
&gt;&gt; &nbsp; &nbsp;stack : Stack (location == &quot;A&quot;)<br>
&gt;&gt; &nbsp; &nbsp;processed : NamedCollection(name == &quot;BoardsSorted&quot;, collection not<br>
&gt;&gt; contains board)<br>
&gt;&gt; then<br>
&gt;&gt; &nbsp; &nbsp;board.setStack(stack);<br>
&gt;&gt; &nbsp; &nbsp;update(board);<br>
&gt;&gt; &nbsp; &nbsp;processed.add(board);<br>
&gt;&gt; &nbsp; &nbsp;update(processed);<br>
&gt;&gt; end<br>
&gt;&gt;<br>
&gt;&gt; Also, the NamedCollection needs to be created, which I&#39;m doing within the<br>
&gt;&gt; ruleset, which adds a somewhat meaningless to Business Analysts rule.<br>
&gt;&gt; Though<br>
&gt;&gt; I could create the NamedCollection in Java and add it to WorkingMemory<br>
&gt;&gt; prior<br>
&gt;&gt; to firing the rules, I&#39;d like the rulesets to take care of themselves.<br>
&gt;&gt;<br>
&gt;&gt; My actual problem set is laced with many solutions that need to update<br>
&gt;&gt; objects. Even if the object is not directly related to the rule criteria,<br>
&gt;&gt; a<br>
&gt;&gt; map to the object needs to be created in the RHS so the LHS has a<br>
&gt;&gt; reference<br>
&gt;&gt; to the object being updated, thus posing the same problem as above.<br>
&gt;&gt;<br>
&gt;&gt; Your insights would be greatly appreciated.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Mark Proctor wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; I&#39;m going to try an informal experiment for the 4th of February at 5PM<br>
&gt;&gt;&gt; GMT (Date/Time subject to change), we will run an online Drools Clinic<br>
&gt;&gt;&gt; in the form of a Webinar. So the idea here isn&#39;t of a 60 minute<br>
&gt;&gt;&gt; presentation, but really more of a 60 minute interactive Q&amp;A where we<br>
&gt;&gt;&gt; will use the desktop to assist in some explanations talking through code<br>
&gt;&gt;&gt; or examples. What do people think?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Ideally we would have a set of pre-determined questions, with some adhoc<br>
&gt;&gt;&gt; ones on the day too. Feel free to start listing your Qs here. I want to<br>
&gt;&gt;&gt; avoid &quot;What&#39;s &nbsp;WorkingMemory&quot; type questions, but other than that,<br>
&gt;&gt;&gt; anything is game. Also if anyone has anything cool they would like to<br>
&gt;&gt;&gt; discuss about how they have used Drools, or just general interesting AI<br>
&gt;&gt;&gt; ideas, then that&#39;s fine too - happy for this just to turn into a fun<br>
&gt;&gt;&gt; geek chat too.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Mark<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; rules-users mailing list<br>
&gt;&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
</div></div><a href="http://www.nabble.com/file/p21671931/tests.zip" target="_blank">http://www.nabble.com/file/p21671931/tests.zip</a> tests.zip<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Drools-Community-Clinic-Feb-4th-5PM-GMT-tp21623144p21671931.html" target="_blank">http://www.nabble.com/Drools-Community-Clinic-Feb-4th-5PM-GMT-tp21623144p21671931.html</a><br>

</font><div class="Ih2E3d">Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
</div><div><div></div><div class="Wj3C7c">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>
</div></div></blockquote></div><br></div>