Re: [rules-users] Odd static inner class behavior
by Edson Tirelli
Eric,
Thanks, I understand now.
What happens is that if both DRL files declare the same package name,
all their contents will be merged. It means that you would end up with both
imports in the same namespace:
import com.company.DataClass.AlternativeKey;
import com.company.AnotherClass.AlternativeKey;
And so the engine will raise an error saying that it does not know
which one you are refering to when you write simply:
AlternativeKey
I think the engine behavior is correct, since the idea of loading two
different files with the same name space into the same package builder is to
merge them, or even replace (update) that eventually have the same name.
What do you think?
Edson
2007/7/26, Eric Miles <eric.miles(a)kronos.com>:
>
> Edson,
>
> I have since changed my schema but here was my issue:
>
> rule1.drl:
> import com.company.DataClass.AlternativeKey;
> import com.company.DataClass;
>
> rule "Some rule"
> when
> DataClass.AlternativeKey(someParm == true)
> then
> ...
> end
>
> Different drlf file:
> rule2.drl
> import com.company.AnotherClass.AlternativeKey;
> import com.company.AnotherClass;
>
> rule "Another rule"
> when
> AnotherClass.AlternativeKey(diffParm == 1)
> then
> ...
> end
>
>
> This was the gist of what I was doing. The outer classes' names were
> different, it was the INNER class of each of these classes that had the same
> name. I was actually getting compile errors on the import statements. Like
> I said, these rules worked fine if loaded separately, but once I tried to
> put them all int he same rule base, I was getting the import collision
> error. Later on this evening (when I'm not at work), I'll try to put
> together a small test case and upload it. In the meantime, you can look
> skim over this and let me know if something jumps out at you.
>
> Thanks,
> Eric
>
> On Thu, 2007-07-26 at 10:32 -0300, Edson Tirelli wrote:
>
> Eric,
>
> Not sure if I understood your problem, but if you have multiple
> classes with the same name, and the only difference is that they are inner
> classes of different classes, I guess what you need to do is to fully
> qualify your class names in your rules...
>
> rule xxx
> when
> my.package.MyClass.MyInnerClass( ... )
> ...
> end
>
> If this is not your problem, can you please show us an example so we
> understand it better?
>
> Edson
>
>
> 2007/7/25, Eric Miles <eric.miles(a)kronos.com>:
>
> Due to how JAXB treats anonymous inner complex types, I ended up with a
> public static inner classes named AlternativeKey in several of my data
> classes I have several rules written to deal with each data class
> individually that all work ok. However, when I attempt to put them all in
> the same rule base (all belong to the same package), I get an import
> collision exception on the AlternativeKey inner class. Depending on where
> in the builder I add the resource depends on which AlternativeKey the
> compiler bitches about (validity). I'm not familiar with the source at all,
> so I'm unsure as to where to look for this. However, this sounds like a bug
> to me? There is an easy workaround for this as I I just don't use anonymous
> types and define them in my schema explicitly. Just thought I'd identify
> this as a possible issue.
>
> Thanks,
> Eric
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
> Edson Tirelli
> Software Engineer - JBoss Rules Core Developer
> Office: +55 11 3529-6000
> Mobile: +55 11 9287-5646
> JBoss, a division of Red Hat @ www.jboss.com
>
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
17 years, 4 months
Problems Extending the Golfer example - Cartesian joins ??
by Simon French
Hi,
After attending a session with Mark Proctor in London I was inspired to play
around with Drools in a slightly different way than we use it for in the
workplace, and try and solve a puzzle.
Unfortunately I couldn't get Drools to solve it as I kept getting memory
problems (I believe are cartesian joins being the problem),
so I decided to extend the golfer example to see if I got the same problem
I added two new names and a new integer property, club
// create all possible Golfer objects
String[] names = new String[] { "Fred", "Joe", "Bob", "Tom",
"Des", "Terry" };
String[] colors = new String[] { "red", "blue", "plaid",
"orange","black", "white" };
int[] positions = new int[] { 1, 2, 3, 4, 5, 6 };
int[] clubs = new int[] {9,8,7,4,5,5};
for ( int n = 0; n < names.length; n++ ) {
for ( int c = 0; c < colors.length; c++ ) {
for ( int p = 0; p < positions.length; p++ ) {
for ( int q = 0; q < clubs.length; q++ ) {
session.insert(new Golfer( names[n],
colors[c], positions[p], clubs[q]) );
....
Then changed the golder.drl to:
package com.sample
import com.sample.Golfer;
rule "Golfer Riddle"
when
// A golfer named Fred,
Golfer( name == "Fred",
$fredsPosition : position, $fredsColor : color, $fredsClub :
club )
// Der Golfer hinter Fred trägt blau
Golfer( $unknownsName : name != "Fred",
$unknownsPosition : position == ( $fredsPosition + 1 ),
$unknownsColor : color == "blue", color != $fredsColor,
$unknownsClub : club == 5 )
// Joe steht an zweiter Stelle
Golfer( name == "Joe", $joesPosition : position == 2,
position != $fredsPosition,
$joesColor : color != $fredsColor,
$joesClub : club == 5 )
// Bob traegt Karo
Golfer( name == "Bob",
name != $unknownsName,
$bobsPosition : position != $fredsPosition,
position != $unknownsPosition, position !=
$joesPosition,
$bobsColor : color == "plaid",
color != $fredsColor, color != $joesColor,
color != $unknownsColor,
$bobsClub : club < $joesClub )
// Tom ist nicht 1. oder 4., traegt kein Orange
Golfer( $tomsName : name == "Tom",
$tomsPosition : position != 1, position != 4,
position != $fredsPosition, position != $joesPosition,
position != $bobsPosition,
$tomsColor : color != "orange", color != "blue",
color != $fredsColor, color != $joesColor,
color != $bobsColor )
Golfer ( $des : name == "Des", $desPosition : position <
$fredsPosition, $desColor : color != "blue",
color != $fredsColor, color != $joesColor,
color != $bobsColor )
Golfer ( $terry : name == "Terry", $terryPosition : position <
$desPosition, $terryColor : color != "blue",
color != $fredsColor, color != $joesColor,
color != $bobsColor )
then
System.out.println( "Fred " + $fredsPosition + " " + $fredsColor );
System.out.println( "Joe " + $joesPosition + " " + $joesColor );
System.out.println( "Bob " + $bobsPosition + " " + $bobsColor );
System.out.println( "Tom " + $tomsPosition + " " + $tomsColor );
System.out.println( "Des " + $desPosition + " " + $desColor );
System.out.println( "terry " + $terryPosition + " " + $terryColor
);
end
After a couple of minutes of processing I got:-
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
I also changed java memory allocation with -Xms1640M -Xmx1640M (The most I
can allocate on my PC), and tried running it as a stateless session too.
Is there anything else I can do, or is this simply pushing drools too far
(surely not!!) ?
I'm very keen on pushing this technology as much as possible in our
workplace and I'd really appreciate any help.
Thanks in advance
Simon
17 years, 4 months
JBoss Rules IDE Error on StringEvaluator
by Ronald R. DiFrango
Anyone ever seen this error in the IDE:
Severity and Description Path Resource Location Creation Time
Id
Operator '50' does not exist for StringEvaluator
RtvDecisionEngine/src/rules/com/circuitcity/rtvcrms/rules rtv.drl
Unknown 1179954317638 29080
And if so what do you do about it? My rules file is just under 1000 lines
[and growing] and shows no other errors.
17 years, 4 months
Drools Puzzle #1: Ages of the sons
by Ellen Zhao
Hallo all!
I talked about running a periodic puzzle solving contest in the user
mailing list to some people in the drools team. They have never done
it before so did not know how this contest will come out. However, I
was allowed to make the first try. If no body is interested, there
won't be any Drools Puzzle #2. Sorry for the spam if you do not like
this at all. In the end of this email you can see how I came up with
this idea.
So, here is the puzzle for round No. 1:
------------------------------------------------------------------------------------------------------------------------------------
Difficulty level: settler
An old man asked a mathematician to guess the ages of his three sons.
Old man said: "The product of their ages is 36."
Mathematician said: "I need more information."
Old man said:"Over there you can see a building. The sum of their ages
equals the number of the windows in that building."
After a short while the mathematician said: "I need more information."
Old man said: "The oldest son has blue eyes."
Mathematician said: "I got it."
------------------------------------------------------------------------------------------------------------------------------------
This is a simple puzzle, you may not need any computer to solve it.
But here are the rules:
1. Solution (the core algorithm) must be written in drools. Any
dialect is allowed. Any DSL is allowed.
2. Any kind of user interface is allowed.
3. Make your program as easy to test as possible. Please attach a
simple and short readme file about how to build/test/deploy it.
4. The drools team will measure the performance of all submissions on
a same computer.
3. The winner will be allowed to post the next puzzle.
4. Any participator, no matter finally win or not, will get points for
each participation. Drools team will run a global ranking system and
build a hall of fame for all participators. At the end of the year,
the one who has most points will be awarded with ( Drools team please
fill here, something like a T-shirt or ?). Top ten people in the hall
of fame will be awarded with (Drools team please fill here).
5. If there are many, many participators, the Drools team might
consider things like "shortest run-time award", "least memory-usage
award", "best UI award", "shortest code award", etc. for each puzzle.
6. Currently the puzzle will come once half month. Submission deadline
of this round is August 15th, 2007.
7. Please do not post your solution to the user mailing list, since
everybody can see your program before the deadline. Drools team please
specify an email account to which participators can post solutions.
8. Best/inspiring solutions will be disclosed when next round is on.
9. If any Drools bug is caught during your solving of the puzzle, the
Drools team will award you with (Drools team please fill here).
-----------------------------------------------------------------------------------------------------------------------------------
Any constructive advice and suggestion about the rules of Drools
Puzzle is welcome.
Here is guideline for posting puzzles:
1. You do not want to scare people away with too difficult puzzles or
bore people with questions like 1+1=?, so please consider a proper
difficulty level for the puzzle.
2. NP-complete or NP-hard is okay. For some NP-hard problems,
sub-optimal solutions can be achieved efficiently. But do please tag
the difficulty level as something like "veteran", "guru", etc.
3. Complexity aside, there is still scope and testability
consideration. Puzzles like "How to integrate my 15 different kind of
services objects and my entity home with Drools?" might be
algorithmically not difficult, but the application-building can really
take a lot of time and energy, and it is not straightforward to test
the solution.
4. The purposes of this contest are:
4.1 To learn from each other, enhance our programming skill and
learn good algorithms, good implementations.
4.2 To encourage people to explore features of Drools.
4.3 For fun.
So your puzzle should not take too much work to solve. It should not
mentally or physically torture participators.
---------------------------------------------------------------------------------------------------------------------------------
This idea was inspired by a "Weekly Challenge" running on dpreview.com
user forum and GOTM from http://gotm.civfanatics.net/
On dpreview.com, a subject is posted by the winner of the prior week,
people can post their photos to compete. On civfanatics.net, an
initial configuration file is posted each month, and gamers submit
their end results for ranking. Both of these two non-official contests
are running very well, I hope Drools Puzzle will turn out a fun thing
too.
Regards and nice weekend,
Ellen
17 years, 4 months
drools-example-brms
by David Nogueras
Hi, I´m trying to run the brms sample and i get the next output:
RuleAgent(insuranceconfig) INFO (Thu Jul 19 14:27:44 CEST 2007): Configuring
with newInstance=true, secondsToRefresh=30
RuleAgent(insuranceconfig) INFO (Thu Jul 19 14:27:44 CEST 2007): Configuring
package provider : URLScanner monitoring URLs:
http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/org.acme...
local cache dir of D:\workspace2\drools-example-brms\cache
RuleAgent(insuranceconfig) WARNING (Thu Jul 19 14:27:44 CEST 2007): Falling
back to local cache.
java.lang.NullPointerException
at org.drools.agent.FileScanner.readPackage(FileScanner.java:101)
at org.drools.agent.FileScanner.getChangeSet(FileScanner.java:79)
at org.drools.agent.FileScanner.loadPackageChanges(FileScanner.java:57)
at org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:93)
at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:291)
at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:259)
at org.drools.agent.RuleAgent.configure(RuleAgent.java:228)
at org.drools.agent.RuleAgent.init(RuleAgent.java:160)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:169)
at org.acme.insurance.launcher.InsuranceBusiness.loadRuleBase(
InsuranceBusiness.java:26)
at org.acme.insurance.launcher.InsuranceBusiness.executeExample(
InsuranceBusiness.java:14)
at org.acme.insurance.launcher.MainClass.main(MainClass.java:13)
could someone help me?
17 years, 4 months
Re: Production rules vs. ECA Rules
by qmars765@gmx.de
Hi Mark,
in which constellations i should select ECAs? What is the difference between events in ECAs and the occurrence of a certain set of facts in WorkingMemory in case of production rules?
In following document they classify ECAs and production rules both as reactive rules, but they state they are somehow different:
http://www.pms.ifi.lmu.de/publikationen/PMS-FB/PMS-FB-2007-8/PMS-FB-2007-...
And they state that JBoss Rules is only for production rules.
So can I use JBoss Rules for implementing ECAs?
Thanks and best regards,
Kioumars
Date: Mon, 30 Jul 2007 19:20:51 +0100
From: Mark Proctor <mproctor(a)codehaus.org>
Subject: Re: [rules-users] Production rules vs. ECA Rules
To: Rules Users List <rules-users(a)lists.jboss.org>
Message-ID: <46AE2C03.8090701(a)codehaus.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
ECA is really a specialised subset of Product Rules; focusing more on
generic event generation and event handling.
Mark
qmars765(a)gmx.de wrote:
> Dear List,
>
> In JBoss Rules documentation it is written that they can be used for production rules. But I frequently read also in other sources about ECA rules.
>
> Is there any significant difference between “ECA†and “Production†Rules?
> If yes, what?
>
> Thanks in advance for your feedback and best Regards,
>
> Kioumars
>
>
--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
17 years, 4 months
Dynamic Packaging using Drools 4.0.0
by Jin, Ming
I am facing a tough problem requiring some abnormal solutions: The
requirements calls for million rules (they all think about that at the
beginning), so we are thinking about packaging rules on the fly during
execution instead caching all the rules in the rules engine. All the
rules will be pre-compiled and serialized to storage. We would like to
achieve to separate the Package and Rule's objects, and dynamically
compose the Package object when needed.
I tried the following steps and was enable to move forward beyond step
5:
1. Create the Package object by using
PackageBuilder().addPackageFromDrl(drl_file).
2. For each rule under the Package object, remove it from Package by
calling Package().removeRule(rule), then serialize it to storage.
3. Serialize the now empty Package object to storage.
<!-- when recompose the Package object, perform the following steps -->
4. Deserialize the Package.
5. Deserialize the Rule objects - this is where I encountered an
ClassNotFoundException at the end of the message
6. Using Package().addRule(rule) to add needed rules - not tried yet.
7. Add the package to RuleBase..... as normally do.
java.lang.ClassNotFoundException:
com.travelocity.rules.hotel.Rule_Match_Region_Rule_1_0ConsequenceInvoker
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:585)
at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699
)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719
)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at com.travelocity.common.util.IOUtil.readObject(IOUtil.java:158)
at com.travelocity.common.util.IOUtil.readObject(IOUtil.java:147)
at
com.travelocity.rules.hotel.HotelChargeRulesUnitTest.loadPackage(HotelCh
argeRulesUnitTest.java:64)
at
com.travelocity.rules.hotel.HotelChargeRulesUnitTest.testHotelChargeRequ
est(HotelChargeRulesUnitTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at
com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)
In the application, the rule name is "Match Region Rule 1", and the
package name is "com.travelocity.rules.hotel". Please advise if it is
possible to get around this problem, or if this approach would really
work?
Your help is greatly appreciated.
-Ming
17 years, 5 months
Error from TroubleTicket example in official 4.0GA drools-examples-drl download
by Shahad Ahmed
I get the following two errors reported by Eclipse when I import the
official 4.0 GA download version of the drools-examples-drl project:
1. Unable to find unambiguously defined class 'Customer', candidates are: [
org.drools.examples.Customer,
org.drools.examples.TroubleTicketExample$Customer]
drools-examples-drl/src/main/rules/org/drools/examples in TroubleTicket.drl
2. Unable to find unambiguously defined class 'Customer', candidates are: [
org.drools.examples.TroubleTicketExampleWithDSL$Customer,
org.drools.examples.Customer]
drools-examples-drl/src/main/rules/org/drools/examples in
TroubleTicketWithDSL.drl
Is this a bug in 4.0GA , or is there further configuration required after
importing the examples project? I'm using the 4.0GA release version of the
drools Eclipse plug-in.
I also noticed that I don't get this error from the latest version of drools
in the trunk (i.e. including post 4.0GA changes), so maybe this has already
been fixed since release 4.0GA?
Here's the stack when you try and run the TroubleTicketExample.java example:
Exception in thread "main" java.lang.Error: Unable to find unambiguously
defined class 'Customer', candidates are: [
org.drools.examples.TroubleTicketExample$Customer,
org.drools.examples.Customer]
at org.drools.base.ClassTypeResolver.resolveType(ClassTypeResolver.java
:178)
at org.drools.rule.builder.dialect.java.JavaFunctionBuilder.build(
JavaFunctionBuilder.java:84)
at org.drools.rule.builder.dialect.java.JavaDialect.addFunction (
JavaDialect.java:431)
at org.drools.compiler.PackageBuilder.addFunction(PackageBuilder.java:380)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:278)
at org.drools.compiler.PackageBuilder.addPackageFromDrl (
PackageBuilder.java:160)
at org.drools.examples.TroubleTicketExample.main(TroubleTicketExample.java
:20)
Shahad
17 years, 5 months
parsing errors
by hypnosat7
Hi,
I'm trying to recover errors information on parsing errors but I don't
know how to get a List<RecognitionException> from the DrlParser instance :
Reader drlReader2 = new
InputStreamReader(PackageValidator.class.getResourceAsStream(PACKAGE_DRL));
DrlParser drlParser = new DrlParser();
PackageDescr packageDescr = drlParser.parse(drlReader2);
List<RecognitionException> parsingErrors = new
ArrayList<RecognitionException>();
parsingErrors = drlParser.getErrors() ????
May be I can extends the DrlParser class with I new method like :
getErrorRecognition
Is it a good Idea ?
Thanks
--
View this message in context: http://www.nabble.com/parsing-errors-tf4192364.html#a11922150
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 5 months