Re: [rules-users] Help Problem with kind of minimization

2007-05-03 Thread Edson Tirelli

  Ops, copy&paste problem. The correct rule is:

rule "get closer object"
when
   $a : Agent( $num1 : num )
   $b : Poste( $num2 : num )
   not Poste( $num3 : num -> ( abs( $num1, $num3 ) < abs( $num1, $num2 ) )
)
then
   // do something
end

  []s
  Edson

2007/5/3, Edson Tirelli <[EMAIL PROTECTED]>:



Hi,

If you are using 4.0.0.M2, I think this will do the job:

function abs( int a, int b ) {
return Math.abs( b - a );
}

rule "get closer object"
when
$a : Agent( $num1 : num )
$b : Poste( $num2 : num )
not Poste( $num3 : num -> ( abs( $num1, $num3 ) < Math.abs( $num1,
$num2 ) ) )
then
// do something
end

If you are using 3.0.x, then it would be like:

function abs( Integer a, Integer b ) {
return Math.abs( b.intValue() - a.intValue() );
}

rule "get closer object"
when
$a : Agent( $num1 : num )
$b : Poste( $num2 : num )
not Poste( $num3 : num -> ( abs( $num1, $num3 ) < Math.abs( $num1,
$num2 ) ) )
then
// do something
end

Hope it helps. Let us know if it works the way you need.

[]s
Edson


2007/5/3, l'ami molette <[EMAIL PROTECTED]>:
>
>  Hi, I'm a new user of JBossRules, and I have difficulties to solve a
> problem using jBossRules.
>
>
>
> I have two classes (AClass.java & Bclass.java). Each one have a number
> (an "int" value (AClass.getNum() & BClass.getNum())
>
> , and I want to extract a Aclass & a Bclass witch have the closest
> numbers. In fact I want to minimize the value:
>
> Math.abs(AClass.getNum() - BClass.getNum()).
>
>
>
> I tried to write a rule like this:
>
>
>
> rule "My rule"
>
> when
>
> ACl : Agent ($AClNum : num , $AClNom : nom)
>
> BCl : Poste ($BClNum : num , $BClNom : nom)
>
> BCl2 : Poste ()
>
> not Agent($ACl2Num : num ->
> (Aminor(CalculAbsolue($ACl2Num.intValue(),BCl2.getNum()) ,
> CalculAbsolue($AClNum.intValue(),$BClNum.intValue()) )))
>
> then
>
> System.out.println("Selected : "+ ACl.getName()
> +" "+BCl.getName()+" diff: "+ CalculAbsolue(ACl.getNum(),BCl.getNum()));
>
> retract(ACl);
>
> retract(BCl);
>
> end
>
>
>
> function int CalculAbsolue(int a, int b){
>
> return Math.abs(b-a);
>
> }
>
>
>
> function boolean Aminor(int a, int b){
>
> return a < b;
>
> }
>
>
>
> --> But the rule doesn't work.
>
> Does anyone have an idea to solve my problem?
>
> Thank you very much for your help.
>
> Olivier Lafon
>
>
>
> PS : (excuse my English, I'm French)
>
> --
> Essayez Live.com, votre nouvelle page d'accueil ! Personnalisez-la en
> quelques clics pour retrouver tout ce qui vous intéresse au même endroit. au
> même endroit. 
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


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





--
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3529-6000
 Mobile: +55 11 9287-5646
 JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Help Problem with kind of minimization

2007-05-03 Thread Edson Tirelli

   Hi,

   If you are using 4.0.0.M2, I think this will do the job:

function abs( int a, int b ) {
   return Math.abs( b - a );
}

rule "get closer object"
when
   $a : Agent( $num1 : num )
   $b : Poste( $num2 : num )
   not Poste( $num3 : num -> ( abs( $num1, $num3 ) < Math.abs( $num1, $num2
) ) )
then
   // do something
end

   If you are using 3.0.x, then it would be like:

function abs( Integer a, Integer b ) {
   return Math.abs( b.intValue() - a.intValue() );
}

rule "get closer object"
when
   $a : Agent( $num1 : num )
   $b : Poste( $num2 : num )
   not Poste( $num3 : num -> ( abs( $num1, $num3 ) < Math.abs( $num1, $num2
) ) )
then
   // do something
end

   Hope it helps. Let us know if it works the way you need.

   []s
   Edson


2007/5/3, l'ami molette <[EMAIL PROTECTED]>:


 Hi, I'm a new user of JBossRules, and I have difficulties to solve a
problem using jBossRules.



I have two classes (AClass.java & Bclass.java). Each one have a number (an
"int" value (AClass.getNum() & BClass.getNum())

, and I want to extract a Aclass & a Bclass witch have the closest
numbers. In fact I want to minimize the value:

Math.abs(AClass.getNum() - BClass.getNum()).



I tried to write a rule like this:



rule "My rule"

when

ACl : Agent ($AClNum : num , $AClNom : nom)

BCl : Poste ($BClNum : num , $BClNom : nom)

BCl2 : Poste ()

not Agent($ACl2Num : num ->
(Aminor(CalculAbsolue($ACl2Num.intValue(),BCl2.getNum()) ,
CalculAbsolue($AClNum.intValue(),$BClNum.intValue()) )))

then

System.out.println("Selected : "+ ACl.getName() +"
"+BCl.getName()+" diff: "+ CalculAbsolue(ACl.getNum(),BCl.getNum()));

retract(ACl);

retract(BCl);

end



function int CalculAbsolue(int a, int b){

return Math.abs(b-a);

}



function boolean Aminor(int a, int b){

return a < b;

}



--> But the rule doesn't work.

Does anyone have an idea to solve my problem?

Thank you very much for your help.

Olivier Lafon



PS : (excuse my English, I'm French)

--
Essayez Live.com, votre nouvelle page d'accueil ! Personnalisez-la en
quelques clics pour retrouver tout ce qui vous intéresse au même endroit. au
même endroit. 

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





--
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3529-6000
 Mobile: +55 11 9287-5646
 JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] ImputDrl

2007-05-03 Thread Alexey Panchenko

Hi Ismail,

1) Make sure .drl file is available thru the classpath
2) Try .class.getResourceAsStream("/Drl/Sample.drl") (with leading slash).
The path is treated as relative without the leading slash.

Alex

On 5/3/07, fakhfakh ismail <[EMAIL PROTECTED]> wrote:


Hello,
First sorry for my bad english,

I set all the class .java is in package hero.client.test
and the file .drl is in folser Drl
the call of file .drl
InputStream in = DroolsTest.class.getResourceAsStream("Drl/Sample.drl");

but the problem is they didn't find the file .drl
always an exception is affiched

Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:55)
at
org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown
Source)
at hero.client.test.DroolsTest.main(DroolsTest.java:34)
Please I need your help
Best regards
Ismail

