Re: [rules-users] rule fires several times

2011-10-31 Thread arrehman
Makes sense, pretty good explanation.

Is there a way to turn this behaviour off? I don't want the rule engine to
re-calculate the rules when I update a fact inside the rule engine. Is that
possible? The reason I ask is that in my application it makes sense based on
the way I have structured the rules and invoking drools.

Thanks,
Abdul

--
View this message in context: 
http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3468125.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] rule fires several times

2011-10-31 Thread Wolfgang Laun
On 31 October 2011 16:41, arrehman arrehma...@yahoo.com wrote:

 Makes sense, pretty good explanation.

 Is there a way to turn this behaviour off? I don't want the rule engine to
 re-calculate the rules when I update a fact inside the rule engine. Is that
 possible?


Just don't make the engine aware of changes to your fact objects, i.e.,
omit modify/update.
-W


 The reason I ask is that in my application it makes sense based on
 the way I have structured the rules and invoking drools.


 Thanks,
 Abdul

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3468125.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] rule fires several times

2011-10-31 Thread arrehman
I have /update()/ on consequence/action part of rules, which I can't void. I
guess there is no way and rule engine is doing the right thing then.

--
View this message in context: 
http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3468183.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] rule fires several times

2011-10-31 Thread Wolfgang Laun
On 31 October 2011 17:06, arrehman arrehma...@yahoo.com wrote:

 I have /update()/ on consequence/action part of rules, which I can't void.


It seems to me that you are contradicting yourself. If you can't remove
update() then this means that you do need the changes to facts being
made known to the rules engine so that it can fire rules (again), due to
changes made. This is the only purpose of an update() call; changes to
the Java object are made by setter calls, as always.

-W


 I
 guess there is no way and rule engine is doing the right thing then.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3468183.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] rule fires several times

2011-10-31 Thread arrehman
You are right, I need to re-think what I am doing. Perhaps there is no need
for me to do the update() calls. I will post back. Thanks.

--
View this message in context: 
http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3468776.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] rule fires several times

2011-10-30 Thread elsdestickere
Hi,

The Expert documentation says  a rule may fire once or several times, but
I don't understand why a rule sould fire several times if the objects state
does not change?

I have an example of a Customer object inserted in the Working Memory, with
2 rules that should fire, but the last rule fires twice.
Can someone explain?

rule isAdult
when
k : Customer( age(date)=18, adult==false );
then
modify( k ) { setAdult(true)  };
System.out.println( Drools +drools.getRule().getName()+: +
k.getAdult() );
end
rule WM 
when
   k : Customer(  ) ;
then
System.out.println( Drools +drools.getRule().getName()+: 
+k.getName());
end

...
Customer bert = new Customer ();
bert.setName(Bert);
bert.setDate(30);
ksession.insert(bert);
ksession.fireAllRules();
...
Output:
Drools WM: Bert 
Drools isAdult: true
Drools WM: Bert 

Br,
Els Destickere

--
View this message in context: 
http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466250.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] rule fires several times

2011-10-30 Thread Michael Anstis
Your first rule matches against the Customer, as does the second. The
modify in the first rule causes both rules to re-evaluate. The first does
not match but the second does.

IIRC no-loop or lock-on-active can be uses to avoid this, but I'd suggest
you double check the docs.

sent on the move

On 30 Oct 2011 19:31, elsdestickere elsdestick...@yahoo.com wrote:

 Hi,

 The Expert documentation says  a rule may fire once or several times, but
 I don't understand why a rule sould fire several times if the objects state
 does not change?

 I have an example of a Customer object inserted in the Working Memory, with
 2 rules that should fire, but the last rule fires twice.
 Can someone explain?

 rule isAdult
when
k : Customer( age(date)=18, adult==false );
then
modify( k ) { setAdult(true)  };
System.out.println( Drools +drools.getRule().getName()+: +
 k.getAdult() );
 end
 rule WM
when
   k : Customer(  ) ;
then
System.out.println( Drools +drools.getRule().getName()+: 
 +k.getName());
 end

 ...
 Customer bert = new Customer ();
 bert.setName(Bert);
 bert.setDate(30);
 ksession.insert(bert);
 ksession.fireAllRules();
 ...
 Output:
 Drools WM: Bert
 Drools isAdult: true
 Drools WM: Bert

 Br,
 Els Destickere

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466250.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] rule fires several times

2011-10-30 Thread arrehman
I have the same question. I see this happening, and I don't know why. 

--
View this message in context: 
http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466263.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] rule fires several times

2011-10-30 Thread elsdestickere
I see, the MODIFY in the LHS triggers the rule WM again. 
thanks !
Els

--
View this message in context: 
http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466287.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] rule fires several times

2011-10-30 Thread Wolfgang Laun
A rule will fire once fore each combination of matching facts, and then,
again and again and again, whenever one of those facts is changed.

In your case: once for reason #1 and once for reason #2.

-W

On 30 October 2011 20:30, elsdestickere elsdestick...@yahoo.com wrote:

 Hi,

 The Expert documentation says  a rule may fire once or several times, but
 I don't understand why a rule sould fire several times if the objects state
 does not change?

 I have an example of a Customer object inserted in the Working Memory, with
 2 rules that should fire, but the last rule fires twice.
 Can someone explain?

 rule isAdult
when
k : Customer( age(date)=18, adult==false );
then
modify( k ) { setAdult(true)  };
System.out.println( Drools +drools.getRule().getName()+: +
 k.getAdult() );
 end
 rule WM
when
   k : Customer(  ) ;
then
System.out.println( Drools +drools.getRule().getName()+: 
 +k.getName());
 end

 ...
 Customer bert = new Customer ();
 bert.setName(Bert);
 bert.setDate(30);
 ksession.insert(bert);
 ksession.fireAllRules();
 ...
 Output:
 Drools WM: Bert
 Drools isAdult: true
 Drools WM: Bert

 Br,
 Els Destickere

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466250.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