[rules-users] Negation semantics in Drools

Greg Barton greg_barton at yahoo.com
Thu Apr 16 22:34:36 EDT 2009


You don't have to worry.  The engine is acting as it should.

The rule Paul had was this, a bit simplified for clarity:

rule "direct"
when
    m : Move()
    not Win(first == m.second)
then
 	insert(new Win(m.first));
end

If the insertion order is [Move(1,2), Move(2,3)] then the rule matches first on Move(2,3) and Win(2) is inserted.  No other rule fires because now Move(1,2) and Win(2) match up, removing the instantiation with Move(1,2) from the agenda.

If the insertion order is [Move(2,3), Move(1,2)] then the order is this:

matched Move(1,2) insert Win(1)
matched Move(2,3) insert Win(2)

The insertion of Win(1) in the first firing does NOT prevent the instantiation with Move(2,3) from then firing.

So it's all good. :)  Sample code and output attached.

--- On Thu, 4/16/09, Greg Barton <greg_barton at yahoo.com> wrote:

> From: Greg Barton <greg_barton at yahoo.com>
> Subject: Re: [rules-users] Negation semantics in Drools
> To: "Rules Users List" <rules-users at lists.jboss.org>
> Date: Thursday, April 16, 2009, 8:50 PM
> It is on the latest snapshot release,
> 5.0.0.20090417.005612-483
> 
> --- On Thu, 4/16/09, Edson Tirelli <tirelli at post.com>
> wrote:
> 
> >     We need to investigate if that is still happening
> in
> > latest trunk.
> 
> 
>       
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users


      
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample.drl
Type: application/octet-stream
Size: 259 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20090416/635c9c4d/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DroolsTest.java
Type: text/x-java
Size: 3679 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20090416/635c9c4d/attachment.bin 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: out.txt
Url: http://lists.jboss.org/pipermail/rules-users/attachments/20090416/635c9c4d/attachment.txt 


More information about the rules-users mailing list