laune wrote
I don't see how these two loops should result in different facts
in WM
unless there
are other rules besides the one you have shown.
Yes, there are other rules. The complete result should be 4 recommendations
for every customer (uid) from the translogs. The recommended products are
for a newsletter. 4 products (4 slots) should be shown there, that is why I
have the /slot == 1/ statement. For simplicity I only showed the rules for
slot 1.
So in the end there are 4 slots, all with one recommendation for every
customer. My rules for slot 1, are the following (always two, because there
are products within a category and brand and also only within a category):
/rule "exclude products"
salience 25
when
$p : Product(netUnitPrice < 4.00)
or
$p : Product(onlineFlag == false)
then
retract($p);
end/
/rule "filter products with category and brand for slot 1"
salience 20
activation-group "productfilter slot 1"
when
Translog($pid : itemID, $uid : userID)
Product(pid == $pid, brand != "", $price : netUnitPrice,
$brand : brand)
ProductCategory(pid == $pid, $cid : cid, $root : root)
Category(cid == $cid, $cname : cname)
FilterCriteria(categories_slot1 contains $root)
FilterCriteria(brands contains $brand)
not Recommendation(pid == $pid, slot == 1, uid == $uid)
then
insert(new Recommendation($pid, $price, $brand, $cname, $cid, (byte)1,
$root, $uid));
end
rule "filter products only with category for slot 1"
salience 20
activation-group "productfilter slot 1"
when
Translog($pid : itemID, $uid : userID)
Product(pid == $pid, brand == "", $price : netUnitPrice)
ProductCategory(pid == $pid, $cid : cid, $root : root)
Category(cid == $cid, $cname : cname)
FilterCriteria(categories_slot1 contains $root)
not Recommendation(pid == $pid, slot == 1, uid == $uid)
then
insert(new Recommendation($pid, $price, "", $cname, $cid, (byte)1, $root,
$uid));
end/
/rule "calculate recomm value for slot 1 with category and brand"
salience 15
activation-group "calculate slot 1"
when
$recomm : Recommendation(recommValue == 0, slot == 1, brand != "",
$price : price, $recomm_value : recommValue,
$brand : brand, $root : root)
$f : FilterCriteria()
$cat_map : HashMap() from $f.getCategories_slot1()
$brand_map : HashMap() from $f.getBrands()
then
modify ($recomm) {
setRecommValue(((Double)$cat_map.get($root)).doubleValue()
+ ((Double)$brand_map.get($brand)).doubleValue()
+ $price)
};
end
rule "calculate recomm value for slot 1 only with category"
salience 15
activation-group "calculate slot 1"
when
$recomm : Recommendation(recommValue == 0, slot == 1, brand == "",
$price : price, $recomm_value : recommValue,
$root : root)
$f : FilterCriteria()
$cat_map : HashMap() from $f.getCategories_slot1()
then
modify ($recomm) {
setRecommValue(((Double)$cat_map.get($root)).doubleValue()
+ $price)
};
end/
laune wrote
Why do you expect more that one result from the first (!) version of
"recomm for slot 1"? Are there several recommendations with the same
maximum recommValue?
Yes that is possible, but with a different /$uid/. Because there is more
than one customer, coming from the Translog-facts.
laune wrote
rule "filter products with category and brand for slot 1"
isn't optimal.
The
patterns should be rearranged for earliest possible blocking of
evaluation.
OK. That makes sense to me. Does it have a positive impact on performance of
the engine?
To call fireAllRules before inserting Translog-facts makes also sense to me,
thanks for advice.
Regards...
--
View this message in context:
http://drools.46999.n3.nabble.com/Different-results-with-same-fact-base-t...
Sent from the Drools: User forum mailing list archive at
Nabble.com.