Nico ROEDERER | 1 Mar 09:17 2011
Picon

[rules-dev] eval problem

Hi,

I've got an other problem with an eval function.
I will try to discribe the path to the error.

I've got a repository where some people can put rules with .drl extension.
My program is listing this repository and execute every rule in this repository.

At the begining, I've got a 'PatientDto' who have a property :
int nbFactRisque;
(with getters and setters)

Some rules increments this number.

In the last rule (the rules are executed in alphabetic mode) I'm testing this number like this :

rule "RisqueNormal"
    when
        $patient : PatientDto()
        eval( $patient.getNbFactRisque() == 0)
    then
        $patient.addDonnees( Constants.CLE_RISQUEPATIENT, Constants.RISQUE_NORMAL );
        System.out.println("RisqueNormal vérifié." + $patient.getNbFactRisque() + "Facteurs.");
end

Here's my problem :
The 'Then' traitement is always executed so the eval always think that $patient.getNbFactRisque() is equal to 0.
But the system.out.println() show me that $patient.getNbFactRisque()  = 2 !

Here's the output : "RisqueNormal vérifié.2Facteurs.".

Perhaps I did something wrong ? Can someone help me ?
Thank you.
_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
pchenna | 1 Mar 09:53 2011
Picon

[rules-dev] Activating the rule

I have a rule while calls doMenu to display options and modify data
accordingly.But why this rule is getting called only once even thought
"WHEN" condition is matching.Isn't it should be called every-time condition
matches?

rule "Check trans"
	dialect "java" 
	when
		exists(Account())
	    $account :Account()
	then
		doMenu($account,drools.getWorkingMemory());		

end

rule "Credit"
#some code here
end rule

rule "Debit"
#some code here
end rule

