The rule language. More about the agenda-group and ruleflow-group attributes
by Maxim Kolchin
Hi,
I've only been working with drools about couple of months. I've read the
documentation and some articles about drools.
But, I've not found the detail information about the agenda-group and
ruleflow-group attributes, or examples showing how to work with them.
Have I missed something? Will be grateful for any useful information.
Regards,
Maxim Kolchin,
Laboratory of Intellectual Systems,
National Research University ITMO,
Saint-Petersburg.
http://ailab.ifmo.ru/
Email: kolchinmax(a)gmail.com
12 years, 7 months
traits - don more than 3 pojos, got IllegalArgumentException
by Michal Bali
Hi all,
I came across this issue when trying out 'traits' with POJOs (not declared
types). An IllegalArgumentException is being thrown when I apply the third
'don'. Here is how to reproduce:
as the POJO I am using the Message class that comes with the project
created by the Eclipse plugin.
now the rule file:
declare Message
@Traitable
end
declare NiceMessage
@format(trait)
end
rule load
when
then
Message message = new Message();
message.setMessage("Hello World");
insert(message);
don(message, NiceMessage.class);
Message unreadMessage = new Message();
unreadMessage.setMessage("unread");
insert(unreadMessage);
don(unreadMessage, NiceMessage.class);
Message oldMessage = new Message();
oldMessage.setMessage("old");
insert(oldMessage);
System.out.println("don " + oldMessage);
don(oldMessage, NiceMessage.class); //*<--- exception happens here*
System.out.println("wont reach this point");
end
When I run this and rule 'load' fires the third 'don' will throw the
following exception:
Exception executing consequence for rule "load" in com.mycompany.app:
java.lang.IllegalArgumentException: argument type mismatch
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:709)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:673)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:221)
at com.mycompany.app.DroolsTest.main(DroolsTest.java:44)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at
org.drools.factmodel.traits.TraitFactory.getProxy(TraitFactory.java:92)
at
org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:502)
at
org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:522)
at
com.mycompany.app.Rule_load_86ecf966a4c14d8486844cfae2e1e0d8.defaultConsequence(Rule_load_86ecf966a4c14d8486844cfae2e1e0d8.java:21)
at
com.mycompany.app.Rule_load_86ecf966a4c14d8486844cfae2e1e0d8DefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
com.mycompany.app.Rule_load_86ecf966a4c14d8486844cfae2e1e0d8DefaultConsequenceInvoker.evaluate(Unknown
Source)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
... 6 more
Am I doing something wrong or is this a bug. I am running with 5.4.0.Beta2.
BTW traits are a great piece of functionality. Thank you!
Best regards,
Michal
12 years, 8 months
Drools verifier
by FrankVhh
Hi all,
Triggered by a post on this forum, I decided to try a testcase
implementation of Drool Verifiier.
I manage to write some code that does not produce any errors at runtime,
which is good. Unfortunately, it doesn't produce any errors/warnings/notes
on my rulefile either, which isn't good.
The drl file consists of some duplicate rules, and since the file is only
part of a ruleset, there might be some gaps as well.
I pasted the java-code below. Does anyone see where I am going wrong?
Thanks in advance!
Regards,
Frank
VerifierBuilder vBuilder =
VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
String ruleText =
"C:\\Users\\Frank\\Documents\\DroolsWorkSpaces\\EmpiricalExperiments\\Financial
Rules\\src\\main\\rules\\clearancerules.drl";
verifier.addResourcesToVerify( ResourceFactory.newReaderResource(
new StringReader( ruleText ) ), ResourceType.DRL );
verifier.fireAnalysis();
VerifierReport result = verifier.getResult();
for(VerifierMessageBase base: result.getBySeverity(
Severity.ERROR ) ){
System.out.println( base );
}
for(VerifierMessageBase base: result.getBySeverity(
Severity.WARNING ) ){
System.out.println( base );
}
for(VerifierMessageBase base: result.getBySeverity( Severity.NOTE )
){
System.out.println( base );
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-verifier-tp268...
Sent from the Drools - User mailing list archive at Nabble.com.
12 years, 8 months
Function calls in decision table
by San
Hi
I am trying to cal a local function getMaturityAge() in the decision table
condition column like
RuleTable MaturityAge Validation
CONDITION
ACTION
pp:PremiumCalculatorFormBean
getMaturityAge() > "$1"
System.out.println("invalid maturity age");
Premium Payment Term Print out
message?
70 X
The method is defined localy using functions key word.
And moreover whenever I trying to pass pp as the argument to my functions,
its not able to find pp. I am getting cud not parse knowledge error.
can anyone pz help me out.
--
View this message in context: http://drools.46999.n3.nabble.com/Function-calls-in-decision-table-tp3919...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
custom lib in guvnor
by Olle Martensson
How can I use a custom lib/jar in guvnor.
What I want to do is to call some framework specific methods from the action part of the rules.
Thanks! // Olle
12 years, 9 months
Challenge! Using javassist and drools presents an issue with drl
by markricard
In order to make writing drl files easy and not requiring writers to be
developers, I have written some JavaAssist code that dynamically creates a
subclass and new methods in memory.
If for example there is a REAL java class called 'com.foo.Instance'. Via
javasssist, I create a new in-memory subclass called 'com.foo.InstanceEx'.
The new class dynamically creates a new getter called getFoo(). The drl
writer would like to directly reference 'foo' in the drl file like so:
when
i : Instance(foo == 'fee')
The problem is, in order to reference foo, I would need the drl file to do
this:
import com.rrd.xspace.drools.InstanceEx;
But I cannot do that because InstanceEx does not exist at runtime. The
error I get, which is an obvious one, is "Unable to create Field Extractor
for 'foo' of '[ClassObjectType class=com.foo.Instance]' in rule 'Test' :
[Rule name='Test']"
Is there a way to include a dynamic import of a JavaAssist class while I am
constructing the KnowledgeBase instances to run the rules so that I can
reference that new method?
I would hope to have something similar to:
KnowledgeBuilder kbuilder = ....
kbuilder.addImport("com.foo.InstanceEx")
or
kbuilder.addClass(Class.forName("com.foo.InstanceEx"))
Any help GREATLY appreciated.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Challenge-Using-javas...
Sent from the Drools - User mailing list archive at Nabble.com.
12 years, 9 months
Why is solving a partial puzzle much slower than generating one from scratch?
by aitchnyu
I am making a 3x3 Sudoku solver with Drools planner. The planning entities
are the digits. The problem facts are the rows (planning variable) and
columns.
When I set Drools Planner to solve a problem where no digit is initialized,
it gives a perfect solution in ~15 secs. But when I set a few digits as
initialized, it never finds a solution. It always lists 8 hard constraints
broken on termination.
I implemented the moves as:
if(digit.getFixed()==false){
moveList.add(new RowChangeMove(digit, toRow));
}
If the digit is fixed, dont make a move object for it.
Earlier, I implemented it in isMoveDoable: if the digit.getFixed() is true,
it returns false. Both do not work.
20:31:13.442 [main] INFO o.d.p.c.l.DefaultLocalSearchSolverPhase - Phase
local search finished: step total (978), time spend (60061), best score
(-8).
20:31:13.442 [main] INFO o.d.p.core.solver.DefaultSolver - Solved: time
spend (60061), best score (-8), average calculate count per second (7433).
--
View this message in context: http://drools.46999.n3.nabble.com/Why-is-solving-a-partial-puzzle-much-sl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months