Question about ruleflows
by Eric Miles
I'm going through some code and I came across something that doesn't
make much sense to me. Can someone explain to me the design behind
tieing a ruleflow to a package? I'm trying to programmatically build
some rulebases together and just realized I can not add a ruleflow to a
rulebase directly unless it has already been added to a package (thus
when I add the package to the rulebase, the ruleflow is indirectly
added). This doesn't seem completely right and would like some
clarification on why.
Thanks,
Eric
17 years
Externalizing Rule parameters - patterns/best practices
by Krishna Satya
Hi, I am a new user to Drools and having passed the first few days of
reading and experimenting with the tool I am now looking to see how rule
parameters can be externalized. And along those lines looking for patterns
and best practices. I have searched through the user forums (maybe not
submitting the right search critera) and through samples etc.
My query is from my intent that application should be decoupled from rules
and the rules are decoupled from its parameters.
I am wondering if Decision tables is the recommended approach or
externalizing/sourcing from Db recommended. Does the Business Service that
interacts with the rule engine source the rule parameters and push it into
working memory for the rule to pickup...or should the rule
declaration be tightly coupled to its parameters.
For example (Quick Psudo code, not sure if I have made any syntactical
errors):
rule "Fee Waive Rule"
when
clientRequest : Request(account.balance > 2000 )
then
clientRequest.setFee(0);
end
rule "Fee Apply Rule"
when
clientRequest : Request(account.balance < 2000 )
then
clientRequest.setFee(5);
end
In the example above what are the best ways to externalize and make
available to the rule the account balance and fee parameters?
Any guidance on patterns/best practices/examples would be much appreciated.
Regards.
- Krishna
17 years
RE:how to configure the rule
by Sikkandar Nawabjan
Is there any Webutility available to configure rules remotely. Please let me know the links and reference material to do the same.
Thanks and Regs,
Basha
17 years
Can I reuse eval output?
by Arjun Dhar
Hi,
I've learned the use of eval() is not efficient, but it cannot be avoided in
many cases.
However, using temporary variables I tried:
when
$tmp: eval(...)
($tmp == false) or (eval(...))
Then
...
end
The above doers not compile; is there an alternative to reduce the number of
evals by reusing their output?
Another question is, is tehre something wrong in the above definition from a
declarative programming point of view?
Thanks,
Arjun
17 years
Re: Constants on LHS?
by J Michael Dean
Thanks. My problem with this is that these constants would have to be
defined in my Java application and then inserted into the session, I
think. What I would aim for is to have ALL the business logic in the
DRL file, but setting constants such as lowTargetLimit = 80 in the
application and then pushing that into the session object does not
make sense to me.
As I write the DRL file with more confidence, I suppose I will end up
creating a DSL. I was just hoping there might be a simple way to
establish constants.
Thanks again.
- Mike
>
> Date: Sun, 9 Dec 2007 15:18:22 -0500
> From: Andy Mei <andy.d.mei(a)gmail.com>
> Subject: Re: [rules-users] Constants on LHS?
> To: Rules Users List <rules-users(a)lists.jboss.org>
> Cc: "rules-users(a)lists.jboss.org" <rules-users(a)lists.jboss.org>
> Message-ID: <F8286E17-CE76-42D7-B49D-089901282452(a)gmail.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> Try global VAR
>
> Sent from my iPhone.
> PLs excuse typing mistake.
>
> On Dec 9, 2007, at 12:48 PM, J Michael Dean <mdean77(a)comcast.net>
> wrote:
>
>> I have not been able to figure out how to define "constants" that
>> can be used replace numbers, etc. on the LHS of rules, and am not
>> quite at the stage where I can set up a DSL. Is there a way to
>> accomplish this?
>>
>> For example, I have a simple rule to determine if glucose is below
>> the targeted range; the lower limit of the target is 80. Quickest
>> solution:
>>
>> when
>> decision : GlucoseDecision(serumGlucoseConcentration < 80)
>> then
>> DO something
>>
>> But I want to be able to write:
>>
>> when
>> decision : GlucoseDecision(serumClucoseConcentration <
>> lowTargetLimit)
>> then
>> Do something
>>
>> so that I can set all these constants in one place, etc.
>>
>> Is there a way to accomplish this inside the DRL?
>>
>> - Mike
>>
17 years
Re: [rules-users] How do I reference newly asserted facts?
by kissro@lidp.com
I understand that part but FNCM_COMMENT is a separate object/fact.
Here's what I'm trying to do:
I have two objects(facts)
FNAC_CLIENT_CONTROL
FNCM_COMMENT
I insert(FNAC_CLIENT_CONTROL)
fireAllRules()
My rule says when FNAC_CLIENT_CONTROL.FNAC_BIRTH_PLACE == "IL"
then insert a new fact that was not previously inserted - FNCM_COMMENT.
I now have 2 facts in WorkingMemory if I understand everything correctly.
When I return to my java program, after the fireAllRules() statement,
I'm hoping to have available to me both the FNAC_CLIENT_CONTROL fact and
the FNCM_COMMENT fact. Is that true? Will I have both available?
If so, how do I access the FNCM_COMMENT fact if it's not in the LHS and
I don't have a variable assigned to it?
> On Mon, Dec 10, 2007 at 11:01:41PM +0530, Darko IVANCAN wrote:
>
>> Hi,
>>
>> In the BRMS you can assign a variable to your fact in the LHS.
>> This would then result in:
>> when
>> a : FNAC_CLIENT_CONTROL( FNAC_BIRTH_PLACE == "IL" )
>> then
>> a.set....
>>
>> good luck,
>> Darko Ivancan
>>
>> On 10/12/2007 20:38, kissro(a)lidp.com wrote:
>>
>>> Hello,
>>>
>>> I am creating all my rules using the BRMS guided rule editor gui.
>>> In the rule editor, I have a rule that looks like this:
>>>
>>> WHEN
>>> FNAC_CLIENT_CONTROL
>>> FNAC_BIRTH_PLACE is equal to "IL"
>>>
>>> THEN
>>> Assert FNCM_COMMENT FNCM_VARIABLE_DATA "This client lives in Illinois"
>>>
>>> When I click the 'View Source' button I see this:
>>>
>>> rule "Rule500"
>>> dialect "mvel"
>>> when
>>> FNAC_CLIENT_CONTROL( FNAC_BIRTH_PLACE == "IL" )
>>> then
>>> FNCM_COMMENT fact0 = new FNCM_COMMENT();
>>> fact0.setFNCM_VARIABLE_DATA( "This client lives in Illinois");
>>> insert( fact0 );
>>> end
>>>
>>> After I return from "fireAllRules", how do I reference the newly
>>> asserted fact in my Java code? Do I reference "fact0" or can I use the
>>> object's "real" name - FNCM_COMMENT.FNCM_VARIABLE_DATA?
>>>
>>> "fact0" is just a generated name created by BRMS when it generates the
>>> rule based on what I type in the gui, right? I'm assuming if I insert
>>> more facts, they would be called fact1, fact2, etc. If I want to
>>> reference these facts, do I have to keep track of how many I've inserted
>>> then reference the appropriate fact number? I'm not sure how to
>>> reference these generated fact names after returning from the rule
>>> engine. Could someone help me?
>>>
>>> Thanks,
>>> Rod
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>>
>>>
>
>
>
>
17 years
Simple rules to "facts"; constraint "all members of a collection exist"
by Ingomar Otter
Folks,
I have a buch of rather simple rules in a configuration use-case which
look like
rule "requires-rule"
when
o1: O(id=2)
o2:O(id=4)
(not (exists (O(id=7))
then
//assert a conflict "O2 and O4 require O7"
In subsequent rules I deal with the conflicts detected. The resolution
of these holds the "juicy bits".
As the above creates quite some text and does not allow me to reason
on the rule itself, I was thinking whether I should
introduce the "domain rule" (o2 & O4 require O7) as a fact and use
'meta rules' to do the processing.
Have you seen similar scenarios? Or is this misuse?
For the time being, I have modeled the requires-rule as something like
class RequiresDomainRule {
Collection<Items> andTermItems; //eg o2, o4
Item requiredItem; O7
}
Then I assert o2,o4 and a RequiresRule( (o2,o4),o6)
But I have a knot in my brain and can't get the LHS written down,
which in prose would be:
there is a "requires rule" whose andTermItems are all present in WM
and whose requiredItem is not present in WM then...
The "andTermItems are all present" got me. I can test for any but
all? - I'm stuck, need help.
Cheers,
Ingomar
--
Ingomar Otter
Chief Technology Officer
mailto:ingomar.otter@valtech.de
Mobile: +49 172 2367867
Valtech GmbH
Bahnstraße 16
40212 Düsseldorf
Germany
Phone: +49 (0)211 179237-0
Fax: +49 211 179237-19
http://www.valtech.de
Geschäftsführer: Ingo Kriescher
Amtsgericht Düsseldorf HRB48672
17 years
How to write a rule which only fires for a closest value?
by velven
HI, i have a problem
using tileworld model, i'm supposed to write a rule which will cause the
agents to choose the tile in the agent's range which is closest to the
agent.
so a rough idea is
when
agent: Agent(x1:x, y1:y, r:range)
tile1: Tile(<tile's x to be between (x1+r) and (x1-r)> && <tile's y to be
between (y1+r and y1-r)>)
tile2: not Tile( < which is closer than the tile1 to agent> )
desperately need help,
alternatives tried::
i tried to use a query to return a list of tiles which is within the agent's
range then compared which one is closer and other similar implementation,
but this too slow for my simulation...
I need one single good rule or efficient way of implementing the above rule
then i tried to do multiple constraints too, say x (> 30 && < 40) is ok
but
x (>
($x-$r) && < ($x+$r)) gives errors ,due to extra parenthesis? i dunno.. any
workarounds?
Thanks!
--
View this message in context: http://www.nabble.com/How-to-write-a-rule-which-only-fires-for-a-closest-...
Sent from the drools - user mailing list archive at Nabble.com.
17 years
How do I reference newly asserted facts?
by kissro@lidp.com
Hello,
I am creating all my rules using the BRMS guided rule editor gui.
In the rule editor, I have a rule that looks like this:
WHEN
FNAC_CLIENT_CONTROL
FNAC_BIRTH_PLACE is equal to "IL"
THEN
Assert FNCM_COMMENT FNCM_VARIABLE_DATA "This client lives in Illinois"
When I click the 'View Source' button I see this:
rule "Rule500"
dialect "mvel"
when
FNAC_CLIENT_CONTROL( FNAC_BIRTH_PLACE == "IL" )
then
FNCM_COMMENT fact0 = new FNCM_COMMENT();
fact0.setFNCM_VARIABLE_DATA( "This client lives in Illinois");
insert( fact0 );
end
After I return from "fireAllRules", how do I reference the newly
asserted fact in my Java code? Do I reference "fact0" or can I use the
object's "real" name - FNCM_COMMENT.FNCM_VARIABLE_DATA?
"fact0" is just a generated name created by BRMS when it generates the
rule based on what I type in the gui, right? I'm assuming if I insert
more facts, they would be called fact1, fact2, etc. If I want to
reference these facts, do I have to keep track of how many I've inserted
then reference the appropriate fact number? I'm not sure how to
reference these generated fact names after returning from the rule
engine. Could someone help me?
Thanks,
Rod
17 years