PMML - Exception excuting consequence for rule xxx in yyy: java.lang.NullPointerException : using KnowledgeAgent
by smilk
Hi. I'm trying to test pmml "decision trees"
(https://github.com/droolsjbpm/drools-chance/tree/master/drools-pmml)
on Drools 5.5.0.Final.
The two test environment's outcome are not same.
1) I got a test on Eclipse. The results are fine. Test source is as below.
public class PMMLTestFromLocal {
public static final void main(String[] args) {
try {
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "LocalPmmlTest");
FactType CHK_YN_Type = kbase.getFactType(
"Meritz_ModelRule_01","CHK_YN" );
CHK_YN_Type.newInstance();
ksession.getWorkingMemoryEntryPoint( "in_AC_CSE_TYP_RE"
).insert( "group0" );
ksession.getWorkingMemoryEntryPoint( "in_AC_TYP_RE" ).insert(
"Caution" );
ksession.getWorkingMemoryEntryPoint( "in_COV_CD_RE" ).insert(
"group2" );
ksession.getWorkingMemoryEntryPoint( "in_AC_STAT_CD_RE"
).insert( "group1" );
ksession.getWorkingMemoryEntryPoint( "in_HDCAP_RATE_RE"
).insert( "0" );
ksession.getWorkingMemoryEntryPoint( "in_FDS_AC_YN" ).insert(
"0" );
ksession.getWorkingMemoryEntryPoint( "in_AGE_GRD" ).insert(
"10대" );
ksession.getWorkingMemoryEntryPoint( "in_AC_COT_DAY" ).insert(
0.0 );
ksession.fireAllRules();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("pmml2.drl"),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse
knowledge.");
}
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase("Meritz");
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
2) The Second environment which is excuting Exception is Tomcat.
I got a test using same drools engine on Tomcat. But NullpointerException
occured.
Test source is as below.
public class PMMLTestFromServer {
public static void main(String[] args) {
StatefulKnowledgeSession kSession = getSKSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(kSession, "ServerPmmlTest");
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
kSession.getWorkingMemoryEntryPoint( "in_AC_CSE_TYP_RE" ).insert( "group0"
);
kSession.getWorkingMemoryEntryPoint( "in_AC_TYP_RE" ).insert( "Caution" );
kSession.getWorkingMemoryEntryPoint( "in_COV_CD_RE" ).insert( "group2" );
kSession.getWorkingMemoryEntryPoint( "in_AC_STAT_CD_RE" ).insert( "group1"
);
kSession.getWorkingMemoryEntryPoint( "in_HDCAP_RATE_RE" ).insert( "0" );
kSession.getWorkingMemoryEntryPoint( "in_FDS_AC_YN" ).insert( "0" );
kSession.getWorkingMemoryEntryPoint( "in_AGE_GRD" ).insert( "10대" );
kSession.getWorkingMemoryEntryPoint( "in_AC_COT_DAY" ).insert( 0.0 );
kSession.fireAllRules();
logger.close();
}
public static StatefulKnowledgeSession getSKSession() {
KnowledgeAgent agent = KnowledgeAgentFactory.newKnowledgeAgent("Meritz");
agent.applyChangeSet(ResourceFactory.newClassPathResource("change-set_model.xml"));
KnowledgeBase ruleBase = agent.getKnowledgeBase();
System.out.println(ruleBase.getKnowledgePackages());
return ruleBase.newStatefulKnowledgeSession();
}
}
The differences in two test source is using KnowledgeAgent.
Exception stack trace follows -
Exception executing consequence for rule
"outputFeature_CHK_YN_to_Probability_N_probability" in Meritz_ModelRule_01:
java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.meritzfis.test.PMMLTestFromServer.main(PMMLTestFromServer.java:43)
Caused by: java.lang.NullPointerException
at
org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.evaluateCachedRight(BeforeEvaluatorDefinition.java:318)
at
org.drools.rule.constraint.EvaluatorConstraint.isAllowedCachedRight(EvaluatorConstraint.java:80)
at
org.drools.common.DoubleBetaConstraints.isAllowedCachedRight(DoubleBetaConstraints.java:97)
at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:156)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.SimpleBeliefSystem.insert(SimpleBeliefSystem.java:38)
at
org.drools.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:204)
at
org.drools.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:176)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:231)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:245)
at
org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:210)
at
org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:205)
at
Meritz_ModelRule_01.Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fc.defaultConsequence(Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fc.java:14)
at
Meritz_ModelRule_01.Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fcDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
Meritz_ModelRule_01.Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fcDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
... 6 more
I'm attaching a drl file.
--
View this message in context: http://drools.46999.n3.nabble.com/PMML-Exception-excuting-consequence-for...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
java.lang.ClassCastException: org.drools.reteoo.BetaMemory cannot be cast to org.drools.reteoo.AlphaNode$AlphaMemory
by dcrissman
Does this mean anything to anyone?
I found this, but I am using 5.5.0.Final:
http://drools.46999.n3.nabble.com/org-drools-reteoo-AlphaNode-AlphaMemory...
java.lang.ClassCastException: org.drools.reteoo.BetaMemory cannot be cast to
org.drools.reteoo.AlphaNode$AlphaMemory
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:136)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
...
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-org-drools...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Timer and AgendaFilter
by Kai Ruddies
Hi,
I have a rule with a timer and call fireAllRules(AgendaFilter agendaFilter) with an AgendaFilter. I can see the Activation is fired after the delay but accept(Activation activation) in my AgendaFilter isn't invoked. My AgendaFilter is working well for other rules without timers.
Is this a bug or wanted that ScheduledActivations aren't passed to the AgendaFilter?
I'm using drools expert 5.5.0.Final.
Thanks,
Kai
12 years, 4 months
RightTupleIndexHashTable
by Ming Fang
What is the purpose of RightTupleIndexHashTable?
We are getting the exception below but unable to come up with a self contained unit test to demonstrate the problem.
Caused by: java.lang.NullPointerException: null
at org.drools.core.util.index.RightTupleIndexHashTable.removeAdd(RightTupleIndexHashTable.java:344) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.JoinNode.modifyRightTuple(JoinNode.java:224) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.PropagationQueuingNode$ModifyToSinkAction.execute(PropagationQueuingNode.java:513) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:280) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:588) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:993) [drools-core-5.5.0.Final.jar:5.5.0.Final]
12 years, 4 months
OptaPlanner: score corruption when using insertLogical with custom objects
by pvandenbrink
Hi,
I've been using Drools Planner with success for a while for our Conversation
planning tool. It's used by schools to plan conversations between teachers
and parents of schoolgoing children.
Recently I checked on the new developments on Drools (the current version
we're using in production is 5.4.0.FINAL) and started to upgrade to
OptaPlanner 6.0.0.Beta5.
Everything looked fine, and seeing how it's now easier to check which
constraints are broken in a given solution, I decided to have a look at that
as well.
And that's where I noticed that we actually had an issue with score
corruption in one of our rules...
The goal of the rule in case is to minimize the amount of timeslots between
the first and last Conversation of a family (they can have conversations for
multiple children.)
The rule uses custom helper objects, like in the NurseRostering example,
which are added with insertLogical.
Conversation is the planning entity, which has the planning variable:
timeslot. FamilyStart and FamilyEnd are custom helper objects to register
the timeslot of the first and last conversation for a family.
The relevant rules are as follows:
rule "familyStart"
salience 1
when
Conversation(
family != null, $family: family,
timeslot != null, $timeslot: timeslot);
not Conversation(
family == $family,
timeslot < $timeslot);
then
insertLogical(new FamilyStart($family, $timeslot));
end
rule "familyEnd"
salience 1
when
Conversation(
family != null, $family: family,
timeslot != null, $timeslot: timeslot);
not Conversation(
family == $family,
timeslot > $timeslot);
then
insertLogical(new FamilyEnd($family, $timeslot));
end
rule "familyCompact"
when
$start: FamilyStart(
family != null, $family: family,
timeslot != null, $timeslotBegin: timeslot);
$end: FamilyEnd(
family == $family,
(timeslot.id - $timeslotBegin.id > family.minimumTimeslotsRequired),
timeslot != null, $timeslotEnd: timeslot);
then
scoreHolder.addSoftConstraintMatch(kcontext, -(($timeslotEnd.getId() -
$timeslotBegin.getId()) - $family.getMinimumTimeslotsRequired()));
end
When running one of my example schedules in FULL_ASSERT mode, the following
error appears during the LocalSearch phase:
Exception in thread "main" java.lang.IllegalStateException: Score
corruption: the workingScore (-2hard/-119soft) is not the uncorruptedScore
(-2hard/-118soft) after completedAction (Teacher 3 family 11 timeslot 2 =>
12):
The corrupted scoreDirector has 1 ConstraintMatch(s) which are in excess
(and should not be there):
defaultpkg/familyCompact/level1/[FamilyEnd Family 11, Timeslot 12,
FamilyStart Family 11, Timeslot 7]=-1
The corrupted scoreDirector has no ConstraintMatch(s) which are missing.
Check your score constraints.
I use a custom ChangeMove and SwapMove implementation. I've also tried using
the new generic Moves, these have the same problem.
It seems like when a move happens that should update an inserted FamilyStart
or FamilyEnd because of a change in timeslot, this change isn't properly
reflected in the scoreDirector.
Do you have any idea what could cause this corruption? The moves do call
beforeVariableChanged and afterVariableChanged on the scoreDirector, and the
FamilyStart and FamilyEnd classes implement an equals and hashcode based on
the Family and Timeslot fields.
(Actually, I've also tried using the default equals and hashcode of Object
for these 2 classes, which causes corruption much faster and with more
ConstraintOccurrences.)
Thanks for any insights,
Pieter
--
View this message in context: http://drools.46999.n3.nabble.com/OptaPlanner-score-corruption-when-using...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Guvnor seems to copy assets across External RDBMS and file system
by Yuri
I set up SQL Server as the external repository, and left everything else in
guvnor and jboss AS7 configured pretty much according to defaults.
When I create assets in guvnor, I see that changes are being made in the
MSSQL db. Despite changes to the db, however, I'm still seeing changes to
the Repository and Workspace folders. It gets more interesting when I
truncate the tables in the external guvnor db, and restart guvnor, it seems
to get all of its assets back from those two folders.
Am I doing something wrong? Is it reconstructing the assets from lucene
indexes? If MSSQL is already indexing things, is the lucene index still
necessary? Are these basic JCR concepts that I am not grasping?
Thanks, Yuri
12 years, 4 months
Scheduling Application and Optaplanner
by marchias
Just started researching OptaPlanner. Loaded examples in Eclipse and got them
running. I'm interested in extending the Nurse rostering example to work
with a scheduling application I have written. I have some interesting
constraints though that wanted to reach out to the community with to make
sure they can be accomodated. My scheduling app has a hierachical entity
setup with Organizations and child locations. An employee can be configured
to work at multiple locations and are also assigned a "Primary" location
which means they should be picked up on shifts at that location before an
employee that does not have that location as primary. Also I have a priority
group or ranking (1-10) which would be considered in sorting employees as
well. Shifts are location, date/time and skill specific with a configured
amount of resources needed.
Shift Examples
Location 1 = 2 nurses, (Monday Wednesay Friday), 7AM - 11PM
Location 1 = 1 nurse, (Sunday,Tuesday,Thursday,Saturday), 7AM - 11PM
Constraints for an employee
Max Hours/Week: 0.00
Min Hours/Week: 0.00
Max Hours/Day: 0.00
Min Hours/Day: 0.00
Max Days/Week: 0.00
Max Consecutive Days: 0.00
Max Shifts/Day: 0.00
Max Shifts/Month: 2.00
Max Weekend Shifts/Month 0.00
Max Consecutive Shifts of Duration 0.00 consecutive 0.00 hr shifts
--
View this message in context: http://drools.46999.n3.nabble.com/Scheduling-Application-and-Optaplanner-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
decision and prediction based on the same set of rules
by Sean Su
Our rules will be using "Date" heavily when making decisions. When the LHS
involving dates is evaluated "true", decision will be made.
Meanwhile, from prediction point of view, we want to know when the LHS
would be evaluated to false, with the changes made to the date fields
(forward to the future). Therefore this becomes prediction - what is the
future date that would cause the LHS to be false.
Question to the list:
has anyone explored the possibility of using the same set of rules to
achieve both tasks?
If there is no tools automatically doing this in Drools (I doubt there is),
I am thinking to build a tool to parse the rules and then auto-generate the
prediction rules based on the "decision" rules. Is this the right direction?
Any inputs will be appreciated.
thanks
Sean
12 years, 4 months
uninformative rule parsing/compiling error -> org.drools.rule.Rule cannot be cast to org.drools.rule.Query
by De Rooms Brecht
Dear rules users,
I am currently writing my own Drools-server since I wanted more control
than the drools-execution server (and it never worked very well here)
where I can send rules/facts over JMS/AQMP/STOMP. Rules which are sent
are saved on the server-side in DRL files that are monitored. That way,
I can debug easily by changing the sent files. However, when I sent the
following code, the agent does not provide me with an error message at
all and hangs:
/
//rule "TrackerRemote.TrackerUpdate"//
// when//
// message:TrackerRemote.TrackerUpdate()//
// then//
// System.out.println("Tracker: " + message);//
//end/
at first I thought it was because TrackerRemote.TrackerUpdate is not in
that package anymore and thus unknown so I tried to send the rule listed
below which gives me the nice and expected error:
Unable to resolve ObjectType 'NotExistingType' : [Rule name='Foo']
/rule "Foo"//
// when //
// NotExistingType( bloe == "test")//
// then//
// System.out.println("this should not work");//
//end/
when I compile the rule myself with a KnowledgeBuilder:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
InputStream is = new ByteArrayInputStream(drlstring.getBytes());
kbuilder.add( ResourceFactory.newInputStreamResource(is),ResourceType.DRL );
I receive the error:
org.drools.rule.Rule cannot be cast to org.drools.rule.Query
which I think doesn't tell me anything about the mistake I made in my
rule, is this a Drools bug and should I post this somewhere?
Kind Regards,
De Rooms Brecht
Full Stack:
java.lang.ClassCastException: org.drools.rule.Rule cannot be cast to
org.drools.rule.Query
at
org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:175)
at
org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:118)
at
org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:67)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:84)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2706)
at
org.drools.compiler.PackageBuilder.compileRules(PackageBuilder.java:930)
at
org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:839)
at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:831)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:467)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:673)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:34)
at
derooms.be.server.listeners.RulesListener.processMessage(RulesListener.java:33)
at
derooms.be.server.listeners.AbstractListener.onMessage(AbstractListener.java:35)
at
org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1321)
at
org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
at
org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
at
org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:129)
at
org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
12 years, 4 months