[rules user] different behavior on double type
by Zeke
Hi, guys:
I am using Drools 4.0.7. I find a strange behavior. When my LHS is
"Message( varDouble == 99.9 )" and "varDouble" equals "new Double(99.9)",
the condition is true. But when my LHS is "Message( types.doubleType ==
99.9 )" and the "doubleType" field is also equal to "new Double(99.9)", the
condition is false. I debug the code, and find that:
When the LHS is "Message( varDouble == 99.9 )", the logic will handle the
literal 99.9 as *Double.valueOf( “99.9” )*, and the comparison is between *(new
Double(99.9)).doubleValue(*) and *Double.valueOf( “99.9” ).doubleValue()*,
When the LHS is "Message( types.doubleType == 99.9 )", the logic is
different from above. The comparison is between *new BigDecimal((Double)
99.9, MathContext.DECIMAL64)* (which double value is 99.90000000000001) and
*new BigDecimal(“99.9”, MathContext.DECIMAL64)* (which double value is
99.9).
I think we need make things consistent. "varDouble" and
"types.doubleType" are of the same type and value. It doesn't make sense to
have different behavior just because of one field is nesting while the
other is not. I know Drools is using MVEL to evaluate the condition. But I
am not sure it is a MVEL bug or Drools uses MVEL wrong. It will be much
appreciated if you can give me any comments!
12 years, 8 months
Possible "memory leak" in 5.3 with update?
by thenim
I'm using a stateful session (in a slightly odd way - obviously this is the
problem), I have a stream of "messages" coming into my system and each
message one of a set of unique keys. Now my rules test various attibutes of
this message and makes some changes (to the messages) etc. (the rules aren't
the problem here - infact in my test case, I have no rules).
I tested the "normal" approach where each message is inserted and the fact
handle retained, and subsequently after firing, the handle is removed (yes
this sounds like a good case for Fusion, except for the making changes bit.)
I noticed that I could get better throughput, if took the following
approach:
1. On the first time the unique key is detected, the handle is saved
2. Then each time a message with that key is received, "update" is called
with the handle for that key
Now, the important thing here is that the "fact" is a *different* object not
an updated version of the original associated with the handle.
Now with this approach, I was getting better numbers, however every so often
there would be a "pause", with GC details being printed out, I see
immediately that it's sitting there doing full GC's very frequently, and
switching to the concurrent collector, I can see mode failures regularly
(i.e. full GCs). With a low message rate, I didn't notice it initially, but
with higher message rates, this is a serious issue.
It appears that the approach I've taken highlights a "leak". I wanted to
find out if others have encountered this before digging around in the code,
for the moment, I will "fix" my approach so that I update the "same object"
- but is "update" not meant to be used this way?
Thanks,
Nim
--
View this message in context: http://drools.46999.n3.nabble.com/Possible-memory-leak-in-5-3-with-update...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
How best to get back the updates that rules perform on declarative fact objects onto the domain objects (Dynamic fact generation with Declarative Fact Model)
by Vidya
Hi,
I am trying to evaluate using Drools in our EDM product. Our domain model is
very generic and complicated to be used as is as the fact model. Also new
domain entities will be added frequently and we would not want to write the
java fact model and supply the jar to the application (which needs
application bouncing...). So we may have to implement dynamic code
generation (using say javaassist).
Now I see that it can be partly achieved with the use of declarative fact
model (which does the dynamic code generation part for us).
But I have these questions -
When the rules fire, any update it makes on the fact needs to be updated
back onto our domain object obviously. Given that the fact model could be
potentially big, we were wondering
- if there can be anyway by which the application can be notified of
updates to the declared fact so we can copu only the changed attributes
backour domain object instead of copying all attributes back
OR
- if there was any way to introduce a dynamic proxy to the declared facts
so that the update (setXXX()) would have been called on the proxy which in
turn could update our domain object directly. As I see, this cannot be done
currently as the declarative facts are concrete classes and do not implement
any interface (its not possible to declare interfaces in drl files)
Is there any other better way to achieve this or should we go for dynamic
code generation in our application itself as mentioned in the beginning and
supply them as facts?
Thanks
Vidya
--
View this message in context: http://drools.46999.n3.nabble.com/How-best-to-get-back-the-updates-that-r...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Drools performance
by Hassan
Hi everyone,
In one of my tests, I inserted 1000000 objects into the working memory,
drools engine made a lot of time to execute the program and it throws
Exception : "java.lang.OutOfMemoryError !!
Please if someone could help me to improve drools performance and specially
reduce the drools execution time
thanks
-----
Youssef AZBAKH.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-performance-tp3870569p3870569.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
ontologies
by Olfa h
hello,
how I can create ontologies with Drools ?
thx
12 years, 9 months
Rule Compilation error when using custom classloader
by M. Kramer
Hello everybody,
I would appreciate some help with the compilation of a rule that involves
dynamically generated POJOs (minimal example at the end of the mail).
When I add the packages of the generated POJOs manually to the imported
packages of my Eclipse plug-in that executes the knowledge session
everything works fine.
When I use my custom classloader (that successfully loads all involved
classes, I checked this thoroughly) I get the following errors:
Unable to generate rule invoker. lts cannot be resolved to a type
Rule Compilation error lts cannot be resolved to a type
Do I need to change my rules just because the involved classes are now
loaded using my custom classloader?
Thanks for your help!
M. Kramer
This is the rule that only works if the package "lts" is listed under
"Import-Package" in the MANIFEST.MF:
import java.lang.String;
import java.util.ArrayList;
import java.util.HashMap;
import org.eclipse.emf.ecore.EObject;
global java.lang.String output;
global java.util.List list;
global java.util.List pclist;
rule "Aspect"
when
$s0Decl: lts.State(name == "a")
$s0: lts.State(this == $s0Decl)
then
java.util.List param = new ArrayList<HashMap<String,EObject>>();
java.util.List ids = new ArrayList<String>();
param.add($s0);
ids.add("0");
list.add(param);
pclist.add(ids);
end
This is the code that I am using to execute the rule:
void executeKnowledgeSession(String droolsRules, URLClassLoader
urlClassLoader, Iterable<EObject> iterable) {
KnowledgeBuilderConfiguration kBuilderConfiguration =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null,
urlClassLoader);
KnowledgeBuilder knowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(kBuilderConfiguration);
Resource droolsRulesResource =
ResourceFactory.newByteArrayResource(droolsRules.getBytes());
knowledgeBuilder.add(droolsRulesResource, ResourceType.DRL);
if (knowledgeBuilder.hasErrors()) {
...
}
KnowledgeBaseConfiguration kBaseConfiguration =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null, urlClassLoader);
KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase(kBaseConfiguration);
knowledgeBase.getKnowledgePackages().clear();
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
StatelessKnowledgeSession knowledgeSession =
knowledgeBase.newStatelessKnowledgeSession();
knowledgeSession.setGlobal(...);
// execute the knowledge session
knowledgeSession.execute(iterable);
}
These are the exact errors that I get:
Unable to generate rule invoker. lts cannot be resolved to a type
lts cannot be resolved to a type
Rule Compilation error lts cannot be resolved to a type
Unable to generate rule invoker. : [Rule name='Aspect']
defaultpkg/Rule_Aspect_0DefaultConsequenceInvoker.java (22:883) : lts
cannot be resolved to a type
defaultpkg/Rule_Aspect_0DefaultConsequenceInvoker.java (22:901) : lts
cannot be resolved to a type
Rule Compilation error : [Rule name='Aspect']
defaultpkg/Rule_Aspect_0.java (6:322) : lts cannot be resolved to a type
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Compilation-error-when-using-custo...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
drl execution problem
by arup
i have one drl like below:
rule "FirstNameDifference"
no-loop true
lock-on-active true
when
person1: Person( $firstName1: firstName )
person2: Person( firstName != $firstName1 )
then
dataDifferenceVO.getDataDiffArray().add("Person/FirstName");
end
i'm passing a list of objects in which i have 2 person type objects. my aim
is to check if the firstnames are same or different. if its different i need
to add one String to the DataDiffArray that is declared inside
DataDifferenceVO class.
but as i pass 2 person objects in the WM the rule is getting executed twice.
i.e, the string "Person/FirstName" is getting added twice in the array list.
why is this happening?... the rule should compare 2 firstnames and return
one String...is not that?... what step should i take to achive what i
want....
Thanks a lot i advance... :) :) :)
--
View this message in context: http://drools.46999.n3.nabble.com/drl-execution-problem-tp3866929p3866929...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Interface and @key in declare
by Findulas
Hello,
I want to declare a new fact base on an interface, f.e.: (i leave away all
those publics)
interface BoInterface {
int getId();
void setId(int id);
}
when i declare the fact
declare BoFact (
bo : BoInterface @key
)
the system throws an exception the a class is expected but an interface is
found, when trying to
perform the equals method.
Is there a restriction that @key cannot be used in a declare?
Greetings,
Bernd
--
View this message in context: http://drools.46999.n3.nabble.com/Interface-and-key-in-declare-tp3868085p...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months