<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3603" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=236335908-29102009><FONT face=Arial 
color=#0000ff size=2>Hi Wolfgang,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=236335908-29102009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=236335908-29102009><FONT face=Arial 
color=#0000ff size=2>I'm interested with your reply and am trying to better 
understand it (although the use-case has nothing to do with what I 
do!)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=236335908-29102009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=236335908-29102009><FONT face=Arial 
color=#0000ff size=2>The Score class has a constructor taking Deal and level 
(assume to be akin to "priority" in the original post); however your example 
Fact insertions exclude level for the Score Fact. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=236335908-29102009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=236335908-29102009></SPAN><FONT 
face=Arial><FONT color=#0000ff><FONT size=2>I<SPAN class=236335908-29102009> 
assume Score's level should be initially set to the highest (most granular) 
level; e.g.&nbsp;2 in the example cited (ranging from 
0-2)?</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN 
class=236335908-29102009></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN 
class=236335908-29102009>It's good to see and understand other's 
approaches.</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN 
class=236335908-29102009></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN 
class=236335908-29102009>Cheers,</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN 
class=236335908-29102009></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN 
class=236335908-29102009>Mike</SPAN></FONT></FONT></FONT></DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <HR tabIndex=-1>
  <FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org 
  [mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Wolfgang 
  Laun<BR><B>Sent:</B> 29 October 2009 07:09<BR><B>To:</B> Rules Users 
  List<BR><B>Subject:</B> Re: [rules-users] Specific Agenda strategy to control 
  which rulesto fire<BR></FONT><BR></DIV>
  <DIV></DIV>I don't think you should consider an agenda strategy for 
  this.<BR><BR>Add a simple class:<BR>&nbsp;&nbsp; class 
  Score{<BR>&nbsp;&nbsp;&nbsp;&nbsp; int level; int coun; Deal deal; Book book; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp; Score( Deal deal, int level ){...} <BR>&nbsp; 
  }<BR><BR>and insert an instance along with the Deal to be 
  classified:<BR><BR>insert( deal );<BR>insert( new Score( deal ) 
  );<BR><BR>Rules for level 2 would be written according to:<BR><BR>rule "trader 
  and product"<BR>salience 10<BR>when<BR><FONT face=Verdana size=2><SPAN 
  lang=EN-GB style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">&nbsp;&nbsp; $s : 
  Score( level == 2, $d : deal )<BR></SPAN></FONT>&nbsp;&nbsp;&nbsp; Deal( this 
  == $d, <FONT face=Verdana size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">trader=="Alex", product == 
  "GOOG" )<BR>then<BR>&nbsp;&nbsp; $s.setCount( $s.getCount() + 1 
  );<BR>&nbsp;&nbsp; $s.setBook( "B2" );<BR>end<BR><BR>Then you'll need a couple 
  of rules handling success and failure:<BR><BR>rule "post level 
  success"<BR>salience 5<BR>when<BR>&nbsp;&nbsp; $s : Score( $l : level, count 
  == 1, $d : deal, $b : book )<BR>then<BR>&nbsp;&nbsp; assign $d to $b, retract 
  $d<BR>&nbsp;&nbsp; retract( $s );<BR>end <BR></SPAN></FONT><BR><FONT 
  face=Verdana size=2><SPAN lang=EN-GB 
  style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">rule "post level 
  failure"<BR>salience 5<BR>when<BR>&nbsp;&nbsp; $s : Score( $l : level, count 
  != 1 )<BR>then<BR>&nbsp;&nbsp; modify( $s 
  ){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setLevel( $l - 1 );<BR>&nbsp;&nbsp; 
  }<BR>end </SPAN></FONT><BR><BR>Rules for level 1 would also be at salience 
  10.<BR><BR>A rule for level == 0 should catch Deals "gone down" through all 
  levels.<BR><BR>-W<BR><BR><BR><BR>
  <DIV class=gmail_quote>2009/10/28 Costigliola Joel (EXT) <SPAN dir=ltr>&lt;<A 
  href="mailto:joel.costigliola-ext@natixis.com">joel.costigliola-ext@natixis.com</A>&gt;</SPAN><BR>
  <BLOCKQUOTE class=gmail_quote 
  style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
    <DIV lang=FR vlink="purple" link="blue">
    <DIV>
    <DIV>
    <DIV>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Hello all,</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">I need some help to to set a 
    specific Agenda strategy in order to control finely which activated rules 
    will be fired.</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Problem context 
    :</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">-----------------</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">My company is a bank where 
    traders are making deals on markets, these deals must be classified in book, 
    this is what we call “booking process”.</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Booking is done according to 
    booking criteria : which trader has made the deal ? on which product ? wich 
    market ? etc … </SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">A booking rule defines a set 
    of criteria and the target book where the deal will classified, it also has 
    a priority, note that it is ok that two booking rule have same priority. 
    </SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">I want to implement booking 
    rule as Drools rule.</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Several booking rule can be 
    applied to a deal, in that case choosing the right booking rule to fire 
    depends on the following algorithm : </SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">- look all the activated 
    booking rule of the highest priority, </SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">--- if there is a unique rule 
    apply it</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">--- if there is no unique rule 
    (0 rule or more than one), look at rules of a lesser priority and apply the 
    same logic.</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Next section is an example 
    that will clear things (I hope).</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Example :</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">---------</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">A deal D1 has been done by 
    Alex on NY market to buy Google stocks.</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">We have 3 booking rules : 
    </SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">- BR1 : criteria = trader=Alex 
    / book = B1</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">- BR2 : criteria = trader=Alex 
    and product = google stock / book = B2</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">As BR2 is more precise than 
    BR1, il will matches the deal and book it in B1</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">If the deal was on another 
    product, BR1 would have been applied.</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Things gets more complicated 
    when 2 rules of same priority can be applied. </SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Let's imagine we add the 
    following booking rule </SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">- BR3 : criteria = trader=Alex 
    and market = NY / book = B3</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">We have a problem to book D1 
    since BR2 and BR3 can be applied but have same priority. </SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">We can't choose one over the 
    other thus we must apply a less precise/prioritary rule (if unique at its 
    own precision level).</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">In my example, that would lead 
    to apply BR1.</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Question :</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">----------</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">If I define BR1,BR2,BR3 as 
    Drools rules, how can I tell Drools : </SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">- to execute a rule only if 
    there is no other active rule with same precision that could be applied 
    ?</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">- to look for a unique 
    matching rule with less precision level ?</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">I think it's the Agenda 
    responsibility to take this decision, but I don't know how implement 
    that.</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Can you give some advices on 
    that ?</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN lang=EN-GB 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Thanks for your lights in 
    advance,</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Regards,</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Joel</SPAN></FONT></P>
    <P class=MsoNormal><FONT face=Verdana size=2><SPAN 
    style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"></SPAN></FONT>&nbsp;</P>
    <P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
    style="FONT-SIZE: 12pt"></SPAN></FONT>&nbsp;</P></DIV></DIV>
    <DIV></DIV>
    <DIV>
    <HR>
    </DIV>
    <DIV align=justify><FONT face=Arial color=gray size=1><SPAN 
    style="FONT-SIZE: 12pt"><FONT face=Arial><FONT face="Times New Roman" 
    color=#000000 size=3></FONT></FONT></SPAN></FONT>&nbsp;</DIV>
    <DIV align=justify><FONT color=gray><SPAN style="FONT-SIZE: 12pt"><FONT 
    color=#000000 size=2>Ce courriel et toutes les pièces jointes sont 
    confidentiels et peuvent être couverts par un privilège ou une protection 
    légale. Il est établi à l’attention exclusive de ses destinataires. Toute 
    utilisation de ce courriel non conforme à sa destination, toute diffusion ou 
    toute publication, totale ou partielle, est interdite, sauf autorisation 
    expresse préalable. Toutes opinions exprimées dans ce courriel ne sauraient 
    nécessairement refléter celle de Natixis, de ses filiales. Elles sont aussi 
    susceptibles de modification sans notification préalable. Si vous recevez ce 
    courriel par erreur, merci de le détruire et d’en avertir immédiatement 
    l’expéditeur. L’Internet ne permettant pas d’assurer l’intégrité de ce 
    courriel, Natixis décline toute responsabilité s’il a été altéré, déformé ou 
    falsifié et chaque destinataire qui utilise ce mode de communication est 
    supposé en accepter les risques.</FONT></SPAN></FONT> </DIV>
    <DIV align=justify><FONT color=gray><SPAN 
    style="FONT-SIZE: 12pt"></SPAN></FONT>&nbsp;</DIV>
    <DIV align=justify><FONT color=gray><SPAN 
    style="FONT-SIZE: 12pt"></SPAN></FONT><FONT color=gray><SPAN 
    style="FONT-SIZE: 12pt"><FONT color=#000000 size=2>This email and any 
    attachment are confidential and may be legally privileged or otherwise 
    protected from disclosure. It is intended only for the stated addressee(s) 
    and access to it by any other person(s) is unauthorised. Any use, 
    dissemination or disclosure not in accordance with its purpose, either in 
    whole or in part, is prohibited without our prior formal approval. Any 
    opinion expressed in this email may not necessarily reflect the opinion of 
    Natixis, its affiliates. It may also be subject to change without prior 
    notice. If you are not an addressee, you must not disclose, copy, circulate 
    or in any other way use or rely on the information contained in this email. 
    If you have received it in error, please inform us immediately and delete 
    all copies. The Internet can not guarantee the integrity of this email 
    therefore Natixis shall not be liable for the email if altered, changed or 
    falsified and anyone who communicates with us by e-mail is taken to accept 
    these risks.</FONT></SPAN></FONT> </DIV>
    <P class=MsoNormal align=justify></P>
    <HR>

    <P></P>
    <P></P></DIV></DIV><BR>_______________________________________________<BR>rules-users 
    mailing list<BR><A 
    href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR><A 
    href="https://lists.jboss.org/mailman/listinfo/rules-users" 
    target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR><BR></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>