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