Drools Puzzles round 1 result
by Drools Puzzle
Hi all,
many thanks to all the participators in the round 1 and congratulations to
the winner Dr. Starke. I'll post a detailed report with current scores of
all participators and comments to each solution to Drools wiki tomorrow. Now
it's Dr. Starke's turn to post the next puzzle.
Happy drooling!
Drools Puzzle
17 years, 3 months
Drools 4.0 Migrating
by Saleem Lakhani
Hi,
I am very new to Drools. I need to know from where I can get some
resources on DSL Syntax in 4.0. Examples etc. I am working on a project
which used Drools 3 and my job is to upgrade it to 4.0. I am able to get
everything compiled but getting stuck at loading DSLs. For example: I am
getting an exception like:
An exception occurred while attempting to parse a Validation rule in
ABC
Failed to add the compiled rule package to the RuleBase cause by: Unable
to resolve ObjectType 'orRiskTO' : [Rule name=Certificate]
Unable to resolve ObjectType 'orRiskTO' : [Rule name=Certificate,
agendaGroup=Rating, salience=0, no-loop=false]
Rule Compilation error : [Rule name=Dwellings, agendaGroup=Rating,
salience=0, no-loop=false]
rating/Rule_Dwellings_0.java (36:39) : A method named
"intValue" is not declared in any enclosing class nor any supertype, nor
through a static import
at org.drools.rule.Package.checkValidity(Package.java:409)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:262)
at
com.citizens.ratebook.RatebookRuleBaseFactory.buildValidationsRulebase(R
atebookRuleBaseFactory.java:168)
... 29 more
thanks
Saleem Lakhani
17 years, 3 months
Guided DRL editor
by kissro@lidp.com
Hello,
I am new to JBoss rules and was wondering if someone could explain how
to get started with the new Guided DRL Editor. I'm using Drools 4.0 and
the Eclipse IDE. I've clicked on 'New Guided DRL editor' in Eclipse and
it's created the rules.brxml file. The editor is on the screen showing
'If', 'Then', and 'Options' but it's blank. I've selected the 'If' and
clicked on little screen with the '+' on the right side of the editor.
A dialog box opens with 'Add a New Condition' and a drop down box for
'Fact' but the only option in the drop down box is 'Choose a Fact'.
I've also selected 'Then' and clicked on little screen with the '+' on
the right side of the editor. A dialog box opens with 'Add a New
Action' and several drop down boxes. The only option in all of the
drop down boxes is 'Choose'.
How do I get these boxes populated? I've already got several existing
rules coded and I thought they would show up in the editor but they
don't. Do I have to code the rules in Java before I can use the editor?
According to what I've read, this is supposed to be a point-and-click
way of creating rules but so far I haven't seen that. I was hoping to
be able to use the editor as sort of a gui for creating or modifying my
rules but haven't been able to figure out how to do that. Any help
would be appreciated.
Rod
17 years, 3 months
trivial case in xls
by Bin Shen (BA/EDD)
Hi, all,
use 4.0.0 GA.
want to have an xls rule file. i am not sure of how to define the following trivial case in xls.
can anybody help? thanx!
when
$p : Person()
then
// do something with any person
end
/ Ben
17 years, 3 months
Decision tables with cutoff time
by Hehl, Thomas
I'm trying to create a decision table. One of the rules is that an event
must occur a certain number of days before another event. This number of
days before cutoff currently means that anytime before the cutoff date is
allowed, but anything on or after the cutoff date is not. I'm trying to
modify this to allow things that are actually on the cutoff date are allowed
if they happen before a certain time in the day, to allow for customers that
want cutoff to be until close of business or some such.
Can I put this into a decision table?
Thanks.
Thom Hehl
Sr. eJuror Architect
* Office (859) 277-8800 x 144
* Thomas.Hehl(a)acs-inc.com <mailto:Thomas.Hehl@acs-inc.com>
ACS, Inc.
Government Solutions
1733 Harrodsburg Road
Lexington, KY 40504-3617
This e-mail message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the sender
by reply e-mail and destroy all copies of the original message and notify
sender via e-mail at Thomas.Hehl(a)acs-inc.com
<mailto:Thomas.Hehl@acs-inc.com> or by telephone at 859-277-8800 ext. 144.
Thank you.
17 years, 3 months
RE: trivial case in xls
by Bin Shen (BA/EDD)
sorry, i used the wrong word "action", instead of "data".
take the schema once more to avoid misunderstanding (assume no grouped rows).
-------------------------------------------
| CONDITION
-------------------------------------------
object type/ | $p : Person
-------------------------------------------
snippet/condition | ?
-------------------------------------------
explaination text | xxxxxxxxx
-------------------------------------------
cell/data | ?
-------------------------------------------
it's clear: the condition ("snippet" in my term) can not be empty, and the data ("cell" in my term) can be empty.
in my case how should i put the condition, when no field constraint is there? how should i put in the data? an empty invalidates the condition!
the case i raised seems trivial. actually it finds many applications as follows. in question comes the rule "otherwise":
rule "main"
salience 10
when
$p : Person(age > 35)
then
// do something with persons older than 35
System.out.println("hello, " + $p + "!");
end
rule "otherwise"
when
$p : Person()
then
// ignore other persons, i.e. retract them to avoid memory leaks
retract($p);
end
/ Ben
17 years, 3 months
RuntimeDroolsException
by Raffaele Viola
Hi,
I'm starting to use eclipse plug.in for JRules. I created the example JRules
project in eclipse and I tried to start it as Java Application but I got
this exception
org.drools.RuntimeDroolsException: Unable to load dialect '
org.drools.rule.builder.dialect.java.JavaDialect:java'
at org.drools.compiler.PackageBuilderConfiguration.buildDialectRegistry(
PackageBuilderConfiguration.java:156)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:131)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:84)
at com.sample.DroolsTest.readRule(DroolsTest.java:50)
at com.sample.DroolsTest.main(DroolsTest.java:21)
Can someone help me?
Thanks
Raffo
17 years, 3 months
Please help - losing hair
by Richard Hoberman
I'm using Drools 4 (M2), which is supposed to support nested accessors*
This works: when Claim( submissionInfo == null), but not this: when
Claim( submissionInfo.date == null)
Rule file, SubmissionInfo.java and exception are below.
What am I missing?
Richard
* See
http://article.gmane.org/gmane.comp.java.drools.user/8079/match=nested+pr...,
which states "Support to nested accessors, property navigation and
simplified collection, arrays and maps syntax"
Rule File
---------------------------------------------------------------------------------------
package mvanamibia.claim;
import java.lang.Object;
import java.lang.String;
import java.lang.Double;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import com.sadalbari.mvanamibia.beans.Claim;
import com.sadalbari.mvanamibia.beans.Mandate;
import com.sadalbari.mvanamibia.beans.SubmissionInfo;
import com.sadalbari.mvanamibia.inspector.ClaimEvaluation;
global ClaimEvaluation evaluation;
rule "hasDateReceived"
when
Claim( submissionInfo.date == null )
then
evaluation.getFailures().add("missing: date received");
end
-----------------------------------------------------------------------------------
Exception
-----------------------------------------------------------------------------------
org.drools.rule.InvalidRulePackage: [19,23]: unknown:19:23 mismatched
token: [@137,471:471='.',<69>,19:23]; expecting type RIGHT_PAREN
at org.drools.rule.Package.checkValidity(Package.java:368)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:250)
at
com.sadalbari.mvanamibia.model.UnregisteredClaimValidationTest.setupWorkingMemory(UnregisteredClaimValidationTest.java:33)
at
com.sadalbari.mvanamibia.model.UnregisteredClaimValidationTest.testMandateClaim(UnregisteredClaimValidationTest.java:56)
... Removed 22 stack frames
FAILED: testEmptyClaim
org.drools.rule.InvalidRulePackage: [19,23]: unknown:19:23 mismatched
token: [@137,471:471='.',<69>,19:23]; expecting type RIGHT_PAREN
at org.drools.rule.Package.checkValidity(Package.java:368)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:250)
at
com.sadalbari.mvanamibia.model.UnregisteredClaimValidationTest.setupWorkingMemory(UnregisteredClaimValidationTest.java:33)
at
com.sadalbari.mvanamibia.model.UnregisteredClaimValidationTest.testEmptyClaim(UnregisteredClaimValidationTest.java:42)
... Removed 22 stack frames
------------------------------------------------------
SubmissionInfo (relevant bits)
public class SubmissionInfo implements Serializable {
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
17 years, 3 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, 3 months
could not access property ('=')
by Arsalan S. Zaidi
Hi.
I've currently evaluating Drools 4.0 for a project of ours and I'm
running into some problems.
I have a rule which looks like this:
rule "W250.42 Editable"
when
DTO(w250_4_1.value in
("0","1","6","7","A","C","D","G","L","M","P","Q","S","V","Z") )
then
System.out.println ("0");
Action action = createAction("W250.42", false, true);
retList.add(action);
end
both DTO and w250_4_1 are extremely simple beans. w250_4_1 just has 1
property 'value' which is a String and DTO has one property w250_4_1
which is the bean w250_4_1.
Now when I put "0" into w250_4_1 then everything works fine. The rule is
true and the 'then' portion is executed. However, if I set w250_4_1 to
"6" (which is also present in the in (...)) then I get the following
error.
org.drools.RuntimeDroolsException: Exception executing predicate
org.drools.base.mvel.MVELPredicateExpression@118fa47
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:1
97)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:122)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Compo
siteObjectSinkAdapter.java:317)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168)
at org.drools.reteoo.Rete.assertObject(Rete.java:168)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:
70)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:848)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:822)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:623)
at com.sample.DroolsTest.main(DroolsTest.java:34)
Caused by: org.mvel.PropertyAccessException: failed to access property:
<<==>> in: class com.sample.DTOShadowProxy
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChai
n(ReflectiveAccessorOptimizer.java:137)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccess
or(ReflectiveAccessorOptimizer.java:96)
at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)
at org.mvel.ast.Or.getReducedValueAccelerated(Or.java:18)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
at
org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
at org.mvel.MVEL.executeExpression(MVEL.java:202)
at
org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpre
ssion.java:36)
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:1
91)
... 10 more
Caused by: org.mvel.PropertyAccessException: could not access property
('=')
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanPropert
y(ReflectiveAccessorOptimizer.java:252)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChai
n(ReflectiveAccessorOptimizer.java:106)
... 18 more
If I keep w250_4_1 as "0", but move "0" in the rule to any other place
place in the in() list (e.g. in ("1","0",...), then I get a similar
error.
I get similar errors when trying to use 'not in' in the same
circumstance, except that then the property is ('!')
What seems to be the issue?
Thanks in advance!
Regards,
--Arsalan
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
17 years, 3 months