[rules-users] New to rules engine - help in defining rules
Jeevan Tambuluri
jeevan_tambuluri at symantec.com
Sun Feb 4 13:47:35 EST 2007
Thanks Edson! The rule pattern you suggested works for me. Any such
pattern to simulate "accumulate" in 3.0.x?
Jeevan
Edson Tirelli wrote:
>
> Jeevan,
>
> You are right: the simplest way would be use "forall".
> Unfortunatelly it is only available in trunk.
> To do it in 3.0.x you will need either a helper attribute or a
> helper class. For instance, you may add a "branchLength" attribute to
> the tree and define 2 rules:
>
> rule "define length"
> when
> $t : Tree( branchLength == -1 )
> Branch( mytree == $t, $bl : branch_length )
> then
> $t.setBranchLength( $bl.intValue() );
> modify( $t );
> end
>
> rule "check length"
> when
> $t : Tree( $bl : branchLength != -1 )
> exists Branch( mytree == $t, branch_length != $bl )
> then
> // do something because the branch has a different length
> end
>
> There are several variations but you will need 2 rules to emulate this.
> Hopefully the new version will be out soon solving this kind of
> problem.
>
> []s
> Edson
>
> Jeevan Tambuluri wrote:
>
>> Hello all,
>>
>> I am looking for a way to define rules for the following problem:
>>
>> class Tree {
>> ...
>> }
>>
>> class Branch {
>> Tree mytree;
>> int branch_length;
>> ...
>> }
>>
>> Let's say I have a fact called Tree and another fact called Branch.
>> Brach identifies which tree it belongs to.
>> Now, I want to write a rule to say that all branches in a tree must
>> be of same length.
>> How do I do this with/without using accumulate or forall?
>>
>> Thanks a lot for any help,
>>
>> J
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
More information about the rules-users
mailing list