function void doMenu(Account account,WorkingMemory wm) {
	
	String option = "1";
	//while(!option.equalsIgnoreCase("3")){

	option = JOptionPane.showInputDialog("1.Debit \n" +
						"2.Credit \n" +
						"3. Exit");
	
	if(option.equalsIgnoreCase("1")){
	
		String amount  = JOptionPane.showInputDialog("Enter Amount to be
Debited");
		double amt = Double.parseDouble(amount);	
		Transaction t = new Transaction ( account, amt, Transaction.DEBIT);
		wm.insert(t);
		
		
	}else if(option.equalsIgnoreCase("2")){
	
		String amount  = JOptionPane.showInputDialog("Enter Amount to be
Credited");
		double amt = Double.parseDouble(amount);	
		Transaction t = new Transaction ( account, amt, Transaction.CREDIT);
		wm.insert(t);
	}
	
//}			
}

Sorry if this question is very naive,tried searching in forums and couldn't
find anything helpful.

--

-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Activating-the-rule-tp2601621p2601621.html
Sent from the Drools - Dev mailing list archive at Nabble.com.
_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev

Wolfgang Laun | 1 Mar 10:03 2011
Picon

Re: [rules-dev] eval problem

Please do not use this list for simple questions - it is reserved for discussion Drools development itself.

(1) Did you inform the Drools engine about incrementing nbFactRisque?
(2) There is no such thing as "alphabetic mode" for rule execution.
(3) Why do you use eval when you can test the fact field?

Indication: Drools Expert manual, three times per day ;-)
-W


On 1 March 2011 09:17, Nico ROEDERER <ino.nicolas <at> gmail.com> wrote:
Hi,

I've got an other problem with an eval function.
I will try to discribe the path to the error.

I've got a repository where some people can put rules with .drl extension.
My program is listing this repository and execute every rule in this repository.

At the begining, I've got a 'PatientDto' who have a property :
int nbFactRisque;
(with getters and setters)

Some rules increments this number.

In the last rule (the rules are executed in alphabetic mode) I'm testing this number like this :

rule "RisqueNormal"
    when
        $patient : PatientDto()
        eval( $patient.getNbFactRisque() == 0)
    then
        $patient.addDonnees( Constants.CLE_RISQUEPATIENT, Constants.RISQUE_NORMAL );
        System.out.println("RisqueNormal vérifié." + $patient.getNbFactRisque() + "Facteurs.");
end

Here's my problem :
The 'Then' traitement is always executed so the eval always think that $patient.getNbFactRisque() is equal to 0.
But the system.out.println() show me that $patient.getNbFactRisque()  = 2 !

Here's the output : "RisqueNormal vérifié.2Facteurs.".

Perhaps I did something wrong ? Can someone help me ?
Thank you.

_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev


_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
Wolfgang Laun | 1 Mar 10:09 2011
Picon

Re: [rules-dev] Activating the rule

Please do not use this list for simple questions - it is reserved for discussion Drools development itself.

(1) The "exists(Account)" is superfluous; existence is implied by the match in the next Conditional Element.
(2) The rule should match once and only once for each Account fact inserted into Working Memory.

Reading the Drools Expert documentation might clarify this and more for you.

-W



On 1 March 2011 09:53, pchenna <prashanth.sc <at> gmail.com> wrote:
I have a rule while calls doMenu to display options and modify data
accordingly.But why this rule is getting called only once even thought
"WHEN" condition is matching.Isn't it should be called every-time condition
matches?

rule "Check trans"
       dialect "java"
       when
               exists(Account())
           $account :Account()
       then
               doMenu($account,drools.getWorkingMemory());

end

rule "Credit"
#some code here
end rule

rule "Debit"
#some code here
end rule


function void doMenu(Account account,WorkingMemory wm) {

       String option = "1";
       //while(!option.equalsIgnoreCase("3")){

       option = JOptionPane.showInputDialog("1.Debit \n" +
                                               "2.Credit \n" +
                                               "3. Exit");

       if(option.equalsIgnoreCase("1")){

               String amount  = JOptionPane.showInputDialog("Enter Amount to be
Debited");
               double amt = Double.parseDouble(amount);
               Transaction t = new Transaction ( account, amt, Transaction.DEBIT);
               wm.insert(t);


       }else if(option.equalsIgnoreCase("2")){

               String amount  = JOptionPane.showInputDialog("Enter Amount to be
Credited");
               double amt = Double.parseDouble(amount);
               Transaction t = new Transaction ( account, amt, Transaction.CREDIT);
               wm.insert(t);
       }

//}
}

Sorry if this question is very naive,tried searching in forums and couldn't
find anything helpful.

--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Activating-the-rule-tp2601621p2601621.html
Sent from the Drools - Dev mailing list archive at Nabble.com.
_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev

_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
Nico ROEDERER | 1 Mar 10:15 2011
Picon

Re: [rules-dev] eval problem

(1) -> yes because when I print the value, the value is correct ( = 2 ). Not the eval.
(2) -> yes, true. My list is in alphabtic mode...
(3) -> Every test I make made the wrong result

eval( $patient.getNbFactRisque() == 0)
or $patient : PatientDto( nbFactRisque == 0 ) ...
---> Why does those test are true dispite nbFactRisque = 2 ????

It works fine when I run x time drools (one call for one rule) but it doesn't work when I run one time with a List of rules.

Can you tell me the right mailing list for those problems ?


Le 01/03/2011 10:03, Wolfgang Laun a écrit :
Please do not use this list for simple questions - it is reserved for discussion Drools development itself.

(1) Did you inform the Drools engine about incrementing nbFactRisque?
(2) There is no such thing as "alphabetic mode" for rule execution.
(3) Why do you use eval when you can test the fact field?

Indication: Drools Expert manual, three times per day ;-)
-W


On 1 March 2011 09:17, Nico ROEDERER <ino.nicolas <at> gmail.com> wrote:
Hi,

I've got an other problem with an eval function.
I will try to discribe the path to the error.

I've got a repository where some people can put rules with .drl extension.
My program is listing this repository and execute every rule in this repository.

At the begining, I've got a 'PatientDto' who have a property :
int nbFactRisque;
(with getters and setters)

Some rules increments this number.

In the last rule (the rules are executed in alphabetic mode) I'm testing this number like this :

rule "RisqueNormal"
    when
        $patient : PatientDto()
        eval( $patient.getNbFactRisque() == 0)
    then
        $patient.addDonnees( Constants.CLE_RISQUEPATIENT, Constants.RISQUE_NORMAL );
        System.out.println("RisqueNormal vérifié." + $patient.getNbFactRisque() + "Facteurs.");
end

Here's my problem :
The 'Then' traitement is always executed so the eval always think that $patient.getNbFactRisque() is equal to 0.
But the system.out.println() show me that $patient.getNbFactRisque()  = 2 !

Here's the output : "RisqueNormal vérifié.2Facteurs.".

Perhaps I did something wrong ? Can someone help me ?
Thank you.

_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev


_______________________________________________ rules-dev mailing list rules-dev <at> lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-dev
_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
Pierre | 1 Mar 10:44 2011
Picon

[rules-dev] Google Summer of Code

Hi guys,

The mentoring organization applications are now being accepted for the Google Summer of Code
(http://google-opensource.blogspot.com/2011/02/mentoring-organization-applications-now.html).
I would like to take advantage of that to develop the RIF support in Drools. Is there an application from the
Drools project itself or should I apply through my university?

All the best,
Pierre

_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev

Wolfgang Laun | 1 Mar 10:47 2011
Picon

Re: [rules-dev] eval problem

The correct list is rules-users <at> lists.jboss.org


On 1 March 2011 10:15, Nico ROEDERER <ino.nicolas <at> gmail.com> wrote:
(1) -> yes because when I print the value, the value is correct ( = 2 ). Not the eval.

Show us the rule where you increment.
 
(2) -> yes, true. My list is in alphabtic mode...

This does not matter for the order those rules will fire.

 
(3) -> Every test I make made the wrong result

Obvious - the problem is somewhere else, not in the test.

-W


_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
Nico ROEDERER | 1 Mar 10:52 2011
Picon

Re: [rules-dev] eval problem

Here's one exemple of incrementation :
IN drl file :
rule "FacteurRisqueHomme"
    when
        $patient : PatientDto()
        eval( $patient.getValue( Constants.RULE_KEY_SEXE ).equals( Constants.SEXE_HOMME )
            && $patient.getDoubleValue( Constants.RULE_KEY_AGE ) > $patient.getDoubleProperties("valeur.age.homme")  )
    then
        $patient.incNbFactRisque();
        System.out.println("FacteurRisqueHomme vérifié");
end

In PatientDto :
   /**
    * Permet l'incrémentation du nombre de risque (depuis une règle drools)
    */
   public void incNbFactRisque() {
       nbFactRisque++;
   }



Le 01/03/2011 10:47, Wolfgang Laun a écrit :
The correct list is rules-users <at> lists.jboss.org


On 1 March 2011 10:15, Nico ROEDERER <ino.nicolas <at> gmail.com> wrote:
(1) -> yes because when I print the value, the value is correct ( = 2 ). Not the eval.

Show us the rule where you increment.
 
(2) -> yes, true. My list is in alphabtic mode...

This does not matter for the order those rules will fire.

 
(3) -> Every test I make made the wrong result

Obvious - the problem is somewhere else, not in the test.

-W


_______________________________________________ rules-dev mailing list rules-dev <at> lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-dev
_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
Wolfgang Laun | 1 Mar 11:07 2011
Picon

Re: [rules-dev] eval problem

The correct way is

   modify( $patient ){
     incNbFactRisque()
   }

-W


On 1 March 2011 10:52, Nico ROEDERER <ino.nicolas <at> gmail.com> wrote:
Here's one exemple of incrementation :
IN drl file :
rule "FacteurRisqueHomme"
    when
        $patient : PatientDto()
        eval( $patient.getValue( Constants.RULE_KEY_SEXE ).equals( Constants.SEXE_HOMME )
            && $patient.getDoubleValue( Constants.RULE_KEY_AGE ) > $patient.getDoubleProperties("valeur.age.homme")  )
    then
        $patient.incNbFactRisque();
        System.out.println("FacteurRisqueHomme vérifié");
end

In PatientDto :
   /**
    * Permet l'incrémentation du nombre de risque (depuis une règle drools)
    */
   public void incNbFactRisque() {
       nbFactRisque++;
   }



Le 01/03/2011 10:47, Wolfgang Laun a écrit :
The correct list is rules-users <at> lists.jboss.org


On 1 March 2011 10:15, Nico ROEDERER <ino.nicolas <at> gmail.com> wrote:
(1) -> yes because when I print the value, the value is correct ( = 2 ). Not the eval.

Show us the rule where you increment.
 
(2) -> yes, true. My list is in alphabtic mode...

This does not matter for the order those rules will fire.

 
(3) -> Every test I make made the wrong result

Obvious - the problem is somewhere else, not in the test.

-W


_______________________________________________ rules-dev mailing list rules-dev <at> lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-dev

_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev


_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
Mark Proctor | 1 Mar 11:26 2011

Re: [rules-dev] Google Summer of Code

On 01/03/2011 09:44, Pierre wrote:
> Hi guys,
>
> The mentoring organization applications are now being accepted for the Google Summer of Code
(http://google-opensource.blogspot.com/2011/02/mentoring-organization-applications-now.html).
I would like to take advantage of that to develop the RIF support in Drools. Is there an application from the
Drools project itself or should I apply through my university?
What I'd love to see is a common java model that both RIF and RuleML 
could parse too.

I'll find out if Red HaT have any slots for google summer of code, last 
year they didn't. Also Red Hat has soooo many projects and a very 
limited number of slots, that if you can apply via your university, it 
may be a safer bet.

Mark
> All the best,
> Pierre
>
> _______________________________________________
> rules-dev mailing list
> rules-dev <at> lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>

_______________________________________________
rules-dev mailing list
rules-dev <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev


Gmane