[rules-users] How many KnowledgeBases?

Pavel Tavoda pavel.tavoda at gmail.com
Fri Feb 19 17:11:00 EST 2010


I will show you our approach. We have rules in rule base like:
rule "start calculate"
when
   RULE TO START CALCULATION
than
   insert(new CalculateFee("firstFee,secondFee".split(",")))
end

rule "END calculate"
   salience -100
when
   RULE TO START CALCULATION
   $fee:CalculateFee()
than
   CALCULATE AND DO WHAT YOU WANT, YOU HAVE FEES IN $fee
end

Than we have excell sheet with columns:
$fee: CalculateFee(feeTypes contains
"$param");OTHERCODITIONS;$fee.addFee($param)
"firstFee";...;15%
"firstFee";...;20%

$fee: CalculateFee(feeTypes contains
"$param");OTHERCODITIONS;$fee.addAbsoluteFee($param)
"secondFee";....;5
"secondFee";....;15
"secondFee";....;25
"secondFee";....;35

In rules you specify which price table to apply when and what to do
with fees. In excel sheet you can specify price tables. For more
detail look to http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e5765

Hope this help

Pavel

2010/2/19 Laird Nelson <ljnelson at gmail.com>:
> Forgive me for what I suspect is an elementary question.  That said, I did
> not see it explained in newcomer-friendly language in the documentation, if
> at all.  And I'm a newcomer!
>
> I'm working on a system for--among other things--pricing things.  Drools
> Expert is a great fit for this.
>
> The system also has to do other things that have nothing to do with pricing
> (let's say shipping, to keep it simple).  There are places where Drools
> Expert is a great fit for this as well.
>
> In both cases, let's assume I might insert a given product into the engine,
> turn the crank, and collect my results.  But the kinds of results I'm
> looking for--and the kinds of calculations I would expect to be
> performed--are quite different in each case.
>
> So, let's assume that--naively speaking here--when I insert the product and
> {handwave handwave} I "know" I'm doing pricing work, then I only need
> pricing-related rules to fire (I don't need the, say,
> product-color-determining rules to fire, or the
> can-the-product-be-shipped-to-Abu-Dhabi rules to fire, or the
> how-many-people-liked-this-product rules to fire, etc.).
>
> And when I insert the product and {handwave handwave} I "know" I'm
> doing--whatever--shipping work, then I don't need the pricing rules to even
> be considered.
>
> I found this (http://n3.nabble.com/Grouping-rules-td55531.html#a55531) as
> perhaps one way of creating different sets of rules to be evaluated in
> different contexts.  This smelled very arcane to me for this purpose,
> but...? perhaps it's the way to go?
>
> Another is obviously to create n KnowledgeBases, each with its own set of
> rules, where n is the number of contexts or activities or types of
> activities that I'm performing.  Then I'd look up the (pre-created)
> KnowledgeBase appropriate for the particular calculation I need performed.
> That seems like solving the problem with a crowbar, a length of iron pipe
> and a blowtorch.  Ick.
>
> Is there an accepted/preferred way to handle this sort of thing?
> Agenda-groups seem...well, perhaps they'd work, but it seems awfully arcane
> for something that I was hoping would be a little more end-user friendly.
> Quoting the Expert manual:
>
>> When Should You Use A Rule Engine?
>> [...]
>> Domain experts often possess a wealth of knowledge about business rules
>> and processes. They typically are nontechnical, but can be very logical.
>> Rules can allow them to express the logic in their own terms. Of course,
>> they still have to think critically and be capable of logical thinking.
>
> My domain users would almost certainly not think in terms of agenda groups.
> Perhaps I could hide this in a DSL or something, but it seems to me there
> must be some facility built into Drools for separating collections of rules
> into channels, or groups, or partitions, or....  Is there?
>
> Best,
> Laird
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>




More information about the rules-users mailing list