Hi Alessandro, just saw your e-mail and answered to you, but basically no-loop will not work for cases like this.
    Either specify your constraints in a way they prevent the loop or use lock-on-active.

rule "Nota final das questoes"
   when
       $qr : QuestionarioResposta( $nf : notaFinal )
       $result : Number( this != $nf )
                     from accumulate( QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)
                                          from $qr.questoesResposta,
                                          sum( $nota * (Double)$peso ) )                then
       modify( $qr ) {
              setNotaFinal($result)
       }
end

    Hope it helps.
        Edson
 

2008/5/5 Alessandro Lazarotti <alessandro@siq.com.br>:
It's a bug?

Alessandro Lazarotti escreveu:

Sorry, my code is ugly in last email...
This is more clean:

rule "The Rule"
  no-loop true
  when

      questionarioResposta : QuestionarioResposta()

       $resultFinal : Number() from accumulate(QuestaoResposta($peso:questao.questaoPeso.peso)
                                         from questionarioResposta.getQuestoesResposta(),
                                         sum( $peso ))
  then
      System.out.println($resultFinal);
      update( questionarioResposta );
end

This is a recursive and no-loop is ignored.
Who knows why this?

Thanks









Alessandro Lazarotti escreveu:
Hi
When I use accumulate and update, no-loop is ignored and the rule is
recursive.
Why?

The Rule:

rule "Nota final das questoes"
   no-loop true
   when







       questionarioResposta : QuestionarioResposta()
       $result : Number() from
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)                                           from questionarioResposta.getQuestoesResposta(),                                           sum($nota * (Double)$peso))
                                                   $resultFinal : Number() from
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)                                           from questionarioResposta.getQuestoesResposta(),                                           sum( $peso ))                                                                then
       System.out.println($result.doubleValue() / $resultFinal.doubleValue());         questionarioResposta.setNotaFinal($result.doubleValue() /
$resultFinal.doubleValue());
       update( questionarioResposta );
end

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com