I don't see how these two loops should result in different facts in WM unless there<br>are other rules besides the one you have shown.<br><br>Why do you expect more that one result from the first (!) version of <br>"recomm for slot 1"? Are there several recommendations with the same<br>
maximum recommValue?<br><br>rule "filter products with category and brand for slot 1" isn't optimal. The<br>patterns should be rearranged for earliest possible blocking of evaluation.<br><br>rule "filter products with category and brand for slot 1"<br>
salience 20<br>
activation-group "productfilter slot 1"<br>
when<br>
Translog($pid : itemID, $uid : userID)<br>
Product(pid == $pid, brand != "", $price : netUnitPrice, $brand : brand) <br> FilterCriteria(brands contains $brand)<br> ProductCategory(pid == $pid, $cid : cid, $root : root)<br>
FilterCriteria(categories_slot1 contains $root) // stop here if the root needs filtering<br> not Recommendation(pid == $pid, slot == 1, uid == $uid)<br>
Category(cid == $cid, $cname : cname) // just needed for the insert<br> then<br> insert(new Recommendation($pid, $price, $brand, $cname, $cid, (byte)1, $root, $uid));<br> end<br>
<br><br>Regarding your rule "exclude products", it should probably be run before you insert any<br>Translog facts, with a separate fireAllRules() call. Then you don't need salience.<br><br>Or you can include the conditions in the Product pattern of<br>
rule "filter products with category and brand for slot 1"<br><br>-W<br><br><br><div class="gmail_quote">On 3 December 2012 09:59, raffi <span dir="ltr"><<a href="mailto:christian.koehler@s2008.tu-chemnitz.de" target="_blank">christian.koehler@s2008.tu-chemnitz.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi.<br>
<br>
I localized the problem. The following lines lead to the described behavior:<br>
<br>
/for (Translog tr : translog) {<br>
if (tr.getTransType() == 1 && !(tr.getUserID().compareTo("null") == 0)) {<br>
FactHandle tr_insert = ksession.insert(tr);<br>
ksession.fireAllRules();<br>
ksession.retract(tr_insert);<br>
}<br>
}/<br>
<br>
If I run the program with the changed lines<br>
/for (Translog tr : translog) {<br>
if (tr.getTransType() == 1 && !(tr.getUserID().compareTo("null") == 0)) {<br>
ksession.insert(tr);<br>
}<br>
}<br>
ksession.fireAllRules();/<br>
<br>
it doesn't work as I expect it. I didn't change the according rule<br>
/rule "filter products with category and brand for slot 1"<br>
salience 20<br>
activation-group "productfilter slot 1"<br>
when<br>
Translog($pid : itemID, $uid : userID)<br>
Product(pid == $pid, brand != "", $price : netUnitPrice,<br>
$brand : brand)<br>
ProductCategory(pid == $pid, $cid : cid, $root : root)<br>
Category(cid == $cid, $cname : cname)<br>
FilterCriteria(categories_slot1 contains $root)<br>
FilterCriteria(brands contains $brand)<br>
not Recommendation(pid == $pid, slot == 1, uid == $uid)<br>
then<br>
insert(new Recommendation($pid, $price, $brand, $cname, $cid, (byte)1,<br>
$root, $uid));<br>
end/<br>
<br>
In the end I show all Recommendation-facts in the console using a query.<br>
There should be at least 4, grouped by uid (userid). But with the corrected<br>
lines I only get one Recommendation-fact.<br>
/query "recomm for slot 1"<br>
$recomm_max : Recommendation(slot == 1, $recomm_value : recommValue, $uid :<br>
uid)<br>
not Recommendation(slot == 1, recommValue > $recomm_value, uid == $uid)<br>
end/<br>
<br>
The same applies for the query, without grouping by uid:<br>
/query "recomm for slot 1"<br>
$recomm_max : Recommendation(slot == 1)<br>
end/<br>
<br>
I chose the first (wrong) solution, with retracting the Translog-facts<br>
directly after firing, because it is transaction data. For my test there are<br>
only a few lines, but in the productive scenario there are at least 100.000<br>
records to insert.<br>
<br>
Regards...<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Different-results-with-same-fact-base-tp4021000p4021056.html" target="_blank">http://drools.46999.n3.nabble.com/Different-results-with-same-fact-base-tp4021000p4021056.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>