[rules-users] Using Decision Tables as Lookup Tables

Wolfgang Laun wolfgang.laun at gmail.com
Tue Apr 10 12:01:33 EDT 2012


Be advised that the approach you are intending has a dangerous "blind spot" you
should guard against. What if Calculate Value doesn't provide a match
for a company/region combination? You'll need an additional rule
detecting the missing ones.

A lookup table F( x, y ) can also be implemented by inserting facts of
type F, and this can be
done by a single "rule" firing with high priority, with a RHS
containing all required inserts.

-W

2012/4/10 Michael Anstis <michael.anstis at gmail.com>:
> Hmmm... the only way I can see this is possible (i.e. with the use of
> accumulate) is to use transient facts:-
>
> This can be set-up with a decision table quite easily (and ValuedRegion can
> be a declarative type that extends Region adding the "value" field)
>
> rule "setup ValuedRegions - using a decision table"
>     when
>         $Region( $score : score )
>     then
>         insertLogical( new ValuedRegion( $score, [a value] ) );
> end
>
> Your rule
>
> rule "Calculate Value"
>    when
>        $c : Company()
>        $r : Region()
>        $val : Double() from accumulate (ValuedRegion($score : score, $value
> : value ) , sum($score * $value))
>
>    then
>        // Do Something
> end
>
> On 10 April 2012 14:51, Davout <davout1805 at gmail.com> wrote:
>>
>> Hello,
>>
>> I'm trying to figure out how I can use a Decision Table as a lookup table.
>> I
>> did come across
>> http://drools.46999.n3.nabble.com/Rules-with-Lookup-Tables-td56996.html
>> however, it asking about using a database.
>>
>> Typical Senario:
>> Where [value from lookup table] is the value retrieved from the Decision
>> Table. The reason I'm looking at a Decision Table rather than using a
>> database is because the number of conditions needs to be changeable by end
>> users.
>>
>> rule "Calculate Value"
>>    when
>>        $c : Company()
>>        $r : Region()
>>        $val : Double()
>>            from accumulate (Region($score : score) , sum($score * [value
>> from lookup table]))
>>    then
>>        // Do Something
>> end
>>
>> Thanks.
>>
>> --
>> View this message in context:
>> http://drools.46999.n3.nabble.com/Using-Decision-Tables-as-Lookup-Tables-tp3899689p3899689.html
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> _______________________________________________
> 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