[rules-users] Plz reply : Descending order rule

Barath barathguna at gmail.com
Thu Feb 21 05:33:38 EST 2008


Hi,

Let me say my understanding about this rule...

rule "Descending order"
    when
        $a : Order( $value : value )
        not Order( value > $value)
    then
        System.out.println("value :"+$value);                	
        retract($a);
end

1. Order value=1    let this be A
2. Order value=2    let this be B
3. Order value=3    let this be C

Case 1 :   $a : Order($value : 1)
              not Order(2 > 1)
           So this rule is True.

Case 2 :   $a : Order($value : 1)
              not Order(3 > 1)
           So this rule is True.

Case 3 :   $a : Order($value : 2)
              not Order(2 > 3)
           So this rule is True.

Case 4 :   $a : Order($value : 2)
              not Order(2 > 1)
           So this rule is False.

Case 5 :   $a : Order($value : 3)
              not Order(3 > 1)
           So this rule is False.

Case 6 :   $a : Order($value : 3)
              not Order(3 > 2)
           So this rule is False.

This indicates the rule should fire for three times but its not the case.
I know i going wrong some where but i couldn't figure out.
Plz do help me.....

Barath.


Barath wrote:
> 
> Hi,
> 
> Can u explain me the rule flow for the below rule ?.
> This will help me to get some clear idea about rules.
> 
> rule "Descending order"
>     when
>         $a : Order( $value : value )
>         not Order( value > $value)
>     then
>         System.out.println("value :"+$value);                	
>         retract($a);
> end
> 
> I am having the following ,
> 
> 1. Order value=1
> 2. Order value=2
> 3. Order value=3
> 4. Order value=4
> 5. Order value=5
> 
> Can u explain the flow(when part) for this 5 object ?
> 
> Note my understanding(in when) : 1st line  take one order object
>                                                  2nd line check for
> any other object with grater 'value'
>                                                  But i dont know
> sequence in which the objects are taken.
> 
> Plz do reply......
> 
> Thanks in advance,
> Barath.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Plz-reply-%3A-Descending-order-rule-tp15606103p15607261.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list