--
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions
! Profitez des connaissances, des opinions et des expériences des
internautes sur Yahoo! 
Questions/Réponses
.


___
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] Disabling indexing causes error

2007-05-03 Thread P Robinson


> Can you plz provide a self contained test an open a JIRA for us to
> investigate? There shouldn't be any problem in disabling/enabling indexes
> as
> this should be a transparent optimization.


Hi,

Yes, I was using Drools 3.0.6.

I have opened the JIRA issue http://jira.jboss.com/jira/browse/JBRULES-838
and (hopefully) attached a test to this posting; see readme.txt for
instructions.

http://www.nabble.com/file/8197/disabling_right_indexing_error.zip
disabling_right_indexing_error.zip 

Thanks!
-- 
View this message in context: 
http://www.nabble.com/Disabling-indexing-causes-error-tf3668001.html#a10301144
Sent from the drools - user 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] error compilation

2007-05-03 Thread suchi22


include stringtemplate-2.3b6.jar in classpath..



fakhfakh ismail wrote:
> 
> hello,
> when I execute my code an error is affiched
> 
> [java] Exception in thread "main" java.lang.NoClassDefFoundError:
> org/antlr/stringtemplate/StringTemplateGroup
> [java] at
> org.drools.semantics.java.RuleBuilder.(Unknown Source)
> [java] at org.drools.compiler.PackageBuilder.addRule(Unknown
> Source)
> [java] at
> org.drools.compiler.PackageBuilder.addPackage(Unknown Source)
> [java] at
> org.drools.compiler.PackageBuilder.addPackageFromDrl(Unknown Source)
> [java] at
> org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown
> Source)
> [java] at
> org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown
> Source)
> 
> thank you for your help
> Best regards
> Ismail
> 
>  
> -
>  Découvrez une nouvelle façon d'obtenir des réponses à toutes vos
> questions ! Profitez des connaissances, des opinions et des expériences
> des internautes sur Yahoo! Questions/Réponses.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/error-compilation-tf3685632.html#a10302406
Sent from the drools - user 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] error compilation

2007-05-03 Thread Hehl, Thomas
If you download the jBoss rules with Dependencies file, it comes with
string-template.jar. Use this.

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of fakhfakh ismail
Sent: Thursday, May 03, 2007 6:03 AM
To: jboss rules
Subject: [rules-users] error compilation

 

hello,
when I execute my code an error is affiched

