I can only say that I tested your (original) rule, and here I need the <br> modify( $parent ){}<br>in the rule where I change the children&#39;s states.<br><br>However, not selecting the &quot;DOWN&quot; state in the first forall pattern<br>
does *not* require this additional modify:<br><br>rule allChidrenDown<br>when<br>    $parent : Device ( $children : eContents, eContents.size &gt; 0 )<br>    forall ( $child : Device ( ) from $children<br>             Device( this == $child,state == &quot;DOWN&quot; ) )<br>
then<br>    System.out.println( $parent.getId() + &quot;: all down&quot; );<br>end<br><br>Note the difference: This version says <br>   for all Device objects [that are children]: <br>       state == &quot;DOWN&quot; <br>
Whereas the original version says<br>   for all Device objects with state ==&quot;DOWN&quot; [that are children]: <br>       true<br>which is something different.<br><br>In any case, you are better off without having to use from.<br>
<br>If you aren&#39;t scared by a little math notation, have a look at<br> <a href="http://www.jessrules.com/jess/docs/PropPred.pdf">http://www.jessrules.com/jess/docs/PropPred.pdf</a> <br>Even though this uses a different rule notation, it might help.<br>
<br>-W <br><br><br><div class="gmail_quote">2010/8/2 Georg Maier <span dir="ltr">&lt;<a href="mailto:Georg.Maier@cjt.de">Georg.Maier@cjt.de</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 link="blue" vlink="purple" lang="DE">

<div>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US">Wolfgang,</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US">thank you so much for your remarks! It’s really
interesting:</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US"> </span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US"><span>-<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">         
</span></span></span><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US">I tried the approach to
update the parent whenever a child is modified before – without any
success</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US"><span>-<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">         
</span></span></span><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US">Now I changed my rule to your
(definitely much better) suggestion – and it works!</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US">So despite of the fact that I’m really happy to have this
one solved I would really be interested in what the problem with the forall is.</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US">Is it possible that a forall statement creates some kind of copy
or “summary” of the facts to be evaluated and is checked only once?
Like an eval statement?</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US">Anyways – thank you so much for your help!</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US">Best regards</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US">Georg</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; color: rgb(31, 73, 125);" lang="EN-US"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-US"> </span></p>

<div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0cm 0cm;">

<p class="MsoNormal"><b><span style="font-size: 10pt;">Von:</span></b><span style="font-size: 10pt;"> <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>
[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>] <b>Im Auftrag von </b>Wolfgang
Laun<br>
<b>Gesendet:</b> Montag, 2. August 2010 12:15<br>
<b>An:</b> Rules Users List<br>
<b>Betreff:</b> Re: [rules-users] Drools + EMF + CDO</span></p>

</div>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style="margin-bottom: 12pt;">Several remarks:<br>
(1) Make sure that a parent is asserted after all of its children. Otherwise
initial evaluation will not comprise the entire children&#39;s list.<br>
(2) After changing a child&#39;s state, update the parent.<br>
(3) The rule as you have it now is somewhat circumstantial. A simpler approach
would be<br>
<br>
rule NoUpChild<br>
when<br>
    $p : Device(  $children : <span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">eContents</span>,
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">eContents</span>.size
&gt; 0 )<br>
    not( Device( state == &quot;UP&quot; ) from $children )<br>
then<br>
    System.out.println( $p.getId() + &quot;: no child up&quot;
);<br>
end<br>
<br>
(4) If you have a &quot;parent&quot; field, this could even be written:<br>
<br>
rule NoUpChild<br>
when<br>
    $p : Device(   children.size &gt; 0 )<br>
    not( Device( parent == $p, state == &quot;UP&quot; ) )<br>
then<br>
    System.out.println( $p.getId() + &quot;: no child up&quot;
);<br>
end<br>
<br>
-W<br>
<br>
<br>
</p>

<div>

<p class="MsoNormal">2010/8/2 Georg Maier &lt;<a href="mailto:Georg.Maier@cjt.de" target="_blank">Georg.Maier@cjt.de</a>&gt;</p>

<div>

<div>

<p class="MsoNormal">Hi,</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"><span lang="EN-US">I’m trying to figure out an issue for three days now and
I’m getting kind of desperate, so I hope someone can help.</span></p>

<p class="MsoNormal"><span lang="EN-US">I’m using Drools in combination with an EMF model which is
modeling a computer network. On init, I read the whole structure of the model
and insert all elements into the working memory. Some of the entities share the
super class “Device” which has an attribute “state”.</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Now I’m having the following rule to change an attribute of
one of the model entities:</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">rule</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">&quot;Set
received status to model&quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">     
</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">when</span></b></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
$event : SomeEvent ( </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                 
$hostname : hostname,</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                 
$hoststate : hoststate,</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                 
$timestamp : timestamp</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
)</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
$device : Device (</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                 
name == $hostname</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
)</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">     
</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">then</span></b></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">modify</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">($device) {</span></p>


<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">     
           
setState($hoststate);</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
}</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
db.commit(</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">false</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">);</span></p>


<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
            </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">retract</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">($event);       
</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
System.err.println(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">&quot;Set status of &quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> + $device + </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">&quot;
to &quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> + $hoststate);</span></p>

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">end</span></b></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">… which works perfectly fine. Anyway, what I want to do in
this test case is to <b>react whenever all child devices of a mutual parent
device</b> (e.g. hosts on one switch) are no longer reachable. I thought of a
rule like the following:</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">rule</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">&quot;Parent
Children Test&quot;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">     
</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">when</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">  </span></p>


<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
$parent : Device (</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                 
$children : eContents,</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                 
eContents.size &gt; 0</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
)</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">forall</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> (</span></p>


<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                 
$child : Device (</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                       
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">state
== &quot;DOWN&quot;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                 
) </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">from</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> $children</span></p>


<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
)</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">     
</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">then</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">       
</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">           
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: olive;" lang="EN-US">…</span></p>

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">end</span></b></p>

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US"> </span></b></p>

<p class="MsoNormal"><span lang="EN-US">… which by the way worked perfectly fine as long as I was not
using objects from a model. My first idea was that for some strange reason the
object might get copied so that I actually would have two different references
after modifying it, but this is not the case. When I initialize the rule base
with the circumstances that the second rule would fire, it really does. It just
seems as it would not being evaluated after changing the attribute, but this is
not the case either! So all I can think of is some strange caching, maybe in
combination with the </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">forall </span></b><span lang="EN-US">statement?
Maybe someone has some experience when using Drools with EMF + CDO and
experienced as similar issue? </span></p>

<p class="MsoNormal"><span lang="EN-US">Any help would be very very very much appreciated! </span></p>

<p class="MsoNormal"><span style="font-size: 10pt;" lang="EN-US">Thanks in advance</span></p>

<p class="MsoNormal"><span style="font-size: 10pt;" lang="EN-US"> </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; color: rgb(136, 136, 136);" lang="EN-US">Georg</span><span style="color: rgb(136, 136, 136);"></span></p>

</div>

</div><div class="im">

<p class="MsoNormal" style="margin-bottom: 12pt;"><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></p>

</div></div>

<p class="MsoNormal"> </p>

</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>