You're missing the agenda.
http://en.wikipedia.org/wiki/Rete_algorithm#Conflict_resolution
In the rete algorithm the agenda is a list of activated rules who's actions are
eligible to fire. The "first" one on the list is selected, it's action is
fired, and the agenda might change as a result. "First" is in quotes because
the agenda list is sorted by conflict resolution rules. One of those rules drools uses is
specificity, which means that rules with more specific patterns (i.e. ones that select for
a more specific set of working memory objects) are selected before less specific ones.
You can't get any less specific than selecting nothing, so the empty LHS rule is
selected last...
--- On Tue, 11/16/10, Nirmal Fernando <nirmal070125(a)gmail.com> wrote:
From: Nirmal Fernando <nirmal070125(a)gmail.com>
Subject: Re: [rules-users] Replacement for eval
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Date: Tuesday, November 16, 2010, 10:32 PM
Thanks for the replies!
I observed that the action of a rule not get executed straight after that rule activated.
Say my rules are following:
rule "Hello World"
when
then
System.out.println( "hello world" );
end
rule "GoodBye"
when
Message( status == Message.GOODBYE, myMessage : message )
then
System.out.println("good bye");
end
If I have set up my Message class such that it will fire the "GoodBye" rule, my
output is:
good bye
hello world
What I wanna know whether this is the expected behaviour? (Since normally I expect the
action of that particular rule to be executed straight after it's fired.)
Am I missing something here?
Thanks.
2010/11/16 Greg Barton <greg_barton(a)yahoo.com>
If you use bean property conventions for naming your methods you can use a regular
condition element. for instance, you could rename emptyMessageFinder() to
isMessageFound() or getMessageFound() and your condition would look like this:
when m : Message(messageFound == true)then...end
And when you do this the rete is used, birds sing in the trees, and world peace will be
declared.
GreG
On Nov 16, 2010, at 5:37, Nirmal Fernando <nirmal070125(a)gmail.com> wrote:
Hi,
I have two questions.
1) Is there any other way/method in Drools to test the truth value of a condition other
than "eval"?
In almost all rules of my application needs to test conditions, and it takes ages to run
using "eval".
2) Say I have a java method which returns a boolean, and I have used it within an
"eval" function. (eg: eval(message.emptyMessageFinder()) )
This "emptyMessageFinder()" method will return a "boolean" if
there's an empty message. This function is containing many loops and recursive
operations.
Will I get a performance improvement if I alternate the above such that the
"emptyMessageFinder()" method sets a boolean attribute (anyEmptyMessage)
in the Message class to true and false, and I'm using following in my drl.
when
m: Message()
m.emptyMessageFinder()
eval(m.anyEmptyMessage) //can I use eval here??
......
If someone can answer these questions it would be a great help!
Thank you in advance!
--
Best Regards,
Nirmal
C.S.Nirmal J. Fernando
Department of Computer Science & Engineering,
Faculty of Engineering,
University of Moratuwa,
Sri Lanka.
Blog: http://nirmalfdo.blogspot.com/
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Best Regards,
Nirmal
C.S.Nirmal J. Fernando
Department of Computer Science & Engineering,
Faculty of Engineering,
University of Moratuwa,
Sri Lanka.
Blog: http://nirmalfdo.blogspot.com/
-----Inline Attachment Follows-----
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users