>If no-loop is used with Rule 1 instead of lock-on-active, the rule will go<br>>into an infinite loop. I don't understand why no-loop doesn't work. Any<br>>guidance?<br>no-loop won'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>>If lock-on-active is used on Rule 1 and Rule 2 (instead of no-loop), Rule 2<br>>is never activated. It's interesting that no-loop works in Rule 2, but not<br>>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'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"><<a href="mailto:dan.seaver@ge.com">dan.seaver@ge.com</a>></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'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't want to block have to go in a<br>
separate rule that doesn'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 "Rule 1"<br>
lock-on-active true<br>
<div class="Ih2E3d"> when<br>
board : Board (thickness == 1)<br>
stack : Stack (location == "A")<br>
then<br>
</div> stack.addBoard(board);<br>
update(stack);<br>
System.out.format ("Sorted: %s added to Stack %s\n", board, stack);<br>
end<br>
<br>
rule "Rule 2"<br>
salience 1<br>
no-loop true<br>
when<br>
stack : Stack (size > 3)<br>
then<br>
stack.setStatus("Overflowing");<br>
update (stack);<br>
System.out.format ("Stack %s\n", stack);<br>
for (Board stackBoard : stack.getBoards()) {<br>
System.out.format ("%20s\n", stackBoard);<br>
}<br>
end<br>
<br>
I'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't understand why no-loop doesn'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'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>
><br>
> see no-loop or the more powerful lock-on-active.<br>
><br>
> Mark<br>
> Dan Seaver wrote:<br>
>> Sounds like a very good idea. If you go forward with this, I'd love to<br>
>> see<br>
>> your method for solving the following type of problem:<br>
>><br>
>> I need to update a particular object without causing the rule to re-fire.<br>
>><br>
>> Say I have two classes, Stack and Board. I need to choose the Stack to<br>
>> put<br>
>> each Board, so one of these sorting rulles would look like this:<br>
>><br>
>> when<br>
>> board : Board (thickness == 1)<br>
>> stack : Stack (location == "A")<br>
>> then<br>
>> board.setStack(stack);<br>
>> update(board);<br>
>> end<br>
>><br>
>> The problem is the update statement puts the rule back in the Agenda to<br>
>> be<br>
>> fired again, thus an infinite loop. My solution in general has been to<br>
>> use a<br>
>> Collection to track boards that have been processed, but it seems to be<br>
>> alot<br>
>> of overhead. I'm not pleased by my solution.<br>
>><br>
>> when<br>
>> board : Board (thickness == 1)<br>
>> stack : Stack (location == "A")<br>
>> processed : NamedCollection(name == "BoardsSorted", collection not<br>
>> contains board)<br>
>> then<br>
>> board.setStack(stack);<br>
>> update(board);<br>
>> processed.add(board);<br>
>> update(processed);<br>
>> end<br>
>><br>
>> Also, the NamedCollection needs to be created, which I'm doing within the<br>
>> ruleset, which adds a somewhat meaningless to Business Analysts rule.<br>
>> Though<br>
>> I could create the NamedCollection in Java and add it to WorkingMemory<br>
>> prior<br>
>> to firing the rules, I'd like the rulesets to take care of themselves.<br>
>><br>
>> My actual problem set is laced with many solutions that need to update<br>
>> objects. Even if the object is not directly related to the rule criteria,<br>
>> a<br>
>> map to the object needs to be created in the RHS so the LHS has a<br>
>> reference<br>
>> to the object being updated, thus posing the same problem as above.<br>
>><br>
>> Your insights would be greatly appreciated.<br>
>><br>
>><br>
>> Mark Proctor wrote:<br>
>><br>
>>> I'm going to try an informal experiment for the 4th of February at 5PM<br>
>>> GMT (Date/Time subject to change), we will run an online Drools Clinic<br>
>>> in the form of a Webinar. So the idea here isn't of a 60 minute<br>
>>> presentation, but really more of a 60 minute interactive Q&A where we<br>
>>> will use the desktop to assist in some explanations talking through code<br>
>>> or examples. What do people think?<br>
>>><br>
>>> Ideally we would have a set of pre-determined questions, with some adhoc<br>
>>> ones on the day too. Feel free to start listing your Qs here. I want to<br>
>>> avoid "What's WorkingMemory" type questions, but other than that,<br>
>>> anything is game. Also if anyone has anything cool they would like to<br>
>>> discuss about how they have used Drools, or just general interesting AI<br>
>>> ideas, then that's fine too - happy for this just to turn into a fun<br>
>>> geek chat too.<br>
>>><br>
>>> Mark<br>
>>><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>
>>><br>
>>><br>
>><br>
>><br>
><br>
><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>
><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>