Rule looping question
by Glenn Macgregor
Hi All,
I am in the process of creating some rules for a POC I am doing using drools, having some issues understanding why I have an infinite loop in a rule.
Rule in question:
rule "Check Parameter Threshold Update Breach"
no-loop true
when
ParameterUpdateEvent($name : name)
from entry-point "ParamUpdateStream"
$param : Parameter(name == $name)
Number($averageUpdateValue : doubleValue)
from accumulate(ParameterUpdateEvent(name == $param.name, $value : value)
over window:time(15m)
from entry-point "ParamUpdateStream", average($value))
$tholdBreach : Parameter.Threshold(windowSize == 15,
threshold >= $averageUpdateValue) from $param.thresholds
$firedAlert : AlertInformation(name == $param.name,
severity != $tholdBreach.severity)
then
System.out.println("Updating alert from '" + $firedAlert.getSeverity() +
"' to '" + $tholdBreach.getSeverity() +
"' alarm: Average update value for " +
$param.getName() + " = " + $averageUpdateValue);
$firedAlert.setSeverity($tholdBreach.getSeverity());
update($firedAlert);
//insert(new AlertInformation($param.getName(), $tholdBreach.getSeverity()));
//modify($firedAlert);
end
I understand what is happening up to the $tholdBreach : Parameter.Threshold line. Each Parameter can have a list of thresholds and what I want this line to do is pick the correct threshold if any are breached. For instance Param1 has 2 thresholds: MINOR and CRITICAL, the MINOR threshold should fire if averageUpdateValue is >= 50, the CRITICAL threshold should fire if averageUpdateValue is >= 40. The first problem I need to solve (in a better way) is getting the correct threshold out of this, the way I do it now is but putting the MINOR threshold in the list before the CRITICAL one. This means that it will be checked first from the line in question. This, to me, is not a good solution. Is there a more deterministic way to do this, I was thinking of somehow using the difference between the threshold and the averageUpdateValue to get the right now but I don't see how that can work from a rule stand point.
The other question I have is this rule loops infinitely when the averageUpdateValue is below 40 (CRITICAL threshold) between a MINOR alarm and a CRITICAL alarm and I don't see why or how because tholdBreach should always be the CRITICAL alarm and the rule would stop on the next line, but it is alernatly returning CRITICAL then MINOR which is confusing. To confuse this even more when I comment out the update($firedAlert) and replace that with a retract($firedAlert) and insert(new ...) it does not loop.
Any ideas would be great.
Thanks
Glenn
16 years
Template rules & eval
by Bertrand Grottier
Hello,
I want to use template rules. Here is my .drt file:
template header
ddeb
dfin
prix
package com.tarification
import java.util.Date ;
import tarification.Produit ;
import java.text.SimpleDateFormat;
function Date getDate(String pStrDate)
{
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
return sdf.parse(pStrDate) ;
}
template "tarification_produit"
rule "Periode(a){row.rowNumber}"
when
$p : Produit(id == 1, eval( dDeb.before( getDate("@{ddeb}") ) ) )
then
$p.setId(2) ;
$p.setPrix(@{prix}) ;
update( $p );
end
end template
I modified an example provided with Drools but encounter the following exception:
Exception in thread "main" org.drools.RuntimeDroolsException: Exception executing predicate com.tarification.Rule_Periode2_0Predicate0Invoker@2110b61d
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:279)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:143)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:147)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at tarification.TestTemplate.executeExample(TestTemplate.java:49)
at tarification.TestTemplate.main(TestTemplate.java:26)
Caused by: java.lang.NullPointerException
at com.tarification.Rule_Periode2_0.predicate0(Rule_Periode2_0.java:9)
at com.tarification.Rule_Periode2_0Predicate0Invoker.evaluate(Rule_Periode2_0Predicate0Invoker.java:23)
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:272)
... 11 more
I am puzzle because when I copy the drl generated string in a drl file, everything works fine.
Any idea ? Thank you in advance.
Regards,
Benoît
_________________________________________________________________
Hotmail et MSN dans la poche? HOTMAIL et MSN sont dispo gratuitement sur votre téléphone!
http://www.messengersurvotremobile.com/?d=Hotmail
16 years
Loading facts by xml
by Bertrand Grottier
Hello,
I keep trying loading facts by xml based on "Example 3.37. Constructing a pipeline".
Now, I encounter a java.lang.RuntimeException when inserting the fact in the working memory:
com.thoughtworks.xstream.mapper.CannotResolveClassException: Produit : Produit
It guess it comes from the definition of my xml file. In the example, a reference to path/facts.xml is mentionned but I could not found this file. I would like to see an example.
Where is it ?
Otherwise can someone provide me with an other example ?
Regards,
Benoît
_________________________________________________________________
Découvrez comment SURFER DISCRETEMENT sur un site de rencontres !
http://clk.atdmt.com/FRM/go/206608211/direct/01/
16 years
gwt-console-drools - link 2 download
by ramram
Hi All,
I am trying to download the source code of the "gwt-console-drools" but I
couldn't find the source code for it. All what I want is to add a button to
the UI of the drools so that I could apply a new functionality.
Can someone help and give me the link of the source code of the
"gwt-console-drools" I already have the war file but I need the source code.
Thnx for the help.
Regards,
Ram
--
View this message in context: http://n3.nabble.com/gwt-console-drools-link-2-download-tp428289p428289.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years
Inferencing
by Tim de Jager
Hi everybody,
I'm currently doing my bachelor thesis on Rule engines. This includes
comapring different Rule engine products. I have set up a small Java program
(Conway's game of life) and I'm writing the 'engine' in different Rule
engines, while keeping the same GUI,CellGrid etc. I have already made a
Drools based engine.
I have been studying the Rule engine subject for somewhat more then a month
now. And I'm currently seeing two different developments namely the use of
an inference engine and the generation of embedded code instead (Take,
Visual Rules etc.) I can see some of the pro's and cons with both
paradigms. But I'm wondering what opinion some of you guys have on the
subject.
I can see that without inferencing it is very hard (or even impossible) to
keep a statefull session inside the rule engine, haven't seen a
non-inferencing rule engine which does offer this possibility. And also lose
features like TMS. But what would be a concrete example where a statefull
session is absolutely necessary? Instead of letting the engine reason over
all the facts in stateless way. And managing conflicts with a ruleflow (see
Visual Rules for a nice example).
I'm looking forward to hearing your thoughts.
Thanks,
Tim
P.S I already read two of Mark Proctors blogs on inferencing, but while
enlightening, they didn't supply me with a definitive awnser
--
View this message in context: http://n3.nabble.com/Inferencing-tp435411p435411.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years
XStream
by Bertrand Grottier
Hello,
My general aim is to load facts from a xml file.
I tried to modify an example furnished in the documentation (Example 3.37. Constructing a pipeline).
I get an exception on the following line:
Transformer transformer = PipelineFactory.newXStreamFromXmlTransformer( xstream );
The message is the following:
org.drools.ProviderInitializationException: Provider org.drools.runtime.pipeline.impl.XStreamTransformerProviderImpl could not be set.
Am I going in the right direction ? (I am a newbie)
If yes, have you got an explanation for my problem.
Otherwise, what is the simplest way to achieve my goal ?
Thank you in advance for your help.
Regards,
Benoît
PS : I am using Drools 5.0
_________________________________________________________________
Découvrez comment SURFER DISCRETEMENT sur un site de rencontres !
http://clk.atdmt.com/FRM/go/206608211/direct/01/
16 years
Guvnor - Test Scenario
by Amit Kumar
Hello,
In test scenario building in guvnor we cannot add refrence relation in
model.
The fact model we have is
Table
color
shape
Legs Collection<Leg>
Leg
material
color
So this object cannot be added there in guvnor.
Do we have some functionality in guvnor or eclipse where we can build test
scenarios for this.
Do we still have FIT in the raw form somewhere which can be utilized
seperately.
Thanks
Amit
16 years
ClassCastException when debugging as a drools unit test with a ruleflow
by H.C.
Hi,
I have a unit test written which tests my rules. In my setup, I am loading
my drl and rf files via a changeset into an agent and getting my knowledge
base. The test then sets globals and facts on my stateful session and
execute my ruleflow. I can execute this unit test in JUnit and debug. My drl
and rf files build ok and I can step through my java breakpoints.
However, when I execute the very same Junit test using debug as Drools Junit
Test, I get the following exception when the knowledge agent is building my
drl and rf files in my junit setup.
The only difference between the two scenarios is that I am using the debug
as Drools Unit Test in the exception scenario and plain debug as junit test
in the first. I make no configuration or code changes.
java.lang.ClassCastException: org.drools.workflow.core.node.RuleSetNode
cannot be cast to org.drools.workflow.core.node.StateBasedNode
at
org.drools.process.builder.EventBasedNodeBuilder.build(EventBasedNodeBuilder.java:21)
at org.drools.compiler.ProcessBuilder.processNodes(ProcessBuilder.java:185)
at org.drools.compiler.ProcessBuilder.buildNodes(ProcessBuilder.java:171)
at org.drools.compiler.ProcessBuilder.buildProcess(ProcessBuilder.java:139)
at
org.drools.compiler.ProcessBuilder.addProcessFromFile(ProcessBuilder.java:222)
at
org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.java:448)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:504)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:386)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:120)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:109)
at com.ac.logistics.usps.IQ.UspsIQEngine.<init>(UspsIQEngine.java:21)
at
com.ac.logistics.usps.transformation.UspsRateRequestTransformer.<init>(UspsRateRequestTransformer.java:25)
at
com.ac.logistics.usps.transformation.TestUspsRateRequestTransformer.setUp(TestUspsRateRequestTransformer.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
--
View this message in context: http://n3.nabble.com/ClassCastException-when-debugging-as-a-drools-unit-t...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years
Converting from Java to MVEL dialect
by Boardman, Dave
We are experiencing permgen space issues in our test environment and we have decided to convert our rules from the java dialect to MVEL. I'm wondering if anybody knows of a reference that describes the syntactic differences between the two dialects and what steps we need to take in order to convert. For example, a small number of our rules have conditional statements in the right-hand side and we will need to rewrite these I believe.
Thanks in advance,
Dave
16 years
Inheritance-Like Design Question
by malkhafaji
Hello,
I know, from searching this forum and posting before, that the concept of
inheritance does not exist today in Drools. However, I have a need for it.
Here is my specific situation:
I have certain rules that have some generic conditions to be fired:
Rule 1
If A Then X end
Rule 2
If A, B Then Y end
What I would like to do is, if Rule 2 is true, then I don't want Rule 1 to
execute. I have many and many of those rules, so combining all the
conditions in less number of rules violates our design having rules being
mutually exclusive. That is why I wanted to include this behavior as a
natural inheritance behavior rather than forcing the flow with logic inside
the rule itself (you will make rules aware of others this way).
So, since there is not built-in feature that allows you to do that, do
people suggest anything that I can do without having to mix Rule 1 and Rule
2 into one rule with complex conditional statements? Any ideas?
The only thing I can think of is taking this logic processing outside of
drools, which is something that I am not too excited about.
Thanks.
--
View this message in context: http://n3.nabble.com/Inheritance-Like-Design-Question-tp430848p430848.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years