[rules-users] drools arithmetics without eval()

fx242 drools at fx242.com
Tue Mar 13 15:12:21 EDT 2012


I have a question regarding eval() use. My rulebase is around ~3k rules, most
of them are auto-generated by templates, and they end up looking like this:

rule "CONFIG_114"
    salience 0
when
    client: Client()
    contextProd: PortfolioProduct(prodAdded == true, productId ==
"PROFESSIONAL")
    Number(qty_00001: intValue) from accumulate(pp:
PortfolioProduct(productId in ("BOX_001"), prodAdded == true), count(pp))
    Number(qty_00002: intValue) from accumulate(pp:
PortfolioProduct(productId in ("BOX_002"), prodAdded == true), count(pp))
    Number(qty_00003: intValue) from accumulate(pp:
PortfolioProduct(productId in ("BOX_003"), prodAdded == true), count(pp))
    Number(qty_00004: intValue) from accumulate(pp:
PortfolioProduct(productId in ("BOX_004"), prodAdded == true), count(pp))
    Number(qty_00005: intValue) from accumulate(pp:
PortfolioProduct(productId in ("BOX_005"), prodAdded == true), count(pp))
    eval(qty_00001 == 1)
    not(eval(qty_00002 >= (qty_00003 + qty_00004 + qty_00005)))
then
    balance(kcontext, contextProd, qty_00002, ">=", (qty_00003 + qty_00004 +
qty_00005));
end

These rules have all one or two evals in the end, comparing product
quantities that are present in the Working Memory.
My question is: Is there any better way to write this kind of rules without
resorting to eval()?
I'm currently getting hit (in performance terms) by over-using these, so I
wonder if there is a  better way to do this.
Thanks!

Tiago Lopes




--
View this message in context: http://drools.46999.n3.nabble.com/drools-arithmetics-without-eval-tp3823232p3823232.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list