<br><font size=2 face="sans-serif">Antonio,</font>
<br>
<br><font size=2 face="sans-serif">I think that the problem may not be
the exists. &nbsp;I'm not an expert at solver, but I believe that there
may be an issue with the consequence of your first rule.</font>
<br>
<br><tt><font size=2>insertLogical(new IntConstraintOccurrence(&quot;diff&quot;,
10));</font></tt>
<br>
<br><font size=2 face="sans-serif">The way that insertLogical works the
new object will only be inserted if it does not .equals() with another
fact in the working memory (or maybe in the truth maintenance system).
&nbsp;Without seeing the rest of the solver (moves and such) I can't say
for certain, but I think that each move is being evaluated to the same
weight because the 1st rule will never result in a constraint occurrence
&gt; 10. &nbsp;Multiple matches of that rule will only result in one IntConstraintOccurrence
being inserted.<br>
</font>
<br><font size=2 face="sans-serif">Maybe Wolfgang or someone else a little
more experienced can verify my assumptions about how insertLogical works.</font>
<br>
<br><font size=2 face="sans-serif">Thanks,</font>
<br><font size=3>Steve</font>
<br>
<br><tt><font size=2>rules-users-bounces@lists.jboss.org wrote on 05/05/2010
04:07:37 AM:<br>
<br>
&gt; [image removed] </font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Re: [rules-users] how &quot;exists&quot; works exactly?</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Wolfgang Laun </font></tt>
<br><tt><font size=2>&gt; <br>
&gt; to:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Rules Users List</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; 05/05/2010 04:15 AM</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Sent by:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; rules-users-bounces@lists.jboss.org</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Please respond to Rules Users List</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; One thing I've noticed is that<br>
&gt; &nbsp; &nbsp;not (exists (EPackage( &nbsp; ) ) )<br>
&gt; is a roundabout (and possibly inefficient) way of saying<br>
&gt; &nbsp; &nbsp;not (EPackage( ... ) )<br>
&gt; <br>
&gt; It's difficult (for me) to deduce what should happen in the rules
as<br>
&gt; the description of the<br>
&gt; fact data isn't clear enough (for me).<br>
&gt; <br>
&gt; -W<br>
&gt; <br>
&gt; 2010/5/5 Antonio Neto &lt;antoniosouzaneto@gmail.com&gt;:<br>
&gt; &gt; Any idea? Please...<br>
&gt; &gt;<br>
&gt; &gt; 2010/5/4 Antonio Neto &lt;antoniosouzaneto@gmail.com&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Hi all,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I don't know exactly why I have a problem in my &quot;exists&quot;
function. I've<br>
&gt; &gt;&gt; tried many different ways, but it does not work. Anybody
could help me,<br>
&gt; &gt;&gt; please?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I have the following rules:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; rule &quot;diff&quot;<br>
&gt; &gt;&gt; when<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp; $var1: EReference(name == &quot;employee&quot;)<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp; $var2: EClass(name == &quot;Company&quot;,
EAllReferences contains $var1)<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp; not (exists( EPackage(EClassifiers contains
$var2 ) ))<br>
&gt; &gt;&gt; then<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp; insertLogical(new IntConstraintOccurrence(&quot;diff&quot;,
10));<br>
&gt; &gt;&gt; end<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; rule &quot;ClassesNotReferenced&quot;<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp; when<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $q1 : EClass();<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $q2 : EPackage(EClassifiers
contains $q1);<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; not( exists (
EReference(EType == $q1) ));<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp; then<br>
&gt; &gt;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertLogical(new
IntConstraintOccurrence(&quot;ClassesNotReferenced&quot;,<br>
&gt; &gt;&gt; 1, $q1));<br>
&gt; &gt;&gt; end<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; and in my facts (and my EPackage) I have 4 instances of EClass
&quot;Company&quot;<br>
&gt; &gt;&gt; with a EReference &quot;employee&quot;, and another EClass
&quot;Person&quot;.&nbsp; I still have a<br>
&gt; &gt;&gt; &quot;move&quot; that removes EClasses in my Drools Solver.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I need to have only one classe &quot;Company&quot; after
processing. But it removes<br>
&gt; &gt;&gt; only the EClass &quot;Person&quot;, when it was supposed
to remove one <br>
&gt; EClass &quot;Person&quot;<br>
&gt; &gt;&gt; and 3 ECLasses &quot;Company&quot;. Leaving one EClass &quot;Company&quot;
in the end.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; The problem is:&nbsp; when Drools tries to remove a EClass
&quot;Person&quot; it thinks<br>
&gt; &gt;&gt; that&nbsp; the EClass &quot;Company&quot; does not exists.
But in fact there are3 others.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Any clue about it, please ?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Thanks<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Bests regards<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Antonio<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; rules-users mailing list<br>
&gt; &gt; rules-users@lists.jboss.org<br>
&gt; &gt; </font></tt><a href="https://lists.jboss.org/mailman/listinfo/rules-users"><tt><font size=2>https://lists.jboss.org/mailman/listinfo/rules-users</font></tt></a><tt><font size=2><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; rules-users@lists.jboss.org<br>
&gt; </font></tt><a href="https://lists.jboss.org/mailman/listinfo/rules-users"><tt><font size=2>https://lists.jboss.org/mailman/listinfo/rules-users</font></tt></a><tt><font size=2><br>
</font></tt>