[rules-users] exists + normal column constraints - how many times a rule is cal led in the end????

nicolae oana oananicolae1981 at yahoo.com
Tue Feb 20 03:37:53 EST 2007


Vlad,

exists Person(role == "parent")  

checks if in workingMemory is at least one Person fact having  attribute role == "parent", in both your examples.

Your reasoning is correct: the four facts with role =="child" will activate the rule. So, the result for your second example will be the same as the first result, for your list of facts, no matter how you switch the columns.

Regards,
               Oana

"Olenin, Vladimir (MOH)" <Vladimir.Olenin at moh.gov.on.ca> wrote:                Hi,
   
  I’m not sure my understanding of ‘existential quantifiers’ is correct. Hopefully, someone can clear it up a bit

   
  Providing I have the following fact class:
   
  Person(role: parent/child, name)
   
  And following facts:
   
  1: parent, John
  2: parent, Alice
  3: parent, Steve
  4: parent, Jane
  5: child, Eric
  6: child, Rob
  7: child, May
  8: child, April
   
  I expect the rule
   
  Rule “iterate children if at least one parent is found”
  When
              exists Person(role == ‘parent’)
              $child: Person(role == ‘child’)
  Then
              // do smth for each $child if at least one parent is found
  End
   
   
  To iterate through all ‘child’ persons (facts 5 through 8), ie the action will be called exactly 4 times. Is this correct? What would happen if I swap the order of the conditions (with ‘parent exists’ constrain going _after_ ‘child’ constraint):
   
  When
              $child: Person(role == ‘child’)
              exists Person(role == ‘parent’)
   
  Thanks,
   
  Vlad
  
  _______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


 
---------------------------------
Now that's room service! Choose from over 150,000 hotels 
in 45,000 destinations on Yahoo! Travel to find your fit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070220/68a4edce/attachment.html 


More information about the rules-users mailing list