<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Just a quick observance, but this is also an excellent example of subsumption of rules (almost). The first rule conditions elements are all contained in the second rule. However, the action items are different. Therefore the first rule should say that the topping does not contain sausage nor pepperoni... Or, the objects could be written so that there would be something to flag a cheese-only pizza otherwise both rules would fire as written. :-(<div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>SDG</div><div>James Owen</div><div>Founder October Rules Fest</div><div>Senior Consultant / Architect KBSC</div><div><span class="Apple-style-span" style="font-family: 'Bodoni SvtyTwo SC ITC TT'; "><font class="Apple-style-span" color="#976635"><a href="http://www.kbsc.com">http://www.kbsc.com</a></font></span></div><div><span class="Apple-style-span" style="font-family: 'Bodoni SvtyTwo SC ITC TT'; "><font class="Apple-style-span" color="#976635"><a href="http://www.OctoberRulesFest.org">http://www.OctoberRulesFest.org</a></font></span></div><div><font class="Apple-style-span" face="'Bodoni SvtyTwo SC ITC TT'"><font class="Apple-style-span" color="#976635">Twitter: OctRulesFest</font></font></div><div><font class="Apple-style-span" face="Garamond"><font class="Apple-style-span" color="#0000FF">Blogs:</font></font></div><div><font class="Apple-style-span" face="Garamond"><font class="Apple-style-span" color="#0000FF"><a href="http://JavaRules.blogspot.com">http://JavaRules.blogspot.com</a> [Rulebased Systems Blog]</font></font></div><div><font class="Apple-style-span" face="Garamond"><font class="Apple-style-span" color="#0000FF"><a href="http://ORF2009.blogspot.com">http://ORF2009.blogspot.com</a> [October Rules Fest Blog]</font></font></div><div><font class="Apple-style-span" face="Garamond"><font class="Apple-style-span" color="#0000FF"><a href="http://exscg.blogspot.com/">http://exscg.blogspot.com/</a> [Expert Systems Consulting Group Blog]</font></font></div><div><font class="Apple-style-span" color="#0000FF" face="Garamond"><br></font></div><div><font class="Apple-style-span" color="#0000FF"><font class="Apple-style-span" face="'Lucida Handwriting'" size="4"><span class="Apple-style-span" style="font-size: 14px; "><i>"If I have seen a little further it is by standing on the shoulders of giants."</i></span></font></font></div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 14px; "><b>Sir Isaac Newton in a letter to Robert Hooke, 5 Feb 1676</b></span></font></div><div><font class="Apple-style-span" color="#FF0000"><span class="Apple-style-span" style="font-size: medium; "><b><br></b></span></font></div><div><span class="Apple-style-span" style="font-size: medium; "><b>Come to October Rules Fest and stand on the shoulders of the Giants of the industry; if only for a week.</b></span></div><div><font class="Apple-style-span" face="arial" size="3"><span class="Apple-style-span" style="font-size: 12px; line-height: 14px; -webkit-border-horizontal-spacing: 6px; -webkit-border-vertical-spacing: 6px; "><br></span></font></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></span></div></span></div></div></div></span></div></span><br class="Apple-interchange-newline"> </div><br><div><div>On Sep 1, 2009, at 9:29 PM, Greg Barton wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>I hope you're not going through all of that trouble just to get the functionality from that concrete example. You get that for free with Drools' default conflict resolution, which includes "specificity." Specificity means that rules with the more specific conditions, and all else equal, are fired first. So between these two rules, only the CheeseSausagePepperoniPepper one fires: <br><br>rule "CheeseOnly"<br><span class="Apple-tab-span" style="white-space:pre">        </span>when<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>p : Pizza( )<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t1: Topping( pizza == p, name == "cheese" )<br><span class="Apple-tab-span" style="white-space:pre">        </span>then<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>System.out.println( "Eating cheese pizza" ); <br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>retract( t1 );<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>retract( p );<br>end<br><br>rule "CheeseSausagePepperoniPepper"<br><span class="Apple-tab-span" style="white-space:pre">        </span>when<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>p : Pizza( )<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t1: Topping( pizza == p, name == "cheese" )<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t2: Topping( pizza == p, name == "sausage" )<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t3: Topping( pizza == p, name == "pepperoni" )<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>t4: Topping( pizza == p, name == "pepper" )<br><span class="Apple-tab-span" style="white-space:pre">        </span>then<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>System.out.println( "Eating cheese sausage pepperoni pepper pizza" ); <br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>retract( t4 ); <br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>retract( t3 ); <br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>retract( t2 );<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>retract( t1 );<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>retract( p );<br>end<br><br>See the attached project.<br><br>--- On Tue, 9/1/09, Bill Tarr <<a href="mailto:javatestcase@yahoo.com">javatestcase@yahoo.com</a>> wrote:<br><br><blockquote type="cite">From: Bill Tarr <<a href="mailto:javatestcase@yahoo.com">javatestcase@yahoo.com</a>><br></blockquote><blockquote type="cite">Subject: [rules-users] Trouble getting Dynamic Salience working<br></blockquote><blockquote type="cite">To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br></blockquote><blockquote type="cite">Date: Tuesday, September 1, 2009, 7:28 PM<br></blockquote><blockquote type="cite">We have a winner! Many thanks<br></blockquote><blockquote type="cite">Michal, hope I can return the favor one day.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">salience ( return getSalience4() )<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">for the record, my function looks something like (after<br></blockquote><blockquote type="cite">tempate evaluation):<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><pre><br></blockquote><blockquote type="cite">function int getSalience4(){<br></blockquote><blockquote type="cite"> int salience = 0;<br></blockquote><blockquote type="cite"> if("VALUE"=="VALUE") salience += 1000;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> return salience;<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"></pre><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I think the combination activation-group and dynamic<br></blockquote><blockquote type="cite">salience for rule-template projects are pretty useful. <br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Just for anyone interested, the tempate code looks<br></blockquote><blockquote type="cite">something like this:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><pre><br></blockquote><blockquote type="cite">rule "Some Rule_@{row.rowNumber}"<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> activation-group "@{PARAM1}-@{PARAM2}"<br></blockquote><blockquote type="cite"> salience ( return getSalience@{row.rowNumber}() )<br></blockquote><blockquote type="cite"></pre><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">where PARAM1 and PARAM2 make up a kind of key. I only want<br></blockquote><blockquote type="cite">to execute one rule that matches that key, no matter how<br></blockquote><blockquote type="cite">many options there are.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Rules that have additional parameters get higher salience<br></blockquote><blockquote type="cite">than rules with less parameters, so here is my function.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><pre><br></blockquote><blockquote type="cite">function int getSalience@{row.rowNumber}(){<br></blockquote><blockquote type="cite"> int salience = 0;<br></blockquote><blockquote type="cite"> if("@{PARAM3}"=="@{PARAM3}") salience += 1000;<br></blockquote><blockquote type="cite"> if("@{PARAM4}"=="@{PARAM4}") salience += 1000;<br></blockquote><blockquote type="cite"> return salience;<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"></pre><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">A concrete example could be pizza. So there are 3 types<br></blockquote><blockquote type="cite">of pizza, all are grouped in the same activation-group.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">cheese, pepperoni<br></blockquote><blockquote type="cite">cheese, pepperoni, sausage<br></blockquote><blockquote type="cite">cheese, pepperoni, meatball, pepper<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Any cheese and pepperoni pizza should could match all these<br></blockquote><blockquote type="cite">rules, but more toppings is always better for me.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">So cheese, pepperoni, onion, pepper getts a salience of<br></blockquote><blockquote type="cite">2000, and is the only rule evaluated.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On Tue Sep 1 18:39:13 EDT 2009, Michal Bali michalbali at<br></blockquote><blockquote type="cite">gmail.com wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">does this work?<br></blockquote><blockquote type="cite">salience ( return getSalience() )<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">or this:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">salience ( getSalience();)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On Tue, Sep 1, 2009 at 6:50 PM, Bill Tarr <javatestcase<br></blockquote><blockquote type="cite">at yahoo.com> wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">Possibily just a simple MVEL error, but I've been<br></blockquote></blockquote><blockquote type="cite">struggling for a while<br></blockquote><blockquote type="cite"><blockquote type="cite">and thought I'd see if anyone could help.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I just want to run a logic test to determine salience<br></blockquote></blockquote><blockquote type="cite">for some rules I am<br></blockquote><blockquote type="cite"><blockquote type="cite">generating with rules-templates. Even after making<br></blockquote></blockquote><blockquote type="cite">the logical test "true"<br></blockquote><blockquote type="cite"><blockquote type="cite">I can't get any of variation to compile.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(true ? "1000" : "0")<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">**produces**<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Unable to build expression for 'salience' : not a<br></blockquote></blockquote><blockquote type="cite">statement, or badly<br></blockquote><blockquote type="cite"><blockquote type="cite">formed structure<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">( true ? 1000 : 0)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">**produces**<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Unable to build expression for 'salience' : invalid<br></blockquote></blockquote><blockquote type="cite">number literal: 1000<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">salience ( getSalience() )<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">...<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">function int getSalience(){return 0;}<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">**produces**<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Unable to build expression for 'salience' :<br></blockquote></blockquote><blockquote type="cite">org.mvel2.util.MethodStub<br></blockquote><blockquote type="cite"><blockquote type="cite">cannot be cast to java.lang.Class'(<br></blockquote></blockquote><blockquote type="cite">getSalienceNONCDW() )'<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Seems like I am missing something simple, but I've<br></blockquote></blockquote><blockquote type="cite">tried many variations on<br></blockquote><blockquote type="cite"><blockquote type="cite">the above, and have been unable to find any working<br></blockquote></blockquote><blockquote type="cite">examples of using a<br></blockquote><blockquote type="cite"><blockquote type="cite">logical test in salience, so if anyone has any<br></blockquote></blockquote><blockquote type="cite">direction it would be greatly<br></blockquote><blockquote type="cite"><blockquote type="cite">appreciated.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Thanks!<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Bill<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> <br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">rules-users mailing list<br></blockquote><blockquote type="cite"><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br></blockquote><blockquote type="cite"><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote><blockquote type="cite"><br></blockquote><br><br><span><DroolsSpecificity.tar.gz></span>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users<br></div></blockquote></div><br></div></body></html>