pattern binding and eval()
by Harris
Hi,
I have a question regarding pattern binding and eval().
The following rule calculates 4 different sums from a list of
"Positions" and determines whether the ratio of the first 2 sums
is smaller than the ratio of the latter 2 sums.
The first version reads quite intuitively but it uses
eval() which - as far as I gather from the docs - should
be avoided whenever possible.
The second version doesn't use eval() since it binds to a
patten, namely the "Number" that represents the sum A1. But the
relation cannot be seen as clearly as in version1.
Is there another, more elegant way to write this rule which I miss?
And does the use of eval() in this case come with any perfomance
or other drawbacks?
Thanks for your help!
Harris
# ---------------------
rule "Test-version1"
when
Number( $sumA1: doubleValue ) from accumulate( Position( posType == "A1",
$val : value ), sum( $val ) )
Number( $sumA2: doubleValue ) from accumulate( Position( posType == "A2",
$val : value ), sum( $val ) )
Number( $sumB1: doubleValue ) from accumulate( Position( posType == "B1",
$val : value ), sum( $val ) )
Number( $sumB2: doubleValue ) from accumulate( Position( posType == "B2",
$val : value ), sum( $val ) )
eval ( ($sumA1 / $sumA2) < ($sumB1 / $sumB2));
then
System.out.println("Ratio A smaller than ratio B !");
end
# ---------------------
rule "Test-version2"
when
Number( $sumA2: doubleValue ) from accumulate( Position( posType == "A2",
$val : value ), sum( $val ) )
Number( $sumB1: doubleValue ) from accumulate( Position( posType == "B1",
$val : value ), sum( $val ) )
Number( $sumB2: doubleValue ) from accumulate( Position( posType == "B2",
$val : value ), sum( $val ) )
Number( doubleValue < (($sumB1/$sumB2)* $sumA2) ) from accumulate(
Position( posType == "A1", $val : value ), sum( $val ) )
then
System.out.println("Ratio A smaller than ratio B !");
end
# ---------------------
--
View this message in context: http://drools.46999.n3.nabble.com/pattern-binding-and-eval-tp3597935p3597...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Re: [rules-users] Drools Planner intro
by ge0ffrey
ssandban wrote
>
> Are there and hardware or memory requirements for using planner in solaris
> environment
>
I like to use a max memory of 512M, but most examples (which have real-sized
data, see reference manual for numbers) run fine with far less memory (the
default of 64M is fine IIRC).
Planner holds about 2-4 solutions in memory (and in future versions this
might go up to 20-30 solutions), so that's peanuts. There is only 1
optimization algorithm, namely "Solution Tabu Search" which is activated
with "solutionTabu", usually set at a 1000, that uses more memory. But
almost all the examples do that and that's still no problem. Avoid that if
you really want to scale down memory.
Network bandwidth isn't used by Planner.
As for CPU: the more CPU speed, the better :) Do note that better algorithms
win versus more CPU any time. You can't solve planning problems by throwing
hardware at them.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Planner-intro-tp3164587p3597805....
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
WorkingMemoryFileLogger question
by jkrupka
Am I totally missing something or is there not a way to stop logging of a
stateful ks once you start doing so via the WorkingMemoryFileLogger (at
least in Drools 5.2)?
The Event Listeners that get registered when the file logger get created
don't seem to ever be unregistered, and calling classes don't even have the
visibility into the internals of the file logger in order to do so
themselves.
The use case for this is if you have a long running stateful session and you
want to turn on logging just for a short period of time to collect some
information, then turn logging off again. The only way I know of doing this
currently is to reload the whole session.
--
View this message in context: http://drools.46999.n3.nabble.com/WorkingMemoryFileLogger-question-tp3591...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
sun.io.MalformedInputException when accessing the drools from War file
by Srinivasa Rao Kodi
Hi All,
We have implemented business logic with the drools (5.2.0). I have export
this project as jar file and placed in web module in WEB-INF/lib folder.
When we test this drools jar from web module in local machine, it is
working fine and accessing the rules file.
But when export this war file to DEV box (that is running in Windows) and
try access to the drools, we are getting the following exception.
16 Dec 2011 14:27:13 ERROR EligibilityImpl:87 - Error Message
is...java.lang.RuntimeException: Unable to parser Reader
at org.drools.compiler.DrlParser.getParser(DrlParser.java:314)
at org.drools.compiler.DrlParser.parse(DrlParser.java:142)
at org.drools.compiler.DrlParser.parse(DrlParser.java:148)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:275)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:451)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at
gov.il.dhs.ccms.impl.EligibilityImpl.readKnowledgeBase(EligibilityImpl.java:251)
at
gov.il.dhs.ccms.impl.EligibilityImpl.executeEligibilityRules(EligibilityImpl.java:72)
at
gov.il.dhs.ccms.eligibility.EligibilityServiceImpl.getEligibilityResults(EligibilityServiceImpl.java:116)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at
flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:418)
at
flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
at
flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1400)
at
flex.messaging.AsyncMessageBroker.routeMessageToService(AsyncMessageBroker.java:563)
at
flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:1005)
at
flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:103)
at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
at
flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
at
flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:166)
at
flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291)
at
flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:353)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:592)
at
com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:525)
at
com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:751)
at
com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)
at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:126)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at
com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:196)
at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:751)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:881)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)
Caused by: sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java:262)
at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:316)
at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:366)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:252)
at java.io.InputStreamReader.read(InputStreamReader.java:212)
at java.io.Reader.read(Reader.java:143)
at org.drools.io.impl.ReaderInputStream.read(ReaderInputStream.java:122)
at java.io.InputStream.read(InputStream.java:113)
at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:354)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:252)
at java.io.InputStreamReader.read(InputStreamReader.java:212)
at org.antlr.runtime.ANTLRReaderStream.load(ANTLRReaderStream.java:82)
at org.antlr.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:68)
at org.antlr.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:52)
at org.antlr.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:48)
at org.antlr.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:40)
at org.drools.compiler.DrlParser.getParser(DrlParser.java:309)
... 43 more
The project structure of drools projects is :
/src
-- gov
--il
-- dhs
-- rules
-- abc.drl
I have added the drl file to KnowledgeBuilder like this
kbuilder.add(ResourceFactory.newClassPathResource("
gov/il/dhs/ccms/rules/Eligibility.drl"), ResourceType.DRL).
I added InputSteamReader with encoding type "UTF-8" also, it is working
in local but not in DEV box.
Could u please help us to solve this issue.
14 years, 3 months
How to install and configure the oryx designer in Drools-guvnor ?
by Manohar Kokkula
Hi to all,
I followed all the steps given in the link
https://blog.athico.com/2010/09/bpmn2-authoring-int-drools-guvnor.html
but when i am trying to create the process in Guvnor I am getting
following error:
HTTP Status 404- /designer/editor/
type Status report
message /designer/editor/
description The requested resource (/designer/editor) is not available
JBoss Web/2.1.1.GA.
and also I am unable to open the designer through browser
I got above same error in browser.
Please any one help me.
Thanks and regards
Manohar Kokkula
Mailto: manohar.kokkula(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
14 years, 3 months
Can we make our kbase object available from one context to another context (one application to another webservice)
by srinivasasanda
Hi Sir,
I have another Problem Please try to give some suggestion.
how can i provide my Kbase object loaded with all packages is at one
context , and can i make it available to other context applications or
webservices
Ex:My actual scenario is :I created all my rules and loaded my application
as
KnowledgeBuilder kbuilder1 = KnowledgeBuilderFactory.newKnowledgeBuilder();
KnowledgeBase kbase1 = readKnowledgeBase();
// Like this i added some 50 packages and build single kbase haveing 15000
rules
kbuilder1.add(ResourceFactory.newUrlResource("http://localhost:8082/guvnor-5.3.0.Final-jboss-as-5.1/org.drools.guvnor.G..."),ResourceType.PKG);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder1.getKnowledgePackages());
This code i made it as .sar file,so it loads automatically when server
start up without user control --
which is loaded is in one context, as per my understanding kbase object is
present in that context.
Now can I make that kbase object available to web service which is present
in some other context(some other application) , so that web service can make
use of kbase which is already available (Instead of creating and loading
new kbase)..
So far,you suggested so many solutions.Hope you will help me to get out of
this problem.
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Can-we-make-our-kbase-object-available-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Eval0Invoker : java.lang.NullPointerException
by Venkat
Hi, I am new to Drools and I have read about it and not mastered yet. I have
written some rules and junit to test it. The rules works good and passes the
test if ran individually, but if ranned all at once with one junit test case
with all the test cases in it, it is through this exception.
Please find the stack trace.
com.ge.energy.drms.smartgrid.datamodel.services.enddevicemanagement.pandeviceregistrationservice.PANDeviceRegistrationServiceFault:
com.ge.energy.drms.external.integration.service.impl.Rule_PAN_Device_Smart_Device_Model_Device_Class_null_ruleEval0Invoker@1e87bc80
: java.lang.NullPointerException
at
com.ge.energy.drms.external.integration.service.impl.PANDeviceRegistrationServiceImpl.provisionPANDevice(PANDeviceRegistrationServiceImpl.java:108)
at
com.ge.energy.drms.external.integration.service.impl.test.ProvisionPanDeviceRequestValidationTest.testMACAdress(ProvisionPanDeviceRequestValidationTest.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
com.ge.energy.drms.external.integration.service.impl.Rule_PAN_Device_Smart_Device_Model_Device_Class_null_ruleEval0Invoker@1e87bc80
: java.lang.NullPointerException
I have googled on this and found that, it might not be able to take all the
rules, one by one, and execute it. As I said I am new to Drools, I am not
able to work on this.
Please help me on this.
Thanks,
Venkat.
--
View this message in context: http://drools.46999.n3.nabble.com/Eval0Invoker-java-lang-NullPointerExcep...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months