The first case
rule "Remove smaller or non-overriden"
    dialect "java"
    when
        L : Response( $r : value && status != "override" )
        (Response(  value > $r ) or Response( status == "override"))
    then
        retract( L );   
end


breaks down to

rule "Rule1"
    dialect "java"
    when
        L : Response( $r : value && status != "override" )
        Response(  value > $r )
    then
        retract( L );   
end

and

rule "Rule2"
    dialect "java"
    when
        L : Response( $r : value && status != "override" )
        Response( status == "override")
    then
        retract( L );   
end


I see that the first rule removes all objects with smaller values and the second one removes all the ones that arent overridden if there exists an object that has an override


What I dont understand is, why the second one doesnt have similar behaviour


rule "Remove smaller or non-overriden"
    dialect "java"
    when
        L : Response( $r : value && status != "override" )
        Response(  value > $r ||  status == "override" )
    then
        retract( L );   
end

When this rule runs , it should start removing objects with smaller values that are *not* overridden .  So if an overridden object exists finally we will be left with 2  objects

Response( maxvalue, non override status ) and Response( somevalue, "override" )

When the rule fires now  L will take on the first one and the the other object will match the second one since it has an override even though value  <= $r . This L should be extracted and we should just be left with the overridden object.

But  I still seem to be left with both the objects.


Jai



On Feb 7, 2008 1:45 PM, Mark Proctor <mproctor@codehaus.org> wrote:
Better still why don't you say why you think it's different. Remember 'or' results in two rules being generate, so write out those two rules separately and it might help you understand. The second one is just standard logic. And don't forget you'll get standard cross products here, i.e. A x B and B x A.

Mark

Jai Vasanth wrote:
Here is the actual reason why I wanted to know the difference between those 2.


rule "Remove smaller or non-overriden"
    dialect "java"
    when
        L : Response( $r : value && status != "override" )
        (Response(  value > $r ) or Response( status == "override"))
    then
        retract( L );   
end

The above rule performs what I intended. It retains the Response with the largest value or it the one that has an override status (if one exists)

But I am getting a different behaviour for this one

rule "Remove smaller or non-overriden"
    dialect "java"
    when
        L : Response( $r : value && status != "override" )
        Response(  value > $r ||  status == "override" )
    then
        retract( L );   
end

This rule seems to retain both the objects, the overriden and the largest value

Could you explain to me how they are diffrent.

Thanks

Jai


On Feb 6, 2008 4:30 PM, Mark Proctor <mproctor@codehaus.org> wrote:
One is a field constraint disjointed connected the other is a Conditional Element 'or'. Details of both are covered in the manual. Suffice to say the first is like writting if ( stmt1.attrib1 == "X" || smt1.attrib1 == "Y" ) whil the ohte results in two separate rules, one checking "X" and the other checking "Y", both rules can match and fire.

Mark

Jai Vasanth wrote:
Hi,

 What is the difference between the following 2 statements


stmt1 : FactA( attrib1 == "X" ||  attrib1 =="Y")   


stmt2: FactA( attrib1 =="X") or FactA(attrib1 =="Y")



Thanks

Jai

_______________________________________________ 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



_______________________________________________ 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