java script to drl
by G S
I have a source code written in Java script but I want that logic to
be written in .drl (drools). Any guidelines, or ideas how I can
convert java script to rules?
sample source code attached.
13 years
Drools Planner Beginner
by cmcl79
Hi,
I'm a beginner to Drools planner. I think it has everything I need to solve
my staff and user scheduling problems.
At the moment I have worked out how to edit the xml files in the nurse
rostering problem to begin to shape my problem. However the xml is very
intrecate and I don't think I will be able to morph this example to exactly
match my problem. Is there any way I can generate my own xml files to encode
my exact problem?
I'm a complete beginner to Drools and to programming.
Many thanks,
C
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Planner-Beginner-tp3601171p36011...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years
Working memory batch insert performance
by Zhuo Li
Hi, folks,
I recently did a benchmark on Drools 5.1.2 and noticed that data insert into
a stateful session is very time consuming. It took me about 30 minutes to
insert 10,000 data rows on a 512M heapsize JVM. Hence I have to keep
inserting data rows when I receive them and keep them in working memory,
rather than loading them in a batch at a given time. This is not a friendly
way for disaster recovery and I have two questions here to see if anybody
has any thoughts:
1. Is there any better way to improve the performance of data insert
into a stateful session;
2. I noticed that there is a method called BatchExecution() for a
stateless session. Did not get a chance to test it yet but is this a better
way to load data in a batch and then run rules?
My requirement is I need to load a batch of data once by end of the day, and
then run the rules to filter out matched data against unmatched data. I have
a 3-hour processing window to complete this loading and matching process,
and the data I need to load is about 1 million to 2 millions. My JVM
heapsize can be set up to 1024 M.
Best regards
Abe
13 years
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
13 years
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
13 years
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.
13 years
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.
13 years
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.
13 years
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.
13 years, 1 month