[java] Exception in thread "main" java.lang.NoClassDefFoundError:
org/antlr/stringtemplate/StringTemplateGroup
[java] at org.drools.semantics.java.RuleBuilder.(Unknown
Source)
[java] at org.drools.compiler.PackageBuilder.addRule(Unknown
Source)
[java] at org.drools.compiler.PackageBuilder.addPackage(Unknown
Source)
[java] at
org.drools.compiler.PackageBuilder.addPackageFromDrl(Unknown Source)
[java] at
org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExe
cutionSet(Unknown Source)
[java] at
org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExe
cutionSet(Unknown Source)

thank you for your help
Best regards
Ismail

  

  _  

Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes
sur Yahoo! 
Questions/Réponses.

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


Re: [rules-users] ImputDrl

2007-05-03 Thread Niloy Debnath
sir,
 if you want to take any .drl file as an input of your JAVA program then 
you can try this code,

final Reader source = new InputStreamReader( 
ClassExample.class.getResourceAsStream( "Class.drl" ) );

here ClassExample is corresponding JAVA program of your  Class.drl  file and 
ClassExample is your main class which contain main 

with regards,
Niloy Debnath

fakhfakh ismail <[EMAIL PROTECTED]> wrote: Hello,
First sorry for my bad english,

I set all the class .java is in package hero.client.test
and the file .drl is in folser Drl
the call of file .drl 
InputStream in = DroolsTest.class.getResourceAsStream("Drl/Sample.drl");

but the problem is they didn't find the file .drl 
always an exception is affiched

Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:55)
at  
org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown
 Source)
at hero.client.test.DroolsTest.main(DroolsTest.java:34)
Please I need your help
Best regards
Ismail
  

-
  Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !  
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses.___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


   
-
 Check out what you're missing if you're not on Yahoo! Messenger ___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Help Problem with kind of minimization

2007-05-03 Thread l'ami molette


Hi, I’m a
new user of JBossRules, and I have difficulties to solve a problem using
jBossRules.

 

I have two
classes (AClass.java & Bclass.java). Each one have a number (an
"int" value (AClass.getNum() & BClass.getNum())

, and I
want to extract a Aclass & a Bclass witch have the closest numbers. In fact
I want to minimize the value:

Math.abs(AClass.getNum()
- BClass.getNum()).

 

I tried to
write a rule like this:

 

rule
"My rule"

when

ACl : Agent ($AClNum :
num , $AClNom : nom)

BCl : Poste ($BClNum :
num , $BClNom : nom)

BCl2 : Poste ()

not Agent($ACl2Num : num
-> (Aminor(CalculAbsolue($ACl2Num.intValue(),BCl2.getNum()) ,
CalculAbsolue($AClNum.intValue(),$BClNum.intValue()) )))

then

System.out.println("Selected
: "+ ACl.getName() +" "+BCl.getName()+" diff: "+
CalculAbsolue(ACl.getNum(),BCl.getNum()));

retract(ACl);

retract(BCl);

end

 

function int CalculAbsolue(int a, int b){

return
Math.abs(b-a);

}



function boolean Aminor(int a, int b){

return
a < b;

}



--> But the rule doesn't work.

Does anyone have an idea to solve my
problem?

Thank you very much for your help.

Olivier Lafon 

 

PS : (excuse
my English, I’m French)


_
Exprimez-vous : créez la page d'accueil qui vous ressemble avec Live.com.
http://www.live.com/getstarted___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] error compilation

2007-05-03 Thread fakhfakh ismail
hello,
when I execute my code an error is affiched

[java] Exception in thread "main" java.lang.NoClassDefFoundError: 
org/antlr/stringtemplate/StringTemplateGroup
[java] at org.drools.semantics.java.RuleBuilder.(Unknown 
Source)
[java] at org.drools.compiler.PackageBuilder.addRule(Unknown Source)
[java] at org.drools.compiler.PackageBuilder.addPackage(Unknown 
Source)
[java] at 
org.drools.compiler.PackageBuilder.addPackageFromDrl(Unknown Source)
[java] at 
org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown
 Source)
[java] at 
org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown
 Source)

thank you for your help
Best regards
Ismail

 
-
 Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses.___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] ImputDrl

2007-05-03 Thread fakhfakh ismail
Hello,
First sorry for my bad english,

I set all the class .java is in package hero.client.test
and the file .drl is in folser Drl
the call of file .drl 
InputStream in = DroolsTest.class.getResourceAsStream("Drl/Sample.drl");

but the problem is they didn't find the file .drl 
always an exception is affiched

Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:55)
at 
org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown
 Source)
at hero.client.test.DroolsTest.main(DroolsTest.java:34)
Please I need your help
Best regards
Ismail

 
-
 Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses.___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users