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, 6 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, 7 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, 7 months
Help
by seagull
Hi everyone,
I am new to drools.net and I am testing some basic commands but can't seem
to find help anywhere! I am trying to print the contents of a variable but
for some reason, the contents are not printed! The first line (i.e. hello)
on the other hand is being printed.. Is there a common mistake I may be
doing?
Thanks!
rule "testing"
when
p: Person (name == "john")
then
Console.WriteLine ("hello");
Console.WriteLine (p.name);
end
--
View this message in context: http://drools.46999.n3.nabble.com/Help-tp3812782p3812782.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Guvnor data enumeration issue
by GPatel@tsys.com
I am trying to use data enumerations and running into a problem. Following
the Vehicle engineType/fuelType data enumeration example in the Guvnor
manual, I created the following enumeration list and it works:
'Vehicle.engineType' : (new test.VehicleHelper()).getEngineTypes()
'Vehicle.fuelType[engineType]' : '(new
test.VehicleHelper()).getFuelTypes("@{engineType}")'
VehicleHelper:
------------
public class VehicleHelper {
public List<String> getEngineTypes(){
List<String> engineTypes = new ArrayList<String>();
engineTypes.add("Petrol");
engineTypes.add("Diesel");
return engineTypes;
}
public List<String> getFuelTypes(String engineType){
List<String> fuelTypes = new ArrayList<String>();
if("Petrol".equalsIgnoreCase(engineType)){
fuelTypes.add("ULP");
fuelTypes.add("PULP");
}
else if("Diesel".equalsIgnoreCase(engineType)){
fuelTypes.add("BIO");
fuelTypes.add("NORMAL");
}
else{
fuelTypes.add("Default Fuel 1");
fuelTypes.add("Default Fuel 2");
}
return fuelTypes;
}
}
Above works as expected.
Problem:
I want to only have an enumeration on Vehicle.fuelType that depends on the
value of engineType, without specifying an enumeration on engineType. So,
I took out the first line in my enumeration list so that it is now:
'Vehicle.fuelType[engineType]' : '(new
test.VehicleHelper()).getFuelTypes("@{engineType}")'
But that does not work. When I create a rule, VehicleHelper.getFuelTypes
does not get called and the dropdown for fuelType is not a list.
How do I get this working?
Thanks
G. Patel
-----------------------------------------
The information contained in this communication (including any
attachments hereto) is confidential and is intended solely for the
personal and confidential use of the individual or entity to whom
it is addressed. If the reader of this message is not the intended
recipient or an agent responsible for delivering it to the intended
recipient, you are hereby notified that you have received this
communication in error and that any review, dissemination, copying,
or unauthorized use of this information, or the taking of any
action in reliance on the contents of this information is strictly
prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original
message. Thank you
12 years, 7 months
Some problems with Deploying drools-camel-sever 5.3.x in Weblogic 10.x
by ndipiazza
Hey everyone,
We have been trying to deploy drools-camel-server-5.3.x.Final.war from
droolsjbpm-integration-distribution-5.3.0.Final on WebLogic 10.3.3.
We hit a series of issues, of which I've opened up some issue tickets to
address:
1) strict web application container complains about web.xml (JBRULES-3403 -
https://issues.jboss.org/browse/JBRULES-3403) - web.xml needs to be
re-arranged to get it to work in weblogic 10.x.
2) There seems to be duplicate JPA persistence units
(https://issues.jboss.org/browse/JBRULES-3404)
I also experienced two other issues that I do not feel comfortable putting
on the issue tracker because they may be weblogic-specific:
3) When I tried to run a SOAP UI test on the drools server in Weblogic
10.3.3 I get this:
WARNING: Interceptor for {http://soap.jax.drools.org/}CommandExecutor has
thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: This class does not support SAAJ 1.1
at
org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer
.java:123)
at
org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:
102)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInv
okerInterceptor.java:58)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:44
1)
at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecu
tor.java:37)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(Se
rviceInvokerInterceptor.java:106)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
orChain.java:263)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
ationObserver.java:118)
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstract
HTTPDestination.java:208)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(
ServletController.java:223)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
roller.java:205)
at
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpr
ingServlet.java:113)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
stractHTTPServlet.java:184)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractH
TTPServlet.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
HTTPServlet.java:163)
at
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run
(StubSecurityHelper.java:227)
at
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri
tyHelper.java:125)
at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:300)
at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:183)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.doIt(WebAppServletContext.java:3686)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:3650)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
121)
at
weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
ervletContext.java:2268)
at
weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
ontext.java:2174)
at
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j
ava:1446)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.UnsupportedOperationException: This class does not
support
SAAJ 1.1
at
weblogic.webservice.core.soap.SOAPMessageImpl.getSOAPBody(SOAPMessage
Impl.java:631)
at
org.drools.jax.soap.PreCxfTransportSoapProcessor.process(PreCxfTransp
ortSoapProcessor.java:42)
at
org.drools.camel.component.DroolsPolicy$DroolsProcess.process(DroolsP
olicy.java:341)
at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$Processor
ToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:70)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(Delegat
eAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsy
ncProcessor.java:89)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:70)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(Delegat
eAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsy
ncProcessor.java:89)
at
org.apache.camel.processor.interceptor.TraceInterceptor.process(Trace
Interceptor.java:99)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:70)
at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler
(RedeliveryErrorHandler.java:290)
at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryE
rrorHandler.java:202)
at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java
:256)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProc
essor.java:99)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:70)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(Delegat
eAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsy
ncProcessor.java:89)
at
org.apache.camel.management.InstrumentationProcessor.process(Instrume
ntationProcessor.java:68)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:91)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsy
ncProcessor.java:85)
at
org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:
97)
... 29 more
Seems to be two possible ways to solve this (have not tested these yet!)
Option One: Use axis.jar instead of saaj-impl.jar
1. add axis.jar file to bea class path
2. in startWebLogic.sh/cmd
set JAVA_OPTIONS=%SAVE_JAVA_OPTIONS%
-Djavax.xml.soap.MessageFactory=org.apache.axis.soap.MessageFactoryImpl
Option Two: Make a code fix to allow the saaj to function
Follow the below steps to resolve "UnsupportedOperationException"
a. Set classpath to latest saaj-impl.jar in startweblogic.cmd
b. Set the below 2 system properties in code.
System.setProperty("javax.xml.soap.MessageFactory","com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl");
System.setProperty("javax.xml.soap.SOAPConnectionFactory","weblogic.wsee.saaj.SOAPConnectionFactoryImpl");
c. Note that the above 2 classes are available in the saaj-impl.jar which i
have used and set classpath in step1. If you are using different version of
saaj-impl.jar, set the exact "MessageFactory" and "SOAPConnectionFactory"
classes which are avilable in your saaj-impl.jar. (Just extract your
saaj-impl.jar and findout the exact classes).
Obviously we cannot expect Drools team to make any code changes with respect
to WebLogic, so I would imagine trying Step 1 is the best way to go.
4) The drools-camel-server.war’s test.jsp apparently runs an example that
uses a Camel route leading to a REST web service. This does not work for me
either off the bat:
WARNING: Interceptor for {http://soap.jax.drools.org/}CommandExecutor has
thrown
exception, unwinding now
org.apache.cxf.interceptor.Fault: Unable to create message factory for SOAP:
Pro
vider org.apache.axis.soap.MessageFactoryImpl not found
at
org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer
.java:123)
at
org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:
102)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInv
okerInterceptor.java:58)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:44
1)
at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecu
tor.java:37)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(Se
rviceInvokerInterceptor.java:106)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
orChain.java:263)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
ationObserver.java:118)
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstract
HTTPDestination.java:208)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(
ServletController.java:223)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
roller.java:205)
at
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpr
ingServlet.java:113)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
stractHTTPServlet.java:184)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractH
TTPServlet.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
HTTPServlet.java:163)
at
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run
(StubSecurityHelper.java:227)
at
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri
tyHelper.java:125)
at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:300)
at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:183)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.doIt(WebAppServletContext.java:3686)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:3650)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
121)
at
weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
ervletContext.java:2268)
at
weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
ontext.java:2174)
at
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j
ava:1446)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: javax.xml.soap.SOAPException: Unable to create message factory
for SO
AP: Provider org.apache.axis.soap.MessageFactoryImpl not found
at
javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:116)
at
org.drools.jax.soap.PreCxfTransportSoapProcessor.process(PreCxfTransp
ortSoapProcessor.java:40)
at
org.drools.camel.component.DroolsPolicy$DroolsProcess.process(DroolsP
olicy.java:341)
at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$Processor
ToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:70)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(Delegat
eAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsy
ncProcessor.java:89)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:70)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(Delegat
eAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsy
ncProcessor.java:89)
at
org.apache.camel.processor.interceptor.TraceInterceptor.process(Trace
Interceptor.java:99)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:70)
at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler
(RedeliveryErrorHandler.java:290)
at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryE
rrorHandler.java:202)
at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java
:256)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProc
essor.java:99)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:70)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(Delegat
eAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsy
ncProcessor.java:89)
at
org.apache.camel.management.InstrumentationProcessor.process(Instrume
ntationProcessor.java:68)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:91)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsy
ncProcessor.java:85)
at
org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:
97)
... 29 more
<Feb 26, 2012 3:58:31 PM CST> <Error> <HTTP> <BEA-101020>
<[ServletContext@12863
942[app:_appsdir_drools-5.3.0A_dir module:drools-5.3.0A path:/drools-5.3.0A
spec
-version:null]] Servlet failed with Exception
org.apache.camel.CamelExecutionException: Exception occurred during
execution on
the exchange: Exchange[Message: <batch-execution lookup="ksession1">
<insert out-identifier="message">
<org.test.Message>
<text>Hello World</text>
</org.test.Message>
</insert>
</batch-execution>
]
at
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(Object
Helper.java:1142)
at
org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper
.java:452)
at
org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(Defau
ltProducerTemplate.java:441)
at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProduce
rTemplate.java:119)
at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProduce
rTemplate.java:135)
Truncated. see log file for complete stacktrace
Caused By: org.apache.camel.CamelExchangeException: No consumers available
on en
dpoint: Endpoint[direct://kservice/rest]. Exchange[Message: <batch-execution
loo
kup="ksession1">
<insert out-identifier="message">
<org.test.Message>
<text>Hello World</text>
</org.test.Message>
</insert>
</batch-execution>
]
at
org.apache.camel.component.direct.DirectProducer.process(DirectProduc
er.java:56)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProc
essor.java:99)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:91)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsy
ncProcessor.java:85)
at
org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProdu
cer.java:63)
Truncated. see log file for complete stacktrace
Apparently the camel endpoint did not deploy at all, or something.
I'm wondering what of these issues are totally specific to WebLogic, and
which are just plain 'ole issues. Can anyone share their experiences or
expectations of using the drools camel server WAR within the various app
servers? How much are we expected to make custom changes?
--
View this message in context: http://drools.46999.n3.nabble.com/Some-problems-with-Deploying-drools-cam...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Knowing which constraints are broken for final best solution in drools-planner
by Manuel Aráoz
Hi! I'm new to this forum so... my name is Manuel and I'm using drools
planner to solve an exam scheduling problem :)
I need to analyze which constraints are broken while the algorithm is
running and when the solver finishes also. Geoffrey pointed me to the
examples, where that is done.
I copied the getScoreDetailList() idea from that example, and it works
perfectly fine for when the algorithm is running (constraints are found and
I can inspect them). The basic idea is that this method obtains the working
memory and obtains from it the objects of type ConstraintOccurrence.
The thing is, when the solver finishes and I call this method, it returns
no constraints, even though I know by the score that some constraints are
still broken. Am I doing something wrong? Or is this the expected
behaviour? It seems as if working memory erases the ConstraintOccurrences
when the solver finishes, but I don't really know. In that case, how can I
obtain the constraints broken for the final solution?
Hope I made myself clear! Thanks!
Manuel
12 years, 8 months
make the Guvnor interface into French
by freelance developpement
Hi every one,
For simplicity I must make the interface Guvnor for administration of
business rules, in French and not English under Internet Explorer or
Firefox.
Have you ant idea?
thanx in advance
12 years, 8 months
KnowledgeAgent Changeset problems
by albertorugnone
Hi all,
I have some problem with KnowledgeAgent, maybe you can help me. I will list
these in the following
1) during change set loading I have the following error
(null: 1, 207): schema_reference.4: Failed to read schema document
'drools-change-set-5.0.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>.
(null: 1, 207): cvc-elt.1: Cannot find the declaration of element
'change-set'.
(null: 1, 216): schema_reference.4: Failed to read schema document
'drools-change-set-5.0.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>.
(null: 1, 311): schema_reference.4: Failed to read schema document
'drools-change-set-5.0.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>
I suppose this is because change-set.xml can be reached. What is a correct
setting for xs:schemaLocation.
2) I would like scan also a directories in order to add knowledge to my rule
set if I add a new file. How I can do that?
3) KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.newInstance", "true") <== what is the
meaning of this property? Where I can find documentation about those
properties
4) why when I would set a global variable I receive
Exception in thread "main" java.lang.RuntimeException: Unexpected global
[service]
at
org.drools.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:615)
at
org.drools.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessionImpl.java:332)
at
com.sample.DroolsKnowledgeAgentTest.main(DroolsKnowledgeAgentTest.java:90)
I the following an example about my question
@SuppressWarnings("restriction") public class DroolsKnowledgeAgentTest {
public static class Service {
}
DroolsKnowledgeAgentTest() {
KnowledgeBase newKnowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
ResourceFactory.getResourceChangeNotifierService()
.start();
ResourceFactory.getResourceChangeScannerService()
.start();
final ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService()
.newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "2");
ResourceFactory.getResourceChangeScannerService()
.configure(sconf);
final KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.scanDirectories", "true");
aconf.setProperty("drools.agent.scanResources", "true");
aconf.setProperty("drools.agent.newInstance", "true");
final KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent("pch.sel.knowledge.agent",
newKnowledgeBase, aconf);
// if (_l.isDebugEnabled()) {
/* we need some log every time */
agent.setSystemEventListener(new PrintStreamSystemEventListener());
// }
}
public static void main(String[] args) throws IOException {
ResourceFactory.getResourceChangeNotifierService()
.start();
ResourceFactory.getResourceChangeScannerService()
.start();
String xml = "";
xml += "<change-set xmlns='http://drools.org/drools-5.0/change-set'";
xml += "
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
xml += "
xs:schemaLocation='http://drools.org/drools-5.0/change-set
drools-change-set-5.0.xsd' >";
xml += " <add> ";
xml += " <resource
source='Z:/WSP/drools-test/src/main/java/com/sample/rule1.drl' type='DRL'
/>";
xml += " </add> ";
xml += "</change-set>";
FileManager fileManager = new FileManager();
File fxml = fileManager.newFile("changeset.xml");
BufferedWriter output = new BufferedWriter(new FileWriter(fxml));
output.write(xml);
output.close();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService()
.newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "2");
ResourceFactory.getResourceChangeScannerService()
.configure(sconf);
KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.scanDirectories", "true");
aconf.setProperty("drools.agent.scanResources", "true");
aconf.setProperty("drools.agent.newInstance", "true");
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("test
agent", kbase, aconf);
kagent.applyChangeSet(ResourceFactory.newUrlResource(fxml.toURI()
.toURL()));
StatefulKnowledgeSession ksession = kagent.getKnowledgeBase()
.newStatefulKnowledgeSession();
ksession.setGlobal("service", new Service());
}
}
and rule named rule1.drl
#created on: 29-Feb-2012
package com.sample
#list any import classes here.
#declare any global variables here
global DroolsKnowledgeAgentTest.Service service;
rule "Your First Rule"
when
#conditions
then
#actions
end
Thank you very much for your answers and kind regards
Alberto
--
View this message in context: http://drools.46999.n3.nabble.com/KnowledgeAgent-Changeset-problems-tp378...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months