Nested Rules
by Vishal Deshmukh
Hi
I am using Drools 4.0.4 with Eclipse 3.2. I m much happy with the results. But now my application needs nested loops..
Can i write nested rules like
rule "rule 1 " // if condition of rule 1 is true then only execute rule 2 other wise skip it
when
condition is true
then
execute rule2
rule "rule 2 "
when
condition is true
then
action
rule "rule 3"
when
condition is true
then
action
Thanks and Rgards
Vishal
16 years, 1 month
Writing rules using java..
by Kolla, Sandeep
Hi Rahul,
Its not about storing the whole file into the database.
I would have a Table representing the parameteres required to construct
a rule.
For example.
Tables:
RuleSetTable:
Ruleset_id
Ruleset_name
RuleTable:
Rule_id
Rule_name
Rule_saliance
Rule_condition
Rule_consequence
Ruleset_id
Now while loading the rules the application basically should read from
the DB, and construct the rules, as everything required to construct the
rules is avaliable in the tables.
This requirement had come up because as the rules keep changing quite
frequently, we don't want to bring down the application to load a new
DRL file.
Hope you understood what I want to achieve.
Thanks much,
Sandeep.
16 years, 2 months
activationCancelled() not being executed?
by Fermion
Hi!
I'm using a JTable to display rules that have been activated.
My goal is to have the table display a set of activations ordered by their
salience. The user should then choose which one of them to fire (if you want
to know why, be invited to read the background).
Of course this makes only sense as long as the activations are valid. Rules
whose activation has been cancelled should still be displayed, but in a
different style (like greyed out).
In order to accomplish this, I want to use an implementation of the
AgendaEventListener-interface, implementing the
activationCancelled()-method.
The Listener itself works, as I use the activationCreated()-method to add
the rule as a row to my table (which works fine).
Unfortunately the activationCancelled()-method doesn't seem to be executed
at all!
I assume that I have a fundamental misunderstanding of what should trigger
an activationCancelled() event?
Background: (just if you're curious...)
I'm working as a PhD student in physics at the CERN international
high-energy physics laboratory, for the ATLAS experiment.
As a member of the Detector Control System (DCS) group, I'm going to write
an expert system in order to assist the shift crew with the detector
operation.
The operation of the detector is a difficult task, because more than 70000
parameters (like voltages, currents and temperatures) have to be controlled.
A Finite State Machine (FSM) computes a defined and limited number of states
from the given parameters (like ON, OFF, STANDBY,...).
I'm going to synchronize the expert system application to ERROR states of
the FSM, in order to extract the relevant parameters from the system (as it
would be impossible to feed all parameters into the XPS all the time).
This is handled by quite some control rules that decide which data has to be
requested, released and so on.
Once all necessary data has been received, this might lead to activations of
the (more interesting) user rules.
Those rules have an explanatory character like "The temperature of this XYZ
is too high, so please try ABC."
For a given set of facts I assume more then one rule to be activated. Whilst
the rule engine should take care of the execution (firing) of all control
related rules, the execution of the user rules should be under direct user
control.
Displaying all activations in a GUI will allow the user to pick one (try it)
and rate it (the proposed solution solved the problem "yes/no"). Changing
the rules salience according to the answer, will allow the system to
dynamically reflect the current system status. (Rules that are related to
broken connections / wrongly connected cables are likely to be found at the
beginning of the experiment but hopefully only on rare occasion later on.)
In order to ensure that no information is lost during the absence of DCS
experts (which will not always be around), a log file should be written for
each major FSM-ERROR. At the moment the WorkingMemoryFileLogger seems to be
predestined for this job. This way I hope to collect large amounts of ERROR
data during the initial phase of the experiment that helps to extract rules
for numerous error conditions.
This will become especially handy, as such errors have a tendency to come
back, even if the original detector experts are gone for years...
--
View this message in context: http://www.nabble.com/activationCancelled%28%29-not-being-executed--tf434...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 3 months
Can drools work in multithreaded environment?
by Barath
Hi,
While doing a load test with jmeter,my web service application with drools
works fine for few clients(5 simultaneous hits for 10 times)
but when i increase my clients(120 simultanious hits for 100 times) i am
gettin the following exception for
few client, (out of 12,000 hits 200 throws this exception)
problem encountered at node [11] 5{170,189}: unable to resolve property:
null pointer exception in property: declr.identifier
org.mvel.TemplateInterpreter.execute(TemplateInterpreter.java:528)
org.mvel.TemplateInterpreter.parse(TemplateInterpreter.java:341)
org.drools.rule.builder.dialect.java.AbstractJavaBuilder.generatTemplates(AbstractJavaBuilder.java:113)
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:95)
org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
com.drools.util.RuleEngine.applyRule(RuleEngine.java:47)
com.drools.util.DroolsController.getAdvertisement(DroolsController.java:94)
com.drools.util.DroolsController.routeBusinessMethod(DroolsController.java:67)
com.drools.util.DroolsController.getAdvertisement(DroolsController.java:43)
com.drools.MyEndpoint.getAdvertisement(MyEndpoint.java:237)
com.drools.MyEndpoint.process(MyEndpoint.java:144)
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:595)
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
java.lang.Thread.run(Thread.java:619)
drl file has 6 rules,
5 rules - which retract facts which passes the rule.
1 rule(low salience) - will add the fact to java.util.List (set as global)
which passes the rule.
1 . Am i getting this error bcoz of the global list? or any other reason?
2 . How to solve this problem?
here the rules,
<code>
global java.util.List feasibleAdv;
rule " percentage rule "
when
$adv : Advertisement( percentageLimit != 0 , percentageLimit <
playedPercentage )
then
System.out.println("remove this adv (failed percentage):
"+$adv.getAdvertisementID());
retract($adv);
end
rule "per day rule"
when
$adv : Advertisement( limitperday != 0 , limitperday <= playedperday
)
then
//System.out.println("remove this adv (failed day):
"+$adv.getAdvertisementID());
retract($adv);
end
rule "per week rule"
when
$adv : Advertisement( limitperweek != 0 , limitperweek <=
playedperweek)
then
//System.out.println("remove this adv (failed week):
"+$adv.getAdvertisementID());
retract($adv);
end
rule "per month rule"
when
$adv : Advertisement( limitpermonth != 0 , limitpermonth <=
playedpermonth)
then
//System.out.println("remove this adv (failed month) :
"+$adv.getAdvertisementID());
retract($adv);
end
rule "total played rule"
when
$adv : Advertisement( totallimit != 0 , totallimit <= totalplayed )
then
//System.out.println("remove this adv (failed total played) :
"+$adv.getAdvertisementID());
retract($adv);
end
rule "advertisement select rule"
salience -1
when
$adv : Advertisement( $playedPercentPerAdvertisement :
playedPercentPerAdvertisement)
not( Advertisement( playedPercentPerAdvertisement <
$playedPercentPerAdvertisement ) )
$advertisementCount : Integer()
then
boolean status = true;
if($advertisementCount-1 < 0){
//System.out.println("halted");
status = false;
drools.halt();
}
if(status){
feasibleAdv.add($adv);
drools.update(
drools.getWorkingMemory().getFactHandle($advertisementCount), new
Integer($advertisementCount-1) );
retract($adv);
}
end
</code>
--
View this message in context: http://www.nabble.com/Can-drools-work-in-multithreaded-environment--tp170...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 3 months
Re: Ruleflow-group attribute causing rule to not fire
by Roger Tanuatmadja
> From: "Roger Tanuatmadja" <rogerst(a)gmail.com>
> To: rules-users(a)lists.jboss.org
> Date: Mon, 19 May 2008 11:55:19 -0700
> Subject: Ruleflow-group attribute causing rule to not fire
> Hi,
>
> I am new to both rules engine and Drools. I am currently evaluating Drools
> 4.0.7 for use in our new project.
> Basically I have been writing a bunch of individual rules and things have
> been fine, the rules that I expected to fire were fired, etc, etc. I then
> proceeded to investigate rule flows. I started innocently enough i.e. adding
> the ruleflow-group attribute to some of my rules. I also defined a ruleflow
> mapping (.rfm).
>
> I then reran my unit-tests (WITHOUT reading the rules in as rule flows) and
> some of my rules were no longer firing!!. I added an Agenda Listener to my
> code and
> 1. without the ruleflow-group attribute, activations were created, and
> fired.
> 2. with the ruleflow-group attribute, activations were created but not
> fired.
>
> Using the debugger yielded the same logical outcomes i.e. without the
> ruleflow-group attribute, my breakpoints were hit, but with the attribute
> specified, none of my breakpoints were hit.
>
> My question is: Is this behavior expected? And why? Especially since some
> other rules (with the attribute specified) continued to work. I've read the
> documentations as much as possible, but I am really new to this field so I
> might not even know what questions to ask either.
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Roger
>
>
>
>
16 years, 3 months
Drools 4.0.4 and Jboss 4.2.2 GA
by Ojwang Wilson O
All,
I am having the following error when deploying drools 4.0.4 within JBOSS
4.2.2 GA. Please help.
====================
01:06,259 INFO [STDOUT] ERROR 17-03 17:01:06,248
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:06,318 INFO [STDOUT] ERROR 17-03 17:01:06,316
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:06,348 INFO [STDOUT] ERROR 17-03 17:01:06,347
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:06,477 INFO [STDOUT] ERROR 17-03 17:01:06,476
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:06,506 INFO [STDOUT] ERROR 17-03 17:01:06,506
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:06,523 INFO [STDOUT] ERROR 17-03 17:01:06,522
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:06,649 INFO [STDOUT] ERROR 17-03 17:01:06,648
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:06,660 INFO [STDOUT] ERROR 17-03 17:01:06,659
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:06,935 INFO [STDOUT] ERROR 17-03 17:01:06,934
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:08,065 INFO [STDOUT] ERROR 17-03 17:01:08,064
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:08,243 INFO [STDOUT] ERROR 17-03 17:01:08,242
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:01:08,994 INFO [STDOUT] ERROR 17-03 17:01:08,993
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:19:33,956 INFO [STDOUT] ERROR 17-03 17:19:33,956
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:19:33,988 INFO [STDOUT] ERROR 17-03 17:19:33,987
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:19:34,039 INFO [STDOUT] INFO 17-03 17:19:34,038
(SecurityServiceImpl.java:login:45) Logging in user [wojwang]
17:19:34,048 INFO [STDOUT] INFO 17-03 17:19:34,047
(DefaultAuthenticator.java:authenticate:38) User logged in via
default authentication module (no security check).
17:19:34,068 INFO [STDOUT] ERROR 17-03 17:19:34,067
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
17:24:34,104 INFO [STDOUT] ERROR 17-03 17:24:34,102
(Contexts.java:flushAndDestroyContexts:335) could not discover
transaction status
===================
Regards
Wilson
16 years, 6 months
RE: Rules with Lookup Tables...
by Rahul Phadnis
Have you looked at
http://labs.jboss.com/portal/jbossrules/subversion.html
I think that page is not uptodate since at the bottom
it says "Trunk is unstable and may often not build. If
you wish to build form Subversion source the latest
tag is:
http://anonsvn.labs.jboss.com/labs/jbossrules/tags/3.0.3-GA/
"
Are n't we at 3.0.5 already?
-Rahul
--- jjdepaul(a)us.ibm.com wrote:
> Rahul -
>
> Where can I find Maven2 repository that has the
> nightly builds for Drools project?! I've looked
> around on a couple of well-known ones abut no luck
> finding anything above D3.0.5
>
> thanks,
> james
> >
> > The "from" CE (conditional expression) is not
> > available in the current released jboss rules
> version
> > (3.0.5) and you probably have to use the nightly
> build
> > to use it.
> >
> > -Rahul
> >
> >
>
>
16 years, 6 months
Updating an existing fact w/o using fact handle
by Fenderbosch, Eric
Is it required to use WorkingMemory.update to update an existing fact?
I thought if assert behavior was set to equality and you implemented the
equals method properly, then you could simply use WorkingMemory.insert
to overwrite a fact in working memory with a new version. If this isn't
the case, then are there other settings that will give this behavior?
I'm using 4.0.7.
Thanks for any help.
Eric
Here's my RuleBaseConfiguration:
AlphaNodeHashingThreshold : 3
CompositeKeyDepth : 3
ExecutorServiceorg.drools.concurrent.DefaultExecutorService
RuleBaseUpdateHandler :
org.drools.base.FireAllRulesRuleBaseUpdateListener
AgendaGroupFactory :
org.drools.common.PriorityQueueAgendaGroupFactory@17653ae
AssertBehaviour : equality
ConflictResolver : org.drools.conflict.DepthConflictResolver@16fe0f4
ConsequenceExceptionHandler :
org.drools.base.DefaultConsequenceExceptionHandler@19d0a1
LogicalOverride : discard
SequentialAgenda : sequential
AlphaMemory : false
IndexLeftBetaMemory : true
IndexRightBetaMemory : true
MaintainTms : true
RemoveIdenities : true
Sequential : false
ShadowProxy : true
ShareAlphaNodes : true
ShareBetaNodes : true
UseStaticObjensis : false
My TestFact class:
public class TestFact {
private String id;
private String value;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public int hashCode() {
return id.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof TestFact)) return false;
TestFact other = (TestFact) obj;
// not null safe, i know
return this.id.equals(other.id);
}
}
And the JUnit Test Case that fails:
public void testFactUpdate() throws Exception {
TestFact testFact = new TestFact();
testFact.setId("1234");
testFact.setValue("old");
FactHandle testFactHandle =
workingMemory.insert(testFact);
TestFact updatedFact = new TestFact();
updatedFact.setId("1234");
updatedFact.setValue("new");
FactHandle updatedFactHandle =
workingMemory.insert(updatedFact);
// using workingMemory.update here works
// passes
assertTrue(testFactHandle == updatedFactHandle);
TestFact retrievedTestFact = (TestFact)
workingMemory.getObject(testFactHandle);
// fails
assertEquals("new", retrievedTestFact.getValue());
}
16 years, 6 months