try to understand Banking example 3
by ferry97
Hi,
I'm trying to understand the Banking Example 3.
rule "Rule 01"
when
$number : Number( )
not Number( intValue < $number.intValue )
then
System.out.println("Number found with value: " + $number.intValue()
);
retract( $number );
end
The result is :
Number found with value: 1
Number found with value: 1
Number found with value: 3
Number found with value: 4
Number found with value: 5
But if I remove the "not"
The result is :
Number found with value: 5
Number found with value: 4
Number found with value: 3
Why ? How does it work ? why the two number "1" is gone ?
Please help
Thanks
--
View this message in context: http://www.nabble.com/try-to-understand-Banking-example-3-tp16138098p1613...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 8 months
Eclipse, JUnit and Classpaths (sorry, back)
by J Michael Dean
I have been unable to work on this for a while but problem has not
gone away. I have an RCP that runs and Drools runs and works. But
when I try to run unit tests that involve Drools, I get this recurrent
problem:
java.lang.NullPointerException
at
org.mvel.optimizers.OptimizerFactory.<clinit>(OptimizerFactory.java:43)
at
org.drools.rule.builder.dialect.mvel.MVELDialect.init(MVELDialect.java:
142)
at org.drools.compiler.DialectRegistry.initAll(DialectRegistry.java:49)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:146)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:108)
at
droolsRules.tests.AllDroolsRulesTests.setUp(AllDroolsRulesTests.java:48)
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:585)
So I am writing to describe this environment again, and see if anyone
has suggestions.
I have the Eclipse plugin in my development environment. It is NOT in
my target environment.
I have a privately minted "MinimalDroolsPlugin" that includes the
core, compiler, and the dependency library. THIS plugin is what is in
my manifest.
This works when I run the application, as an RCP with product
branding, or as a product. When I use the target environment in
Eclipse to create Mac, Linux, and W32 applications, all is well.
When I run JUnit tests, I get the error above.
I am wondering if the problem is the simultaneous presence of my
minimal plugin as well as the eclipse Drools plugin?
The Drools jars that are needed by the application need to be
incorporated into some kind of Eclipse plugin so that they are
exposed, which is why I created the minimal plugin. But if I leave
this out completely and then try to setup a routine that imports a
Drools compiler class, for example, Eclipse does not find it merely
from the Eclipse plugins (Drools plugins).
Sorry if this sounds ludicrous and confused, but any help greatly
appreciated!
- Mike
16 years, 8 months
Convert .brl to .drl
by Michael
Hello!
I have found this:
....you can use the following snippet of code to convert the brl to a drl rule:
BRXMLPersitence read = BRXMLPersitence.getInstance();
BRDRLPersistence write = BRDRLPersistence.getInstance();
String brl = ... read from the .brl file as needed...
String outputDRL = write.marshall(read.unmarshal(brl));
//then pass the outputDRL to the PackageBuilder as normal
Can you explain please: "String brl = ... read from the .brl file as needed..."
for example if I have "first.brl" and I want "first.drl"
Thank you... =)
16 years, 8 months
Sequential rules execution
by Aaron Dixon
I found the following thread searching through the Drools mailing list
archives and I was wondering if there were any interesting
developments to mention about sequential rules execution since it was
posted last year. I am achieving sequential execution by preprocessing
rules into activation groups and generating transfer rules to move
between groups, but I imagine my performance is much worse than it
could be.
http://thread.gmane.org/gmane.comp.java.drools.user/7128
I'm interested in sequential execution not for performance reasons but
for the simplicity it offers some users in writing their rules. A
rules engine and the RETE algorithm is too advanced for some users and
a sequential engine allows these users to author rules that will run
in a well-understood environment and protects them from infinite rule
execution, for example.
Is there any plan to offer a sequential execution mode in Drools? Does
anyone else have a similar interest?
Aaron
16 years, 8 months
Need Help with 2 same objects in Working Memory
by Saleem Lakhani
Hi,
I need to have two objects of the same class present in the working
memory at the same time. Both objects can have other nested objects of
different classes.
The reason is I need to compare data change b/w two objects. E.g;
originalObject_A.getPersonTO().getAge() !=
changedObject_A.getPersonTO().getAge()
I am using Drools 3.0, DRLs and DSL.
My question is: how do I assert two objects belonging to the same class
in working memory in order to access them both in DSL.
E;g
I can do:
workingMemory.assertObject(originalObject_A); //instance of class A
workingMemory.assertObject(changedObject_A); //instance of class A
and in DRL I can write:
[when]There is an instance with = originalObject_A:ClassA()
to access originalObject_A but how do I access the changedObject_A in
dsl.
How does drool know which object I am requesting? I hope my question is
clear. Is it even possible in drools 3.0?
Thanks
Saleem Lakhani
16 years, 8 months
(no subject)
by Saleem Lakhani
Hi,
I need to have two objects of the same class present in the working
memory at the same time. Both objects can have other nested objects of
different classes.
The reason is I need to compare data change b/w two objects. E.g;
originalObject_A.getPersonTO().getAge() !=
changedObject_A.getPersonTO().getAge()
I am using Drools 3.0, DRLs and DSL.
My question is: how do I assert two objects belonging to the same class
in working memory in order to access them both in DSL.
E;g
I can do:
workingMemory.assertObject(originalObject_A); //instance of class A
workingMemory.assertObject(changedObject_A); //instance of class A
and in DRL I can write:
[when]There is an instance with = originalObject_A:ClassA()
how do I get the changedObject_A in dsl.
How does drools know which object I am requesting? I hope my question is
clear. Is it even possible in drools 3.0?
Thanks
Saleem Lakhani
16 years, 8 months
Re : Drools 4.0.x branch has still some issues with serialization
by siddhartha banik
Hi Group Members,
In Drools 4.0.5 release most of the bugs with *"Working Memory
serialization"* are fixed. But still the feature has few bugs.
The bug scenario :
1. Create a rule Base & Working Memory (Stateful Session).
2. Assert some objects in Working Memory & call fireAll()
3. Serialize both Rule Base & Working Memory.
4. De Serialize Rule Base & Working Memory.
5. Remove Pkg/rule from Rule Base.
6. Serialize both Rule Base & Working Memory.
7. De Serialize Rule Base & Working Memory. --------->* In this step Working
Memory De Serialization fails with java.lang.ClassNotFoundException.
*8. Assert some more objects in Working Memory & call fireAll()
I have tested the scenario using *"MarshallingTest.java"* from Drools
Codebase. In the *
MarshallingTest.testSerializeAddRemove_NoClassDefFoundError()* test case,
I have appended bellow mentioned code snippet at end:
ruleBase = (RuleBase) serializeIn( serializedRulebase );
session = ruleBase.newStatefulSession( new ByteArrayInputStream(
serializedSession ) ); *// throws java.lang.ClassNotFoundExceptionException
* results = (List) session.getGlobal( "results" );
InternalFactHandle stilton5 = (InternalFactHandle) session.insert(
new Cheese( "stilton", 30 ) );
InternalFactHandle brie5 = (InternalFactHandle) session.insert( new
Cheese( "brie", 30 ) );
InternalFactHandle bob7 = (InternalFactHandle) session.insert( new
Person( "bob", 30 ) );
InternalFactHandle bob8 = (InternalFactHandle) session.insert( new
Person( "bob", 40 ) );
session.fireAllRules();
assertEquals( 8,
results.size() );
assertEquals( bob7.getObject(),
results.get( 6 ) );
assertEquals( bob8.getObject(),
results.get( 7 ) );
serializedSession = null;
serializedRulebase = null;
serializedSession = serializeOut( session );
serializedRulebase = serializeOut( ruleBase );
session.dispose();
*One more bug is:* Can not serialize Working Memory if Rule contains *
Accumulate* or *Collect* Conditional element. Because, both of them have
nested static class "*AccumulateMemory*" & "*CollectMemory*" respectively,
which are not serializable.
We want to use Drools in our project with its *"Working Memory
serialization"* feature to maintain state of Rule Engine between executions.
So Fix of All bugs related to *"Working Memory serialization"* feature is
very important for us.
Thanks
Siddhartha
16 years, 8 months
TWO Same Object Types in WorkingMemory
by Saleem Lakhani
Hi,
I need to have two objects of the same class present in the working
memory at the same time. Both objects can have other nested objects of
different classes.
The reason is I need to compare data change b/w two objects. E.g;
originalObject_A.getPersonTO().getAge() !=
changedObject_A.getPersonTO().getAge()
I am using Drools 3.0, DRLs and DSL.
Thanks
Saleem Lakhani
16 years, 8 months