<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-GB" link="blue" vlink="purple">
<div class="Section1">
<p class="MsoPlainText">A better approach is probably to split up the conditions from action.<o:p></o:p></p>
<p class="MsoPlainText">Each condition would be a separate rule which would use insertLogically to insert a new object.<o:p></o:p></p>
<p class="MsoPlainText">Then have another rule which accumulates and counts how many of these objects exist in the working memory. If the count is >= 2 then perform the action.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Thomas<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:
"Tahoma","sans-serif";color:windowtext">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of </b>Tihomir Surdilovic<br>
<b>Sent:</b> 03 June 2010 13:40<br>
<b>To:</b> rules-users@lists.jboss.org<br>
<b>Subject:</b> Re: [rules-users] Firing a rule if at least its two conditions are satified<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">IMO you can just use activation groups and not have to deal with incrementing, something like:<br>
<br>
rule first<br>
activation-group "myactgrp"<br>
when<br>
Condition A<br>
Condition B<br>
then<br>
...<br>
end<br>
<br>
<br>
rule second<br>
activation-group "myactgrp"<br>
when<br>
Condition A<br>
Condition C<br>
then<br>
...<br>
end<br>
<br>
rule third<br>
activation-group "myactgrp"<br>
when<br>
Condition B<br>
Condition C<br>
then<br>
...<br>
end<br>
<br>
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.<br>
<br>
<br>
On 6/3/10 8:15 AM, PAYET, Manuel wrote: <o:p></o:p></p>
<pre>If I were you, I'd use something like <o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Global java.lang.Integer cnt;<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Rule "before everything"<o:p></o:p></pre>
<pre>Salience 10<o:p></o:p></pre>
<pre>When<o:p></o:p></pre>
<pre>Eval(true)<o:p></o:p></pre>
<pre>Then<o:p></o:p></pre>
<pre>Cnt=0<o:p></o:p></pre>
<pre>End<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Rule "condition A"<o:p></o:p></pre>
<pre>When <o:p></o:p></pre>
<pre> condition A<o:p></o:p></pre>
<pre>Then<o:p></o:p></pre>
<pre> cnt=cnt+1;<o:p></o:p></pre>
<pre>End<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Rule "condition B"<o:p></o:p></pre>
<pre>When <o:p></o:p></pre>
<pre> condition B<o:p></o:p></pre>
<pre>Then<o:p></o:p></pre>
<pre> cnt=cnt+1;<o:p></o:p></pre>
<pre>End<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Rule "condition C"<o:p></o:p></pre>
<pre>When <o:p></o:p></pre>
<pre> condition B<o:p></o:p></pre>
<pre>Then<o:p></o:p></pre>
<pre> cnt=cnt+1;<o:p></o:p></pre>
<pre>End<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Rule "action 1, after everything"<o:p></o:p></pre>
<pre>Salience -10<o:p></o:p></pre>
<pre>When <o:p></o:p></pre>
<pre> eval(cnt>=2)<o:p></o:p></pre>
<pre>Then<o:p></o:p></pre>
<pre> execute action 1<o:p></o:p></pre>
<pre>End<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>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<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>-----Message d'origine-----<o:p></o:p></pre>
<pre>De : <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [<a href="mailto:rules-users-bounces@lists.jboss.org">mailto:rules-users-bounces@lists.jboss.org</a>] De la part de skasab2s<o:p></o:p></pre>
<pre>Envoyé : jeudi 3 juin 2010 14:04<o:p></o:p></pre>
<pre>À : <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><o:p></o:p></pre>
<pre>Objet : [rules-users] Firing a rule if at least its two conditions are satified<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Hello,<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>we are using Drools in our company. We have a rule with three conditions in this format:<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>when<o:p></o:p></pre>
<pre> Condition A<o:p></o:p></pre>
<pre> Condition B<o:p></o:p></pre>
<pre> Condition C<o:p></o:p></pre>
<pre>then <o:p></o:p></pre>
<pre> execute Action 1<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>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?<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Many thanks and regards!<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>skasab2s.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre> <o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>--<o:p></o:p></pre>
<pre>View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Firing-a-rule-if-at-least-its-two-conditions-are-satified-tp867432p867432.html">http://drools-java-rules-engine.46999.n3.nabble.com/Firing-a-rule-if-at-least-its-two-conditions-are-satified-tp867432p867432.html</a><o:p></o:p></pre>
<pre>Sent from the Drools - User mailing list archive at Nabble.com.<o:p></o:p></pre>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>rules-users mailing list<o:p></o:p></pre>
<pre><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><o:p></o:p></pre>
<pre><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is <o:p></o:p></pre>
<pre>intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to <o:p></o:p></pre>
<pre>read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message <o:p></o:p></pre>
<pre>in error, please notify the sender immediately and delete all copies of this message.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>rules-users mailing list<o:p></o:p></pre>
<pre><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><o:p></o:p></pre>
<pre><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> <o:p></o:p></pre>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data
may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br>
<br>
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>
**************************************************************************************<br>
</font>
</body>
</html>