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