[rules-users] Infinte Loop problem

Darko IVANCAN ivancan at gmx.de
Sun Dec 9 08:02:47 EST 2007


Hi,

Looks to me you do not need an update here.
Rather try using a ruleflow:
1. increase desirability depending on various parameters (not
desirability, obviously)
2. apply the rules, that use desirability
3. done / retract (if you like)

hope this helps,
Darko Ivancan

On 05/12/2007 16:08, benjimcc wrote:
> Im sure people have seen this before ive searched high and low for an answer
> but no luck, fairly new to using drools so any advice would be much
> appreciated.  Here is a sample of my rules:
>
> rule "Gender Desirability"
> 	salience 400
> 	no-loop true
> 	when
> 		$broker : Broker(brokerName=="bah")
> 		Proposer(gender == "F")
> 	then
> 		int desirability = $broker.getDesirability() + 10;
> 		$broker.setDesirability(desirability);	
> 		update($broker);
> 		System.out.println("Gender Hit");
> end
>
>
> rule "Age Desirability"
> 	salience 200
> 	no-loop true
> 	when
> 		$broker : Broker(brokerName=="bah")
> 		$proposer : Proposer($dob : dateOfBirth)
> 		$rulesrequest : RulesEngineRequest($inception : inceptionDate)
> 	
> eval(age_desirability_flex.isInRange($proposer.getAge($dob,$inception))==true)
> 	then
> 		int desirability = $broker.getDesirability() + 20;	
> 		$broker.setDesirability(desirability);
> 		update($broker);		
> 		System.out.println("Age Hit");	
> end
>
> rule "Check Desirability"
> 	salience 190
> 	when
> 		$broker : Broker($des : desirability,brokerName=="europa")
> 		eval($des < desirability_Index)
> 	then
> 		$broker.setInclude(false);
> 		retract($broker);
> end
>
>
>
> Ok basically all the 'when' bits work.  But what seems to happen is that
> when the update happens and the rules are evaled again and it ping pongs
> between the two rules as they both update the Broker object.  Resulting in
> the 'Check Desirability' never being hit and for debug spewing 'Gender Hit'
> 'Age Hit' in a infinite loop till te JVM runs out of memory and it crash and
> burns.
>
> Any help in this would be much appreciated.  If you need any more
> information let me know as well.
>
> Thanks
> Ben
>
> "The views opinions and judgments expressed in this message are solely those
> of the author.  The message contents have not been viewed or reviewed or
> approved by CDL"
>   



More information about the rules-users mailing list