Pregunta

I have a rule that checks if there are 5 facts that have the same value (5 facts with the same value in the last 7 days). Now I'm working with 40 facts, so the rule checks this issue over the 40 facts. With the top 20 no problem, but every time takes longer. The 21 is not execute because Java sends an OutOfMemory exception.

This is my rule:

rule "MUL_04"
no-loop true
when

    r_A:Fact(viewed==false)
    r_B:Fact(viewed==true, INT_IP==r_A.INT_IP, Tools.check(SOL_FEC, r_A.SOL_FEC)<=7)
    r_C:Fact(viewed==true, INT_IP==r_A.INT_IP, Tools.check(SOL_FEC, r_A.SOL_FEC)<=7, r_B!=r_C)
    r_D:Fact(viewed==true, INT_IP==r_A.INT_IP, Tools.check(SOL_FEC, r_A.SOL_FEC)<=7, r_C!=r_D, r_B!=r_D)
    r_E:Fact(viewed==true, INT_IP==r_A.INT_IP, Tools.check(SOL_FEC, r_A.SOL_FEC)<=7, r_B!=r_E, r_C!=r_E, r_D!=r_E)
    r_F:Fact(viewed==true, INT_IP==r_A.INT_IP, Tools.check(SOL_FEC, r_A.SOL_FEC)<=7, r_B!=r_F, r_C!=r_F, r_D!=r_F, r_E!=r_F)


then
        modify (r_A) {
        setViewed(true),
        setEST_EST_FRA(1),
        setEST_PRO_EST(1)
    }
end

Anyone know how to fix the Java memory problem or how to optimize this rule?

Thank in advance

UPDATE::

I'm testing with this query:

   query multipleRequests(Fact r_A, Integer exits)
    $exits := Number(intValue>=5) from accumulate(
         r_B:Fact(viewed==true,INT_IP == r_A.INT_IP,Tools.check(SOL_FEC, r_A.SOL_FEC) <=7),
         count(r_B)
         )
end

And this rule:

rule "MUL_04_WithQuery"
no-loop true
when
    r_A:Fact(viewed==false)
    $numbers : multipleRequests(r_A;)    
then
        modify (r_A) {
            setViewed(true),
            setEST_EST_FRA(1),
            setEST_PRO_EST(1)
        }
end

But I can not get the expected performance. Also, when I try with more than 100 facts, I get, too, a Java heap problem.

I don't understand. Is it the correct query for my problem???

¿Fue útil?

Solución

You are causing a combinatorial explosion: the 40 facts will be matched in all possible combinations to your five clauses. A good approach would be to count the number of facts which match your criteria. This is accomplished by using a rule as a query (described, among other places, in this forum thread).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top