[rules-dev] salience alternative with before/after

Mark Proctor mproctor at codehaus.org
Tue Feb 14 11:53:43 EST 2012


On 14/02/2012 16:25, Edson Tirelli wrote:
>
>    The overall idea of using labels instead of numbers is a good 
> thing, but I share some of the concerns Greg seems to have. It does 
> not matter if the underlying conflict resolution is based on numbers 
> or not, but mixing this concept with the concept of salience might be 
> confusing and bring runtime conflicts.
>
>     One situation that comes to mind is that as of today, all 
> conflicts and error messages are resolved by Drools at compile time. 
> Once the knowledge package is built, adding it to a kbase will not 
> generate errors or make the kbase inconsistent... so Drools has no 
> framework to prevent such addition or report back to the application 
> if such operation can't be completed because of a conflict and then 
> safely rolled back. A feature such as this requires runtime validation 
> as the dependencies can be defined in different knowledge packages 
> where the addition of one to a kbase does not cause any problems, but 
> the addition of the other can cause a circular dependency.
agreed.

For this to work we must be able to detect if a kbase change is invalid 
and roll back. We need this feature anyway, not just for label based 
conflict resolution, but also for other typs of problems. Such as trying 
to remove type declaration for a type used in rules that are still present.
>
>     Another related issue is that if the labels are just synonyms to 
> certain salience numbers, what happens when someone mixes salience 
> numbers with labels. How do you decide the order? Wolfgang suggests 
> mutual exclusivity (which also requires runtime checking), but I feel 
> that it would be too limiting. For some cases I prefer to simply 
> assign a number to one rule than having to annotate multiple rules in 
> order to say: this should fire before/after those rules.
>
>     In any case, Mark mentioned that he thinks that this is different 
> from ruleflows (and much lighter). This, in my mind, is an 
> implementation detail. If I am a user, at the moment, I don't see a 
> difference between ordering rules based on ruleflow groups and based 
> on this before/after other than that using ruleflow-groups, I can 
> define my order graphically in the flow editor, while in this thing I 
> will have to manage priority annotating every single rule, and if I 
> ever need to change the order of some of these priorities, I have to 
> fix it in multiple places instead of a single diagram.
The main different is salience is "inline" you don't need external 
declarations/invokcations to control orderling like you do with 
ruleflow-groups  and agenda-groups. So ignoring the implementation it's 
use is "lighter" for users.

But both "inlining" before and after and also externalising the control 
are compliementary things, actually the externalising aspect ties in 
with our idea for "classifical planning", 
http://en.wikipedia.org/wiki/STRIPS. ruleflow-groups and agend-agroups 
have it all wrong. ruleflow-groups are processes and thus brittle for 
change, agenda-groups have no over all archicture. Hiearathical Task 
Networks can be visualised a as a graph, yet are much more robust and 
fully rule based. So while before/after might handle "inline" we'll 
probably take a HTN approach for externalisation.


>
>     My point is that while the idea of a lightweight, labeled-priority 
> conflict resolution is good and desirable, I think we need to mature 
> the idea and maybe make that change in a transparent way for the user. 
> Maybe this whole concept can be unified with Mark's uber-group idea 
> instead of creating a separate feature that will be hard to manage and 
> use...
damn, and I was about to commit a working implementation ;)


>
>    My .02c
>
>    Edson
>
> On Tue, Feb 14, 2012 at 2:54 AM, Wolfgang Laun 
> <wolfgang.laun at gmail.com <mailto:wolfgang.laun at gmail.com>> wrote:
>
>     This is an excellent idea.
>
>     It should be reasonable to assume that "salience" and the use of
>     before/after are mutually exclusive.
>
>     Also, salience (irrespective of the way it is defined) should not be
>     confused with agenda groups. I tell my students that "focus" is
>     suitable for rule flow "in the large" and salience can be used for
>     fine-grained prioritizing (with the caveat that more levels than you
>     have fingers on your hand are evil).
>
>     The question is whether before and after should be rule annotations.
>     If you create a new package element you could define rule precedence
>     in one central place, exclusively referring to annotations, e.g.:
>
>     fire @reset before @cashflow before @print;
>
>     fire @yawn before @stretch before @scratch,
>          @dinner after @hightea after @lunch after @breakfast;
>
>     Here you see it at a glance, and it opens fewer possibilities for
>     creating loops.
>
>     -W
>
>     On 14/02/2012, Mark Proctor <mproctor at codehaus.org
>     <mailto:mproctor at codehaus.org>> wrote:
>     > Davide has suggested a good idea.
>     >
>     > Now that rules support annotations, and annotations with values. We
>     > should add a before/after keyword to each rule. before/after
>     would then
>     > take a list of annotations. The idea is to use this to generate
>     salience
>     > under the covers.
>     >
>     > rule resetBalance before( @cashflow ) when then end
>     >
>     > rule debit @cashflow when then end
>     >
>     > rule credit @cashflow when  then end
>     >
>     > rule printBalance after(@cashflow ) when then end.
>     >
>     > Salience gives one rule priority over another, thus it's
>     declaring an
>     > implicit relationship between rules. Yet it's a magic number that
>     > doesn't easily show this relation, and as the rulebase grows it
>     can be
>     > very hard to determine those relationships as specified by
>     salience from
>     > reading the rules. before/after allows you to specify
>     declarative the
>     > relationships betwen rules in a more maintainable and readable
>     way, even
>     > if under the covers it's just generating:
>     >
>     > rule resetBalance salience 100 when then end
>     >
>     > rule debit salience 0  when then end
>     >
>     > rule credit salience 0 when  then end
>     >
>     > rule printBalance saliance -100 when then end.
>     >
>     > Yes there are agenda-groups and ruleflow-groups, but they can be
>     a bit
>     > cumbersome compared to the simplicity of using salience. This
>     way we get
>     > the simplicity of using salience, without the downfalls of it
>     being a
>     > magic number.
>     >
>     > What do people think? Any ideas on how we can improve this? At build
>     > time it would have to report impossible to resolve relationships
>     and barf.
>     >
>     > Mark
>     > _______________________________________________
>     > rules-dev mailing list
>     > rules-dev at lists.jboss.org <mailto:rules-dev at lists.jboss.org>
>     > https://lists.jboss.org/mailman/listinfo/rules-dev
>     >
>     _______________________________________________
>     rules-dev mailing list
>     rules-dev at lists.jboss.org <mailto:rules-dev at lists.jboss.org>
>     https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
>
>
> -- 
>   Edson Tirelli
>   JBoss Drools Core Development
>   JBoss by Red Hat @ www.jboss.com <http://www.jboss.com>
>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20120214/82064fb1/attachment-0001.html 


More information about the rules-dev mailing list