Drools Accumulate function
by lyally
Hi,
I am new to Drools so please excuse me if this is a simple question.
I currently have several rules that look as follows (one for each entry
point):
The intention of these rules is to average the speed, occupancy and flow of
traffic at a particular road location over a 30 second sliding window. The
rule works fine as it is, however it is not very scalable since I currently
need a similiar rule and associated input stream for each road location that
I am monitoring. There may be 100s of these.
What I was really after was one rule that would perform the same averaging
calculations over the 30 second window. My first thoughts were that I would
need to lose the individuall input streams per location and thereby place
all of the TrafficData facts from all locations into working memory. But
then I was unsure how I would change the rule to group relevant TrafficData
instances by their location (Note that the TrafficData instance has a
location identifier within it) together before doing the averaging.
Any assistance would be much appreciated.
Regards,
Steve
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Accumulate-function-tp4023718.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Restricting the items included in a snapshot
by Lance Leverich
I am aware of how Guvnor can be told to only include assets with a given
state, during the build process. What I haven't been able to figure out is
a way to tell Guvnor to only include the items that were part of the latest
build, when creating a snapshot. Is there a way to do this? I am using
Guvnor 5.3.5.Final.
~ Lance
12 years, 10 months
How to find rules, that use special fields in their Condition
by mdzaebel
Hi,
the following code traverses rules and their conditions. However, I did not
find a method to find conditions, that match over a certain field of a
declared class. I know, that the rule API should be hidden for good reasons
(Mark Proctor).
for(Rule ruleDef : kb.getKnowledgePackages().iterator().next().getRules()) {
for(RuleConditionElement rce :
((RuleImpl)ruleDef).getRule().getLhs().getChildren()) {
for(Map.Entry<String, Declaration> entry :
rce.getInnerDeclarations().entrySet()) {
??
Thanks, Marc
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-find-rules-that-use-special-fiel...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Ways to list the globals
by Sonata
Hi, I am trying to list out the globals but I am confused, please help.
I wrote this line in my drl file
((MapGlobalResolver)drools.getKnowledgeRuntime().getGlobals()).getGlobals()
this gives me ONLY the globals that I have added in drl through
drools.getWorkingMemory().setGlobal()
this does not list out the globals that I have added in java before firing
the rules.
Then I tried this line in my drl file
drools.getKnowledgeRuntime().getKnowledgeBase().getKnowledgePackages().getGlobalVariables()
this gives me BOTH the globals that I have added in drl through
drools.getWorkingMemory().setGlobal()
AND the globals that I have added in java before firing the rules.
My question is, to list the useable globals in the current rule, what is the
correct method call?
Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/Ways-to-list-the-globals-tp4023616.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Drools 5.5 run time exception from the library code but no impact to the rule evaluation result
by Sean Su
Just want to put the exception out here in case it is meaningful to the
development or whoever ran into this before. It occurred but does not
impact the result of the process.
Exception in thread "Thread-6" java.lang.NullPointerException
at java.lang.String.<init>(String.java:210)
at org.mvel2.ast.ASTNode.toString(ASTNode.java:426)
at org.mvel2.ast.Or.toString(Or.java:59)
at java.lang.String.valueOf(String.java:2826)
at java.lang.StringBuilder.append(StringBuilder.java:115)
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeNode(ConditionAnalyzer.java:247)
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeSingleCondition(ConditionAnalyzer.java:106)
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeCondition(ConditionAnalyzer.java:99)
at
org.drools.rule.constraint.ConditionAnalyzer.analyzeCondition(ConditionAnalyzer.java:70)
at
org.drools.rule.constraint.MvelConditionEvaluator.getAnalyzedCondition(MvelConditionEvaluator.java:83)
at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:270)
at
org.drools.rule.constraint.MvelConstraint.access$200(MvelConstraint.java:51)
at
org.drools.rule.constraint.MvelConstraint$ConditionJitter.run(MvelConstraint.java:250)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Sean
12 years, 10 months
Consequence Exception with too many events
by Jason Barto
I am new to Drools (Expert and Fusion) and have been reading through the
materials over the last few days. After going through some of the tutorial
code I wrote a very quick and dirty to perform a base assessment of the
speed of Fusion / Expert. My code is below. The strange thing I'm
currently receiving is, if I insert 100k events the test completes
successfully, if I insert 150k events, I receive a ConsequenceException
caused by an NPE. Being new to Drools I must be doing something wrong, can
anyone please provide some guidance?
(Main function)
Counter cc = new Counter ();
session.insert (cc);
for (int i = 0; i < 150000; i++) {
entryPoint01.insert (new MyEvent ());
}
(Counter Class)
public class Counter {
private long total = 0;
// get / set total
public void addValue (int val) {
total += val;
}
}
(MyEvent Class)
public class MyEvent {
private int value = 1;
// get / set value
}
(DRL file)
declare MyEvent
@role (event)
@expires (1s)
end
rule "Count the rules"
when
$ev : MyEvent () from entry-point entryPoint01
$pc : Counter ()
then
$cc.addValue ($ev.getValue ());
end
12 years, 10 months
Camel get ksession results
by mauro
Hi,
I'm using Drools integration with Camel and have to be able to get the
objects that were validated by a rule in a stateless ksession later in the
Camel route.
My camel-server.xml has something similar to this:
<policy ref="droolsPolicy">
<bean ref="createList" />
<to uri="drools:node1/ksession1" />
<bean ref="afterRules" />
</policy>
in the "createList" bean I create a list of java objects and call
CommandFactory.newBatchExecution(commandList);
My Drools rule responds as expected. So far so good.
But then later when execution reaches "afterRules" bean, the exchange body
has empty lists for both "facts" and "results".
What I want at this point is to be able to get all the objects which were
compatible with the rule (a simple sysout). The ones that didn't match the
rule, are simply disposed.
How can I solve that?
Drools v5.5.0 Final
Camel 2.10.4
Thanks!
Mauro
--
View this message in context: http://drools.46999.n3.nabble.com/Camel-get-ksession-results-tp4023670.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months