<p dir="ltr">Hmm, sure it makes sense. The operations and resources are independent. I think I can safely split the problem into smaller ones. I will try this approach.</p>
<p dir="ltr">Thanks for the tip</p>
<div class="gmail_quote">Le 20 mars 2014 20:51, "Wolfgang Laun" <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I may fail to understand the fundamentals of this problem, but it seems<br>
to me that it doesn't have the dynamic requirements that would<br>
warrant a full "blow up" of all Resources and Operations at the same time.<br>
<br>
We have the 300 rules, and I'm assuming that the pattern is the one<br>
shown in OP's mail: a Resource subset times an Operation subset. So,<br>
if you insert just one Resource (or Operation) fact together with<br>
all Operation (or Resource) facts and fire all rules, you'll get all Forbids<br>
for the one Resource with all Operations (or vice versa). Then, you<br>
retract the singleton and insert the next one, fire all rules, and so on.<br>
<br>
-W<br>
<br>
<br>
On 20/03/2014, Raphael Jolivet <<a href="mailto:raphael.jolivet@gmail.com">raphael.jolivet@gmail.com</a>> wrote:<br>
> Thanks for you quick answer.<br>
><br>
> Not yet,<br>
><br>
> For that I will need to switch to fact insertion instead of Java Set.<br>
> Do you think to will make a difference in the way the RETE Tree will be<br>
> built ?<br>
><br>
><br>
><br>
><br>
> 2014-03-20 20:27 GMT+01:00 Mark Proctor <<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>>:<br>
><br>
>> Did you try using the engine in equality mode? It will only ever allow<br>
>> one<br>
>> "equal" object to be inserted, others are just ignored.<br>
>><br>
>> Mark<br>
>> On 20 Mar 2014, at 18:54, Raphael <<a href="mailto:raphael.jolivet@gmail.com">raphael.jolivet@gmail.com</a>> wrote:<br>
>><br>
>> > Hi,<br>
>> ><br>
>> > In our project, we use Drools to compute forbidden allocations as input<br>
>> for<br>
>> > an allocation problem (for which we do not use Drools BTW).<br>
>> ><br>
>> > The constraint of the problem (forbidden operation for given resources)<br>
>> are<br>
>> > expressed as drools rules.<br>
>> ><br>
>> > We have about<br>
>> > -200 resources<br>
>> > -700 operations<br>
>> ><br>
>> > Those are the Drools facts.<br>
>> > We have about 200 Drools rules describing the forbidden allocations<br>
>> ><br>
>> > The problem here is that many rules produce duplicates forbids.<br>
>> > For instance :<br>
>> > Rule 1 may forbid Op1 on Res1 & Res3<br>
>> > Rule 2 may forbid Op1 on Res2 & res3<br>
>> ><br>
>> > Currently the RHS of rules just insert forbids into a pure Java Set (no<br>
>> fact<br>
>> > insertion).<br>
>> > The Set takes care of avoiding duplicates, but still, we feel we could<br>
>> help<br>
>> > Drools by giving him a hint that<br>
>> > all rules are actually producing pairs of <Resource, Allocation> and<br>
>> that he<br>
>> > should not try to produce them more than once.<br>
>> ><br>
>> > Currently the structure of each rule looks like that :<br>
>> ><br>
>> > when<br>
>> > $resource : Resource(<someconditions>)<br>
>> > $operation : Operation(<someconditions>)<br>
>> > then<br>
>> > globalSet.add(Pair<resrouce, operation>)<br>
>> > end<br>
>> ><br>
>> > With the size of the problem, we often end up with outOfMem/ GC limit.<br>
>> > When analyzing memory dump, we see about<br>
>> > 300.000 drools left tuple object.<br>
>> ><br>
>> > I am not sure if we could help drools to reduce the Rete tree here.<br>
>> > I mean, the allocation matrix is already : 200*700 = 140.000 cells.<br>
>> > Drools only uses 2 nodes for each possible forbids, which seems already<br>
>> well<br>
>> > optimized.<br>
>> ><br>
>> > We had several idea to improve that though, but we are not enough<br>
>> > expert<br>
>> in<br>
>> > the internal of the RETE algorithm to decide if that's a good way to go<br>
>> > :<br>
>> ><br>
>> > 1) Insert forbids as facts in the RHS and check they are not already<br>
>> there<br>
>> > in the LHS :<br>
>> > when<br>
>> > $resource : Resource(<someconditions>)<br>
>> > $operation : Operation(<someconditions>)<br>
>> > not Forbid(res=$resource, op=$operation)<br>
>> > then<br>
>> > insert(Forbid($resource, $operation))<br>
>> > end<br>
>> ><br>
>> > 2) Merge all rules in one big rule with a single RHS<br>
>> > Is it possible to have something like :<br>
>> > when<br>
>> > // Rule 1<br>
>> > ($resource : Resource(<someconditions>)<br>
>> > $operation : Operation(<someconditions>))<br>
>> > or<br>
>> > // Rule 2<br>
>> > ($resource : Resource(<someconditions>)<br>
>> > $operation : Operation(<someconditions>))<br>
>> > // Etc ...<br>
>> > then<br>
>> > globalSet.add(Pair<resrouce, operation>)<br>
>> > end<br>
>> ><br>
>> > 3) Define a common RHS somewhere and tell Drools all rules use this<br>
>> > one.<br>
>> > Is there a possibility in Drools to define reusable RHS ? Would it help<br>
>> > ?<br>
>> ><br>
>> > 4) Any other idea ?<br>
>> ><br>
>> ><br>
>> > Thanks in advance for your help.<br>
>> > Brgds,<br>
>> ><br>
>> > Raphael Jolivet<br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > View this message in context:<br>
>> <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>
>> > 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>
>><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>
>><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>
</blockquote></div>