[rules-users] Help Problem with kind of minimization

l'ami molette l_ami_molette at hotmail.com
Thu May 3 06:15:02 EDT 2007



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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070503/a91fec5f/attachment.html 


More information about the rules-users mailing list