[rules-users] Firing a rule if at least its two conditions are satified
PAYET, Manuel
manuel.payet at capgemini.com
Thu Jun 3 08:46:24 EDT 2010
Yes, you're right Tihomir Surdilovic
your solution is way more elegant than mine.
And to skasab2s: you should use a function to avoid copy and paste three time the same then clause
________________________________
De : rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] De la part de Tihomir Surdilovic
Envoyé : jeudi 3 juin 2010 14:40
À : rules-users at lists.jboss.org
Objet : Re: [rules-users] Firing a rule if at least its two conditions are satified
IMO you can just use activation groups and not have to deal with incrementing, something like:
rule first
activation-group "myactgrp"
when
Condition A
Condition B
then
...
end
rule second
activation-group "myactgrp"
when
Condition A
Condition C
then
...
end
rule third
activation-group "myactgrp"
when
Condition B
Condition C
then
...
end
When one of these rules fire it will cancel the activation of all other rules in the same activation group. You can also then add salience to control rule priority.
On 6/3/10 8:15 AM, PAYET, Manuel wrote:
If I were you, I'd use something like
Global java.lang.Integer cnt;
Rule "before everything"
Salience 10
When
Eval(true)
Then
Cnt=0
End
Rule "condition A"
When
condition A
Then
cnt=cnt+1;
End
Rule "condition B"
When
condition B
Then
cnt=cnt+1;
End
Rule "condition C"
When
condition B
Then
cnt=cnt+1;
End
Rule "action 1, after everything"
Salience -10
When
eval(cnt>=2)
Then
execute action 1
End
Of course, if you change the fact, you'll probably have to think about things like lock-on-active to increment only one time the cnt variable
-----Message d'origine-----
De : rules-users-bounces at lists.jboss.org<mailto:rules-users-bounces at lists.jboss.org> [mailto:rules-users-bounces at lists.jboss.org] De la part de skasab2s
Envoyé : jeudi 3 juin 2010 14:04
À : rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
Objet : [rules-users] Firing a rule if at least its two conditions are satified
Hello,
we are using Drools in our company. We have a rule with three conditions in this format:
when
Condition A
Condition B
Condition C
then
execute Action 1
Now we have a situation, in which the rule should fire if AT LEAST two of the three conditions are satisfied. Do you know how to implement this? Any ideas or hints?
Many thanks and regards!
skasab2s.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Firing-a-rule-if-at-least-its-two-conditions-are-satified-tp867432p867432.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is
intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to
read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message
in error, please notify the sender immediately and delete all copies of this message.
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
</PRE><p style="font-family:arial;color:grey" style="font-size:13px">This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.</p><PRE>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100603/94ae6b7e/attachment.html
More information about the rules-users
mailing list