Re: Rule is firing on those objects for which that hasalready fired
by Alexander Claus
> I need to write some rule which will *only* fire on newly inserted data
> points in Working Memory. Does Drools support any
> such feature which will help me to achieve this ? Any suggestion, how can
> I
> achieve this efficiently?
>
> I am inserting 6 matching DataObjects into Working Memory. Rule is
> getting fired once
>
> But in subsequent rule executions after I insert 6 more matching
> DataObjects
> into Working Memory, Rule is getting fired couple of times
> How can I avoid this ?
Hi,
here:
http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html/ch06s05.html#d...
the "exists" statement is described which has almost the functionality which
you want.
Unfortunately (but intuitively) you cannot access variable bindings from
inside the "exists" body. This is intuitive, because "exists" models the
logical existential quantifier which gives true, if there exist some facts
supporting the truth of the formula !no matter, which facts that are!.
So for your purpose you have to think about, if you are really interested in
which objects trigger the rule. If so, I can imagine, that you don't want to
know only one portion of information but information about each activation.
Then the behaviour of your rule is correct.
But, I know about the problem. I faced it sometimes too. One way to a
solution would be to retract objects from the working memory, if you can
safely assume that they "have done their work". I.e. if you know, that these
objects should not cause activations of this rule again AND you know that no
other rule needs these objects, retract them in the rhs of your rule.
If other rules need the objects and you can't retract them therefore, the
only solution which I know is to mark the objects by yourself as "processed"
by the rule, e.g with your ruleID, and to test everytime in the lhs if the
object of interest is not processed... This is ugly, but it works.
Hope I could help you, but, let me know, if you have found a better
solution.
Alexander Claus
18 years
Re: [rules-users] Working memory view is empty
by Marina
I figured what was wrong - I did not convert my project into Drools project and the debug profile was not starting it as a Drools application. Once I did that - I could see the objects in all views.
Marina
----- Original Message ----
From: Marina <ppine7(a)yahoo.com>
To: Rules Users List <rules-users(a)lists.jboss.org>
Sent: Friday, June 20, 2008 9:07:14 AM
Subject: [rules-users] Working memory view is empty
Hi,
It might be something very simple, but I can't see it. I use Eclipse 3.3 with JBoss Rules 4.0.7 plugin.
I'm trying to debug my rules , but no matter what breakpoints I set I can never get anything in the Working Memory or Agenda views.
I tried setting a normal Java breakpoint on the session.fireAllRules() method -- it stops before calling the method, I select the session variable in the Debug Variables view - but nothing is displayed in the Working Memory view. I even tried to step into the fireAllRules() method - but the Working Memory view is empty at all times.
Then I tried to set a rules breakpoint in a "then" part of my rule - this time Eclipse does not even stop there, instead, it stops on the statement after the call to the fireAllRules() method.
Do I have something mis-configured??
thanks,
Marina
18 years
OR in more than one level
by Sergio Stateri
Hi,
How can I use OR in second level attributes ? (attributes that´re in a
aggregate Class of a aggregate Class of main Class)
when
$trigger : ArrayList( size >= 1 )
from collect( PromotionShoppingCartLine( productItem.sku == "1" ||
productItem.sku == "2" ) from
$promotionShoppingCart.promotionShoppingCartLines )
then
.
.
I can´t use "productItem.sku" (sku attribute inside productItem attribute
that´s inside PromotionShoppingCartLine class) if I´m using the || (OR), but
if I use && (AND) all works fine.
thanks in advance,
Sergio Stateri Jr.
stateri(a)gmail.com
--
Sergio Stateri Jr.
stateri(a)gmail.com
18 years
Working memory view is empty
by Marina
Hi,
It might be something very simple, but I can't see it. I use Eclipse 3.3 with JBoss Rules 4.0.7 plugin.
I'm trying to debug my rules , but no matter what breakpoints I set I can never get anything in the Working Memory or Agenda views.
I tried setting a normal Java breakpoint on the session.fireAllRules() method -- it stops before calling the method, I select the session variable in the Debug Variables view - but nothing is displayed in the Working Memory view. I even tried to step into the fireAllRules() method - but the Working Memory view is empty at all times.
Then I tried to set a rules breakpoint in a "then" part of my rule - this time Eclipse does not even stop there, instead, it stops on the statement after the call to the fireAllRules() method.
Do I have something mis-configured??
thanks,
Marina
18 years
concrete query methods
by thomas kukofka
Hello,
supposed I have rules sets for different issues and operating on different
facts. Now I want to write an interface for users who don't want to be
bothered with details of the Drools API and who wish interface methods which
returns results for concrete questions like:
ResultFact getAnswerForQuestionXY()
How can such a concrete query be implemented?
My first idea was to store the result fact with the help of globals:
rule "XY"
when
FactX ()
then
ResultFact resultFact = new ResultFact();
service.addResultFact(resultFact);
insert(resultFact
);
end
So my method would only return something like service.getResultFact().
I don't know if there are better solutions or if it is unusual to use
methods for concrete queries.
Kind regards
Thomas
18 years
LHS reuse?
by Barry Kaplan
I have a set of rules that /all/ contain the following condition...
positionQuantityAllocatedToLegs :
Integer(intValue < position.quantity)
from accumulate( StrategyLeg(priority > 1, instrument == equity,
longShort ==
LongShort.LONG, legQuantity : quantity )
legsQuantity(legQuantity) )
...the only difference being the values for the StrategyLeg.
It would be very nice if there was some way to create reusable LHS
constructs, say maybe something like:
positionQuantityAllocatedToLegs : legsAllocation(1, position.quantity,
LongShort.LONG)
Where 'legsAllocation' is replaced with the condition above. Is there such a
mechanism, or need I simply live with large amounts of duplication in my
LHS?
thanks!
--
View this message in context: http://www.nabble.com/LHS-reuse--tp17986260p17986260.html
Sent from the drools - user mailing list archive at Nabble.com.
18 years
RuleFlow Groups and retraction
by Markus Helbig
Hi,
one question about using ruleflows:
1. i have a ruleflow consisting of 2 Nodes
2. i insert 2 facts
3. the 2 facts match the condition in rule for the second node, so
when inserting an activation is generated
4. but the rule in the first node will retract one of the 2 facts
5. it seems the activation for the second node is not cancelled also i
do a retract in the rule
6. now the activation in second node tries to execute and results in a
NullpointerException
What do i do wrong?
Cheers
Markus
18 years
Is there a way to preventing the Agenda to not match against ALL rules when inserting a fact object
by Amit Mhatre
Hi,
I am migrating one of my projects to using the drools rule-flow. I have a
bunch of RuleFlowGroups and just 1 fact object (where I am iterating over an
external list and hence I execute the RuleFlow tens of thousands times,
inserting a new fact object for each element in my list). Each RuleFlowGroup
is a logical set of rules that would set a certain variable in the
FactObject and eventually after the flow is executed, the last RuleFlowGroup
will return the outcome based on the variable set by the previous
RuleFlowGroups. I am using a statelessSession.
The problem I am facing is that when I insert the FactObject into the
workingMemory - then the data points needed by ALL the rules across ALL the
RuleFlowGroups are gathered, i.e. the getter beans for all variables used
across all the RuleFlowGroups are invoked. The activations take place
according to the ruleFlow, but the data is gathered for all the rules
(though my flow might not reach certain groups).
The thing is, this behavior is not ideal for the task I am working with,
since some of the data points are pretty expensive to be gathered (requiring
expensive queries to be executed). What I'd ideally like is that the data be
gathered only for one RuleFlowGroup at a time, since my rules are structured
such a way that only a fraction of the evaluations should actually need the
expensive data points. The data be gathered for the rules in a ruleFlowGroup
only when that group is active. I understand that this might take a hit for
the efficiency of the matching algorithm, but it would be ideal for my task.
I've dug through the documentation for AgendaGroups, SequentialMode etc,
but nothing seems to be working for me.
Has somebody faced a similar problem? Could somebody point me in the
direction I should be following to resolve this? Any help would be greatly
appreciated.
Thanks,
- am
18 years