Poor performance from a simple join
by David Martin
Folks:
My co-workers and I have been using Drools to great success, but we ran smack into a performance brick wall recently.
In the example below, both BINNING_INPUT and LU_DEVICE_TYPE have large numbers of associated facts in working memory (BINNING_INPUT has more than 8 million facts in working memory, LU_DEVICE_TYPE about 10k.)
LU_DEVICE_TYPE models a lookup table.
rule "Binning for Attribute: Device_type_desc"
when
$call :
BINNING_INPUT()
$device_typeLookup :
LU_DEVICE_TYPE(
$call.device_type == device_type
)
then
$call.setDevice_type_desc($device_typeLookup.getDevice_type_desc());
end
It's a simple enough rule: join on the device_type field. Unfortunately, this rule and a few others like it are taking FOREVER to insert. Even when I cut the number of BINNING_INPUT facts in working memory down from 8M to 10k.
This feels like a basic Drools question. But I can't seem to find any help from google.
Please advise!
Thanks in advance,
Dave Martin
14 years, 6 months
Multiplying the count of each score rule
by Patrik Dufresne
Hi,
I'm still in process to model my planning problem and I have some
difficulties in defining the correct weight of soft constraints. I have
soft constraints with different priorities : C1, C2, C3, ..., Cn where C1
are higher then C2. Currently, I've tried to set different weight for each
of them : C1 get higher weight. But it's not sufficient since multiple C2
may balance one C1. What I really need is to set the priority to every soft
constraints.
Solution #1 :
My first thought it to implement a new score definition
(HardAndSoftPriorityScoreDefinition) having separate soft score for each
priority. The rule may insert ConstraintOccurence by defining the weight
and the priority. This solution seems elegant but require effort to
implement the score definition, the score calculation, and other things I
don't even know about.
Solution #2 :
The other solution is stated in the Drools Planner User Guide :
"Most use cases will also weigh their constraints differently, by
multiplying the count of each score rule with its weight. For example in
freight routing, you can make 5 broken "avoid crossroads" soft constraints
count as much as 1 broken "avoid highways at rush hour" soft constraint.
This allows your business analysts to easily tweak the score function as
they see fit."
Even tough I don't know how to implement this, it's seems much easier to
achieve since it's only a rule. Compare to solution #1, it's lack the
support of soft constraints with same priority but different weights.
What is your opinion about both solution.
Is one faster then the other ?
Is it hard to create a new score definition ?
Did anyone ever did this ?
--
Patrik Dufresne
14 years, 6 months
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, 6 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, 6 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, 6 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, 7 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, 7 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, 7 months