The solution I adopted is to make SwitchState not a subclass of TrackState but of ElementState, which means that the field(s) to be inherited from TrackState have to be duplicated in SwitchState. (Luckily, here it is only one field.)<br>
<br>Adding a type-identifying field goes against the (my) idea of classes for identifying categories and using them as an implicit constraint in rules, making them more readable. That&#39;s one of the benefits of having an OO RBS, isn&#39;t it?<br>
<br>Anyway, I just wanted to draw people&#39;s attention to this hidden trap; working around it is no problem once you know it is there.<br><br>-W<br><br><br><div class="gmail_quote">On 12 December 2010 05:06, Greg Barton <span dir="ltr">&lt;<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>&gt;</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;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
Well, seeing as you&#39;re already maintaining two parallel type hierarchies, and it&#39;s a mismatch between the two that&#39;s causing the problem, you might as well use that in the rules.<br><br><div><div class="im">   rule &quot;Xyz state update&quot;  <br>
   when<br></div>       $s: XyzState( $id: id, $type: type ... )<br>       $e: Xyz( id == $id, type == $type )<div class="im"><br>   then<br>     //...update $e, retract $s<br>   end<br><br></div></div><div><div class="im">
   rule &quot;Xyz state for unknown element&quot;<br>   when<br></div>      $s: XyzState( $id: id, $type: type )</div><div>      not Xyz( id == $id, type == $type )</div><div class="im"><div>  then<br>      //... diagnostic, retract $s<br>
  end</div><div><br></div></div><div>That oughter do
 it, and it avoids salience.<br>--- On <b>Sat, 12/11/10, Wolfgang Laun <i>&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">
<br>From: Wolfgang Laun &lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;<br>Subject: [rules-dev] A remarkable flop<br>To: &quot;Rules Dev List&quot; &lt;<a href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a>&gt;<br>
Date: Saturday, December 11, 2010, 10:23 AM<div><div></div><div class="h5"><br><br><div><br>
Given classes Switch and Track, and the &quot;natural&quot; class hierarchy representing state changes for these two elements:<br>
   ElementState<br>
   TrackState extends ElementState (&quot;free/occupied&quot;)<br>
   SwitchState extends TrackState (adds &quot;left/right/moving&quot;)<br>Now we have rules for updating Switch and Track elements, like this one:<br>
   rule &quot;Xyz state update&quot;  <br>
   when<br>
       $s: XyzState( $id: id, ... )<br>
       $e: Xyz( id == $id )<br>
   then<br>
     //...update $e, retract $s<br>
   end<br>
and, since we want to catch bad ids, also<br>
   rule &quot;Xyz state for unknown element&quot;<br>
   when<br>
      $s: XyzState( $id: id )<br>
      not Xyz( id == $id )<br>
  then<br>
      //... diagnostic, retract $s<br>
  end<br>
<br>
Best practice, wouldn&#39;t you say?<br><br>Testing by inserting a few of SwitchState objects works fine:<br>   updated: Switch 5 RIGHT occupied<br>   updated: Switch 2 RIGHT<br>   updated: Switch 1 RIGHT occupied<br> so everything is allright, wouldn&#39;t you say? <br>


<br>Add another SwitchState for Switch &quot;4&quot; to the test, and suddenly:<br>  updated: Switch 4 RIGHT<br>  track state for unknown element 5<br>  updated: Switch 2 RIGHT<br>  updated: Switch 1 RIGHT occupied<br>What&#39;s this?!<br>

<br>After some headscratching I realized that the negative rule for the SwitchState&#39;s superclass TrackState produces another activation, since, for any Switch element with an id x there clearly isn&#39;t a Track element with id x! This activation <i>occasionally </i>precedes the activation for the match in the &quot;update&quot; rule.<br>

<br>This is annoying. Of course, negative salience for the &quot;not&quot; rules fixes this, but who would have thought that you need it with conditions (seemingly!) describing disjoint situations. And the negative salience is counter-intuitive, since normally you&#39;d perform the check &quot;no such element&quot; <i>before </i>permitting any update action.<br>

<br>Remarkable.<br>Wolfgang<br><br><br><br> <br> <br><br><br>
</div><br></div></div>-----Inline Attachment Follows-----<br><br><div>_______________________________________________<br>rules-dev mailing list<br><a href="http://mc/compose?to=rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br></div></blockquote></div></td></tr></tbody></table><br>

      <br>_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
<br></blockquote></div><br>