<div dir="ltr"><div>Thanks for you quick answer.</div><div><br></div>Not yet,<div><br></div><div>For that I will need to switch to fact insertion instead of Java Set.</div><div>Do you think to will make a difference in the way the RETE Tree will be built ?</div>

<div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-20 20:27 GMT+01:00 Mark Proctor <span dir="ltr">&lt;<a href="mailto:mproctor@codehaus.org" target="_blank">mproctor@codehaus.org</a>&gt;</span>:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Did you try using the engine in equality mode? It will only ever allow one &ldquo;equal&rdquo; object to be inserted, others are just ignored.<br>


<span class="HOEnZb"><font color="#888888"><br>
Mark<br>
</font></span><div class="HOEnZb"><div class="h5">On 20 Mar 2014, at 18:54, Raphael &lt;<a href="mailto:raphael.jolivet@gmail.com">raphael.jolivet@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Hi,<br>
&gt;<br>
&gt; In our project, we use Drools to compute forbidden allocations as input for<br>
&gt; an allocation problem &nbsp;(for which we do not use Drools BTW).<br>
&gt;<br>
&gt; The constraint of the problem (forbidden operation for given resources) are<br>
&gt; expressed as drools rules.<br>
&gt;<br>
&gt; We have about<br>
&gt; -200 resources<br>
&gt; -700 operations<br>
&gt;<br>
&gt; Those are the Drools facts.<br>
&gt; We have about 200 Drools rules describing the forbidden allocations<br>
&gt;<br>
&gt; The problem here is that many rules produce duplicates forbids.<br>
&gt; For instance :<br>
&gt; Rule 1 may forbid Op1 on Res1 &amp; Res3<br>
&gt; Rule 2 may forbid Op1 on Res2 &amp; res3<br>
&gt;<br>
&gt; Currently the RHS of rules just insert forbids into a pure Java Set (no fact<br>
&gt; insertion).<br>
&gt; The Set takes care of avoiding duplicates, but still, we feel we could help<br>
&gt; Drools by giving him a hint that<br>
&gt; all rules are actually producing pairs of &lt;Resource, Allocation&gt; and that he<br>
&gt; should not try to produce them more than once.<br>
&gt;<br>
&gt; Currently the structure of each rule looks like that :<br>
&gt;<br>
&gt; when<br>
&gt; $resource : Resource(&lt;someconditions&gt;)<br>
&gt; $operation : Operation(&lt;someconditions&gt;)<br>
&gt; then<br>
&gt; &nbsp;globalSet.add(Pair&lt;resrouce, operation&gt;)<br>
&gt; end<br>
&gt;<br>
&gt; With the size of the problem, we often end up with outOfMem/ GC limit.<br>
&gt; When analyzing memory dump, we see about<br>
&gt; 300.000 drools left tuple object.<br>
&gt;<br>
&gt; I am not sure if we could help drools to reduce the Rete tree here.<br>
&gt; I mean, the allocation matrix is already : 200*700 = 140.000 cells.<br>
&gt; Drools only uses 2 nodes for each possible forbids, which seems already well<br>
&gt; optimized.<br>
&gt;<br>
&gt; We had several idea to improve that though, but we are not enough expert in<br>
&gt; the internal of the RETE algorithm to decide if that&#39;s a good way to go :<br>
&gt;<br>
&gt; 1) Insert forbids as facts in the RHS and check they are not already there<br>
&gt; in the LHS :<br>
&gt; when<br>
&gt; $resource : Resource(&lt;someconditions&gt;)<br>
&gt; $operation : Operation(&lt;someconditions&gt;)<br>
&gt; not Forbid(res=$resource, op=$operation)<br>
&gt; then<br>
&gt; &nbsp;insert(Forbid($resource, $operation))<br>
&gt; end<br>
&gt;<br>
&gt; 2) Merge all rules in one big rule with a single RHS<br>
&gt; Is it possible to have something like :<br>
&gt; when<br>
&gt; // Rule 1<br>
&gt; ($resource : Resource(&lt;someconditions&gt;)<br>
&gt; $operation : Operation(&lt;someconditions&gt;))<br>
&gt; &nbsp;or<br>
&gt; // Rule 2<br>
&gt; ($resource : Resource(&lt;someconditions&gt;)<br>
&gt; $operation : Operation(&lt;someconditions&gt;))<br>
&gt; // Etc ...<br>
&gt; then<br>
&gt; &nbsp;globalSet.add(Pair&lt;resrouce, operation&gt;)<br>
&gt; end<br>
&gt;<br>
&gt; 3) Define a common RHS somewhere and tell Drools all rules use this one.<br>
&gt; Is there a possibility in Drools to define reusable RHS ? Would it help ?<br>
&gt;<br>
&gt; 4) Any other idea ?<br>
&gt;<br>
&gt;<br>
&gt; Thanks in advance for your help.<br>
&gt; Brgds,<br>
&gt;<br>
&gt; Raphael Jolivet<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; View this message in context: <a href="http://drools.46999.n3.nabble.com/Needs-advice-to-help-Drools-on-a-big-problem-and-avoid-GC-overhead-tp4028838.html" target="_blank">http://drools.46999.n3.nabble.com/Needs-advice-to-help-Drools-on-a-big-problem-and-avoid-GC-overhead-tp4028838.html</a><br>


&gt; Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<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>
</div></div></blockquote></div><br></div>