Does window:length work in Drools version 5.1.1 ?
by eskomk
Drools-expert 5.1.1
Does window:length work in Drools version 5.1.1 ?
It seems that "over window:length( 5 )" in rule "PossibleFFF_launch_level1"
does not work.
It seems that it returns only the last MMMBean added in trackers in rules
"PossibleFFF_Level1_update_tracker_count" and
"PossibleFFF_Level2_update_tracker_count".
The idea here is that trackers keep count of how many MMMBeans have entered
the system, after incoming BBBBean with bbbEmpty == true have initiated the
tracking (PossibleFFF).
App domain specific operations are launched if there is no active counts
(actCount) in a series of MMMBeans ("PossibleFFF_launch_level1" and
"PossibleFFF_launch_level2").
actCount is an integer but accumulate function sum apparently returns a
floating point number, hence the check "doubleValue < 0.5".
Rules "PossibleFFF_kill_tracker_with_bbb" and
"PossibleFFF_kill_tracker_with_count" are to retract the trackers from
memory, so ending the tracking.
Rule "PossibleFFF_kill_tracker_with_bbb" kills this profileID's tracker if
bbbEmpty == false.
Rule "PossibleFFF_kill_tracker_with_count" kills tracker if count > 5, count
indicating that no operations were launched ("PossibleFFF_launch_level1" and
"PossibleFFF_launch_level2").
Problem is, that the condition
$theSum : Number(doubleValue < 0.5) from accumulate(
// MMMBean( $actCount : activeCount) over window:length( 5 ) from
$tracker.mdsBeanList,
MMMBean( $actCount : activeCount) over window:length( 5 ) from
$tracker.getMdsBeanList(),
sum( $actCount ) )
in rules
"PossibleFFF_launch_level1" and "PossibleFFF_launch_level2"
does not seem to work as expected.
I expected that the sum would be calculated from field MMMBean.actCount over
all MMMBean members of list $tracker.mdsBeanList.
It seems that sum returns only the actCount of last MMMBean which was
inserted in $tracker.mdsBeanList.
Is there something wrong with the rules ?
Rules are like these:
// RULES -->
rule "PossibleFFF" dialect "mvel"
when
$bsb : BBBBean(bbbEmpty == true)
not FFFTracker(profileID == $bsb.profileID)
then
FFFTracker $tracker = new FFFTracker();
$tracker.level = 1;
$tracker.count = 0;
$tracker.profileID = $bsb.profileID;
$tracker.location = $bsb.location;
retract($bsb);
$tracker.sensorBean = $bsb;
insert($tracker);
end
rule "PossibleFFF_Level1_update_tracker_count" dialect "mvel"
when
$tracker : FFFTracker(level == 1)
$mds : MMMBean(profileID == $tracker.profileID, this after $tracker)
then
drools.retract($mds);
$tracker.addMdsBean($mds);
$tracker.count = $tracker.count + 1;
drools.update($tracker);
end
rule "PossibleFFF_launch_level1" dialect "mvel"
when
$tracker : FFFTracker(level == 1, count == 5, $prof : profileID)
$theSum : Number(doubleValue < 0.5) from accumulate(
// MMMBean( $actCount : activeCount) over window:length( 5 ) from
$tracker.mdsBeanList,
MMMBean( $actCount : activeCount) over window:length( 5 ) from
$tracker.getMdsBeanList(),
sum( $actCount ) )
then
retract($tracker);
FFFTracker $tracker2 = new FFFTracker();
$tracker2.level = 2;
$tracker2.profileID = $tracker.profileID;
$tracker2.location = $tracker.location;
$tracker2.sensorBean = $tracker.sensorBean;
$tracker2.count = 0;
// Tracker2 is set to track further conditions
insert($tracker2);
// launch the app domain specific things
end
rule "PossibleFFF_Level2_update_tracker_count" dialect "mvel"
when
$tracker : FFFTracker(level == 2)
$mds : MMMBean(profileID == $tracker.profileID, this after $tracker)
then
drools.retract($mds);
$tracker.addMdsBean($mds);
$tracker.count = $tracker.count + 1;
drools.update($tracker);
end
rule "PossibleFFF_launch_level2" dialect "mvel"
when
$tracker : FFFTracker(level == 2, count == 5, $prof : profileID)
$theSum : Number(doubleValue < 0.5) from accumulate(
// MMMBean( $actCount : activeCount, profileID == $prof) over
window:length( 5 ) from $tracker.mdsBeanList,
MMMBean( $actCount : activeCount, profileID == $prof) over
window:length( 5 ) from $tracker.getMdsBeanList(),
sum( $actCount ) )
then
retract($tracker);
// launch the app domain specific things
end
rule "PossibleFFF_kill_tracker_with_bbb" dialect "mvel"
when
$tracker : FFFTracker($prof : profileID, $loc : location)
$bsb : BBBBean(profileID == $prof, location == $loc, bbbEmpty == false,
this after $tracker)
then
retract($tracker);
end
rule "PossibleFFF_kill_tracker_with_count" dialect "mvel"
when
$tracker : FFFTracker(count > 5, $prof : profileID)
then
retract($tracker);
end
// <-- RULES
BBBBean, MMMBean, FFFTracker are declared as events.
class FFFTracker:
public class FFFTracker extends Tracker
{
private ArrayList<MMMMBean> mdsBeanList = new ArrayList<MMMMBean>();
public ArrayList<MMMBean> getMdsBeanList()
{
return mdsBeanList;
}
public void setMdsBeanList(ArrayList<MMMBean> pmdsbeanlist)
{
this.mdsBeanList = pmdsbeanlist;
}
public void addMdsBean(MMMBean pbean)
{
this.mdsBeanList.add(pbean);
}
}
class Tracker:
public class Tracker
{
private long profileID = 0;
private short location = 0;
private int level = 0;
private int count = 0;
private ASensorBean sensorBean = null; // AsensorBean is an abstract
class from which BBBBean and MMMBean are derived
// getters and setters goes here
}
Best Regards,
Esko
------
Esko Hujanen
www.ebsolut.fi
--
View this message in context: http://drools.46999.n3.nabble.com/Does-window-length-work-in-Drools-versi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 7 months
Drools session reuse question
by arrehman
Is creation of StatefulKnowledgeSession expensive? Is there a guideline or
best practice regarding this?
Currently I am creating a new session /kbase.newStatefulKnowledgeSession()/
each time I want to call /session.fireAllRules()/. I do this for each of the
200,000 data records that I have. So it creates and destroys 200 drools
sessions (monitored via drools JMX bean)
I was trying to reuse the same drools session for each of those 200,000 data
records to see if it improves the performance (don't know if this is frowned
upon or recommended). However this was failing my rules left and right, not
sure why, possibly because I am not cleaning up the session cleanly. I have
been calling /session.dispose() /after every /fireAllRules() /though.
Any thoughts?
Thanks,
Abdul
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-session-reuse-question-tp3466635...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 7 months
Drools Performance /Memory Leak Issue
by arrehman
Hi,
I am not much of an expert on Drools. I got a DRL file (very small rule set
of less than 10 rules, that checks few conditions, also includes DB calls).
I use Drools 5.2 inside a grails application. I am using stateful session. I
call this rules 100,000 times for each for each of the 100,000 records that
I want to validate. However the performance gradually deteriorates. What
could be going on here? General advice on how to approach solving this,
improving performance. Should I be using stateless drools session? How do I
configure the Drools MBeans so I can monitor Drools better?
PS: I can provide more details as you needed. I can paste the general gist
of the code and DRL file. Any help is greatly appreciated. I spent two days
on this with no results.
Thanks,
Abdul
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Performance-Memory-Leak-Issue-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 7 months
Drools 5.3.0 Dependencies
by arrehman
Hi,
I was using drools 5.2.0 in my grails 2.0.0.M2 application. I use Drools
expert to execute a .drl file I have. The three dependencies that I have set
up for this to work was:
runtime 'org.drools:drools-core:5.2.0.Final'
runtime 'org.drools:drools-compiler:5.2.0.Final'
runtime 'com.sun.xml.bind:jaxb-xjc:2.2.4'
However when I switched to drools 5.3.0. The rules are not getting executed
or there are some problems. There is no stacktrace or log. I have no idea
what is going on. My guess is that some of the dependency jars or classes
are missing. Any insight into this?
Thanks,
Abdul
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-3-0-Dependencies-tp3452346p345...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 7 months
Drools command line tools?
by arrehman
Hi,
I am using Drools 5.2 (direclty, not via grails plugins) in a grails
2.0.0.M2 web application. I use IntelliJ IDEA for development which does not
support Drools inherently. (I know eclipse has better support) I am
struggling with the compilations, syntax erros of .DRL file I have in my
app. Are there any command line tools that will help me point out the exact
syntax errors of the DRL file? Currently I am struggling, and doing a adhoc
approach. I know there must be a better way.
Thanks,
Abdul
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-command-line-tools-tp3465973p346...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 7 months
5.3.0 Faster Complation?
by Saleem Lakhani
Hi,
>From documentation of 5.3.0:
2.1.1.4. Faster compilation
Thanks to many improvements and optimizations made on both MVEL library
and Drools internals, the DRL compilation is now at least 3 times faster
for both MVEL and Java dialects.
Does it really affect the runtime execution of already compiled &&
serialized rules in production? Any technical details will help.
Thanks,
saleem
14 years, 8 months
confusing behaviour of enum comparison
by lhorton
5.2.0.Final
I am seeing some confusing behaviour in enum comparisons in LHS rule
conditions. I have an enum class, "Status" (full source below) that is an
attribute on several of our domain objects. I'm comparing the enum in
several ways, and the rule fires differently when I use syntax that AFAIK
ought to have the same result.
for example, say there is a Step with status of Status.PENDING. if I write:
$step : Step(status.active == false) // rule DOES fire
$step : Step(status != Status.ACTIVE) // rule does NOT fire, but should
I am testing this with the same objects and same test each time. can anyone
explain why the two comparisons do not get the same result?
here is the definition of Status:
public enum Status {
PENDING("Pending"),
ACTIVE("Active"),
COMPLETE("Complete");
private final String label;
private Status(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
public boolean isPending(){
return label.equals("Pending");
}
public boolean isActive(){
return label.equals("Active");
}
public boolean isComplete(){
return label.equals("Complete");
}
public static boolean isPending(Status status) {
return (status == null) ? false : status.isPending();
}
public static boolean isActive(Status status) {
return (status == null) ? false : status.isActive();
}
public static boolean isComplete(Status status) {
return (status == null) ? false : status.isComplete();
}
public static Status fromString(String name) {
if (name != null) {
Status types[] = Status.values();
for(Status s : types) {
if (name.equalsIgnoreCase(s.toString())) {
return s;
}
}
}
return null;
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/confusing-behaviour-of-enum-comparison-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
Regression 5.1->5.2 with conflicting ClassNames
by Swindells, Thomas
I'm in the progress of updating from Drools 5.1 to 5.2 in the hope of solving problems we are having with intermittent mysteriously missing activations.
I've found a regression with the compiler which I don't know whether anybody else has noticed before.
In our application we've got two Content classes in different packages, and unfortunately one of our rule files has to reason over both of them.
In drools 5.1 this was fine, we imported one of them and then used the fully qualified name for the other.
I'm just upgrading to 5.2.0-Final and this no longer works. When resolving the unqualified class name drools/mvel(?) was choosing the package that we hadn't imported!
This obviously then gave us loads of misleading error messages about not being able to find fields.
Fully quallifiying all references to both classes fixed the issue but something obviously isn't behaving properly.
Thomas
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
14 years, 8 months
Fwd: "Accumulate and Collect" issue - Guvnor 5.2 Final
by Michael Anstis
---------- Forwarded message ----------
From: <praveen.sanju(a)gmail.com>
Date: 28 October 2011 10:48
Subject: "Accumulate and Collect" issue - Guvnor 5.2 Final
Hi,
We gave a try with 5.2 Final version, and see that all "collect" clauses
appears in grey and are not editable (such conditions are also not
deletable). Everything was OK with the M2 version (rules were edited with
this version).
It is quite strange because all the "collect" condition is greyed, just like
a disabled field, and seems to be done by purpose. Is "collect" deprecated ?
http://drools.46999.n3.nabble.com/rules-users-Guvnor-5-2-CR1-problem-with...
Above Forum link says to import what is required into the package
definition.
Could you please provide a detailed step-by-step procedure to get this
accomplished. Our intention is to get all the Collection types in the Guvnor
UI.
Thanks & Regards,
Praveen.
14 years, 8 months