Re: [rules-users] Adding eval on rule cause it to run in infinite loop
Hi, Use lock-on-active true in when condition, This will resolve this issue Thanks Ganesh Neelekani -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4030007.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
Davide is correct, for our analysis to work, the constraint must not be inside an eval, and any constraint that does not start with a field name is internally rewritten as an eval. Mark On 11 Jun 2014, at 18:48, Davide Sottara dso...@gmail.com wrote: I think I know what is happening here. I assume your supportFT class is @propertyReactive. (btw, you should follow bean conventions and capitalize class names) Looking at Rule 1, you don't set the value directly, but you do it through a modify. Your rule 2, which checks for the value, uses the function containsAny rather than the field direclty as in value IN (..). At the moment, the engine has no way to realize that the function involves the field value - I'm not even sure it is possible in general - Property reactivity will ignore the update since, from its perspective, none of the fields relevant to the rule has been affected, hence rule 2 will not hit. If you use eval in the constraint, property reactivity is disabled, so the rule WILL fire the first time, but now you are vulnerable to infinite loops, as if you did not have propertyreactive. You may have to use the @watch() annotation explicitly to control which modifies will cause reevaluations and which ones won't (see the manual for this) Adding eval everywhere is not a good idea. Best, Davide On 06/11/2014 01:53 PM, brachi wrote: example of rule that doesn't work without eval: /*rule 1 salience -1 agenda-group agenda1 when $conclusion: supportFT() then if($conclusion.getValue()==null){ modify($conclusion) { setValue(new ArrayList())}; } $conclusion.getValue().add(supportedValue); modify($conclusion) { setValue($conclusion.getValue()) }; end rule 2 salience -2 agenda-group agenda2 when supportFT(Operators.containsAny(value,new String[]{supportedValue,otherValue})) $conclusion: ConclusionFt() then modify($conclusion){setValue(success)}; end*/ rule 2 doesn't hit, works only with eval in rule 2. in this example I can add eval, because the Fact Types model is different, so the rule doesn't reevaluated. because I had this case, I decided to add eval for all constraints, but unfortunately I had an infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029984.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ 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
[rules-users] Adding eval on rule cause it to run in infinite loop
for this Drools Fact Type: /* declare DvFacts0 @propertyReactive IsNUMERIC: Double condIsNUMERIC: Double end*/ I have this rule: /*rule 1 salience -1 agenda-group agenda1 when $condIsNUMERIC: DvFacts0(eval(condIsNUMERIC == null ) ) $conclusion: DvFacts0( ) then modify($conclusion){setIsNUMERIC(1.0)}; end*/ the rule hit just one time without the eval clause, adding the eval cause this rule to run in infinite loop. have an idea? put attention that I add @propertyReactive on the DVFacts0 to avoid this. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
Add no-loop true on the line after the rule directive. rule 1 no-loop true Regards Chiddu On Wed, Jun 11, 2014 at 2:05 PM, brachi brach...@sapiens.com wrote: for this Drools Fact Type: /* declare DvFacts0 @propertyReactive IsNUMERIC: Double condIsNUMERIC: Double end*/ I have this rule: /*rule 1 salience -1 agenda-group agenda1 when $condIsNUMERIC: DvFacts0(eval(condIsNUMERIC == null ) ) $conclusion: DvFacts0( ) then modify($conclusion){setIsNUMERIC(1.0)}; end*/ the rule hit just one time without the eval clause, adding the eval cause this rule to run in infinite loop. have an idea? put attention that I add @propertyReactive on the DVFacts0 to avoid this. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ 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
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
Wrapping a constraint into eval (for which there's absolutely no need) hides the visibility of the attribute condIsNUMERIC to the observer that would avoid the reactivation. -W On 11/06/2014, brachi brach...@sapiens.com wrote: for this Drools Fact Type: /* declare DvFacts0 @propertyReactive IsNUMERIC: Double condIsNUMERIC: Double end*/ I have this rule: /*rule 1 salience -1 agenda-group agenda1 when $condIsNUMERIC: DvFacts0(eval(condIsNUMERIC == null ) ) $conclusion: DvFacts0( ) then modify($conclusion){setIsNUMERIC(1.0)}; end*/ the rule hit just one time without the eval clause, adding the eval cause this rule to run in infinite loop. have an idea? put attention that I add @propertyReactive on the DVFacts0 to avoid this. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ 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
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
so, will no-loop help? is eval also override this attribute? -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029971.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
The whole point of @propertyReactive is to avoid no-loop where possible. What Wolfgang was trying to say is that there is no need to use the eval: just write DvFacts0( condIsNUMERIC == null ) and the @propertyReactivity will work Davide On 06/11/2014 10:40 AM, brachi wrote: so, will no-loop help? is eval also override this attribute? -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029971.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ 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
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
I need the eval. I have some rules that doesn't hit correctly, just if I put eval around the condition. but eval makes the rules to run in an infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029979.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
Could you please show the conditions for which you need the eval? And which version are you using? As far as I know, eval is rewritten and removed internally in latest versions, so there shouldn't be a difference. On 06/11/2014 12:34 PM, brachi wrote: I need the eval. I have some rules that doesn't hit correctly, just if I put eval around the condition. but eval makes the rules to run in an infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029979.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ 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
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
What is the issue in using the no-loop directive? Regards Chiddu On Wed, Jun 11, 2014 at 5:09 PM, Davide Sottara dso...@gmail.com wrote: Could you please show the conditions for which you need the eval? And which version are you using? As far as I know, eval is rewritten and removed internally in latest versions, so there shouldn't be a difference. On 06/11/2014 12:34 PM, brachi wrote: I need the eval. I have some rules that doesn't hit correctly, just if I put eval around the condition. but eval makes the rules to run in an infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029979.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ 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
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
On 11/06/2014, Chidambaran Subramanian chi...@gmail.com wrote: What is the issue in using the no-loop directive? Expert manual, Subsection Fine grained property change listeners -W Regards Chiddu On Wed, Jun 11, 2014 at 5:09 PM, Davide Sottara dso...@gmail.com wrote: Could you please show the conditions for which you need the eval? And which version are you using? As far as I know, eval is rewritten and removed internally in latest versions, so there shouldn't be a difference. On 06/11/2014 12:34 PM, brachi wrote: I need the eval. I have some rules that doesn't hit correctly, just if I put eval around the condition. but eval makes the rules to run in an infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029979.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ 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
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
example of rule that doesn't work without eval: /*rule 1 salience -1 agenda-group agenda1 when $conclusion: supportFT() then if($conclusion.getValue()==null){ modify($conclusion) { setValue(new ArrayList())}; } $conclusion.getValue().add(supportedValue); modify($conclusion) { setValue($conclusion.getValue()) }; end rule 2 salience -2 agenda-group agenda2 when supportFT(Operators.containsAny(value,new String[]{supportedValue,otherValue})) $conclusion: ConclusionFt() then modify($conclusion){setValue(success)}; end*/ rule 2 doesn't hit, works only with eval in rule 2. in this example I can add eval, because the Fact Types model is different, so the rule doesn't reevaluated. because I had this case, I decided to add eval for all constraints, but unfortunately I had an infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029984.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
example of rule that doesn't work without eval: /*rule 1 salience -1 agenda-group agenda1 when $conclusion: supportFT() then if($conclusion.getValue()==null){ modify($conclusion) { setValue(new ArrayList())}; } $conclusion.getValue().add(supportedValue); modify($conclusion) { setValue($conclusion.getValue()) }; end rule 2 salience -2 agenda-group agenda2 when supportFT(Operators.containsAny(value,new String[]{supportedValue,otherValue})) $conclusion: ConclusionFt() then modify($conclusion){setValue(success)}; end*/ rule 2 doesn't hit, works only with eval in rule 2. in this example I can add eval, because the Fact Types model is different, so the rule doesn't reevaluated. because I had this case, I decided to add eval for all constraints, but unfortunately I had an infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029985.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
On 11/06/2014, brachi brach...@sapiens.com wrote: example of rule that doesn't work without eval: /*rule 1 salience -1 agenda-group agenda1 when $conclusion: supportFT() Where's the eval? then if($conclusion.getValue()==null){ modify($conclusion) { setValue(new ArrayList())}; } $conclusion.getValue().add(supportedValue); modify($conclusion) { setValue($conclusion.getValue()) }; You might use a simple update() here. end rule 2 salience -2 agenda-group agenda2 when supportFT(Operators.containsAny(value,new String[]{supportedValue,otherValue})) This can be written using the clearer and cleaner syntax supportFT( value in (supportedValue,otherValue) ) $conclusion: ConclusionFt() Moreover, this should contain the constraint $conclusion: ConclusionFt( value != success ) then modify($conclusion){setValue(success)}; Here, ConclusionFt's attribute value is a simple String, but in that other rule it is set to an ArrayList. -W end*/ rule 2 doesn't hit, works only with eval in rule 2. in this example I can add eval, because the Fact Types model is different, so the rule doesn't reevaluated. because I had this case, I decided to add eval for all constraints, but unfortunately I had an infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029984.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ 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
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
This example describes a case using function in the constraint (Operators.containsAny) and pass a Fact Type that was changed in a previous rule. you are right that I can use the drools operator IN (...), but I wanted to use function in the example, because that is the case that rules don't hit. I have a lot of functions in my rules, also for custom operators and also for complex formulas, and I need to cause this rules to hit, just eval helped: /*supportFT( eval(Operators.containsAny(value,new String[]{supportedValue,otherValue})))*/ adding / *$conclusion: ConclusionFt( value != success ) */ to the rule can avoid the infinite loop... but this solution won't work for all my rules. for example: rule that count something: /* modify($conclusion) { setValue($conclusion.getValue()+1)}*/. to summarize, I have 2 problems: 1. rule doesn't hit. 2. eval solve problem 1, but cause infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029987.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Adding eval on rule cause it to run in infinite loop
I think I know what is happening here. I assume your supportFT class is @propertyReactive. (btw, you should follow bean conventions and capitalize class names) Looking at Rule 1, you don't set the value directly, but you do it through a modify. Your rule 2, which checks for the value, uses the function containsAny rather than the field direclty as in value IN (..). At the moment, the engine has no way to realize that the function involves the field value - I'm not even sure it is possible in general - Property reactivity will ignore the update since, from its perspective, none of the fields relevant to the rule has been affected, hence rule 2 will not hit. If you use eval in the constraint, property reactivity is disabled, so the rule WILL fire the first time, but now you are vulnerable to infinite loops, as if you did not have propertyreactive. You may have to use the @watch() annotation explicitly to control which modifies will cause reevaluations and which ones won't (see the manual for this) Adding eval everywhere is not a good idea. Best, Davide On 06/11/2014 01:53 PM, brachi wrote: example of rule that doesn't work without eval: /*rule 1 salience -1 agenda-group agenda1 when $conclusion: supportFT() then if($conclusion.getValue()==null){ modify($conclusion) { setValue(new ArrayList())}; } $conclusion.getValue().add(supportedValue); modify($conclusion) { setValue($conclusion.getValue()) }; end rule 2 salience -2 agenda-group agenda2 when supportFT(Operators.containsAny(value,new String[]{supportedValue,otherValue})) $conclusion: ConclusionFt() then modify($conclusion){setValue(success)}; end*/ rule 2 doesn't hit, works only with eval in rule 2. in this example I can add eval, because the Fact Types model is different, so the rule doesn't reevaluated. because I had this case, I decided to add eval for all constraints, but unfortunately I had an infinite loop. -- View this message in context: http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029984.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ 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