Is it safe to 'build' a knowledgebase (compile rules) in a web app?
by groovenarula
Hello,
In our environment we need to develop a framework wherein we would have
about a dozen rule templates whose data will be provided by users using
spreadsheets. Basically users will upload excel workbooks containing 10-12
worksheets and we'll be using ExternalSpreadsheetCompiler to generate the
appropriate DRLs that will then be 'add'ed to a KnowledgeBuilder class to
create a KnowledgeBase. We need to provide this capability use a web
application deployed in Tomcat.
Question - Are KnowledgeBuilder/ExternalSpreadSheetCompiler thread safe ? Is
it safe to develop this KnowledegeBase build process in a web application ?
If these classes are not thread safe, can someone please advise me on how to
make this framework single threaded ? It's perfectly acceptable for the
framework to be single threaded (essentially if more than a single session
tries to upload a workbook, they will have to wait a few mins if there are
other workbooks being processed ahead of theirs). I know the last question
is not drools centric, but it would be great to hear from the gurus on how
best I can make the build/compile process single threaded.
Please let me know if this is a safe approach to take or if there are ways
to make this approach safe !
Thanks in advance,
-G
--
View this message in context: http://drools.46999.n3.nabble.com/Is-it-safe-to-build-a-knowledgebase-com...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
global identifier
by Bobby Richards
Is there a way to create a 'global' that is completely specific to a drl
file rather than the working memory? I only wish to use this in rhs
notification/persistence operations, ie passing a user's unique id to a db
or sms operation.
I know this does not work but perhaps it will help to better illustrate my
question:
global int user_id = 123;
...
then
notification.sendSMS(user_id);
12 years, 7 months
Performance boost separating accumulates or removing typecasting
by ploaiza
I wanted to find out if anyone has a comment on what would increase the
performance of the rules more.
1. Removing the typecasting from strings to enumerations back to strings for
1/3 of all the rules
2. Splitting a rule that gets executed for every request multiple times with
4 accumulates with sum into 4 different rules with single accumulates with
sum
My guess is that the second one would increase the performance more because
keeping all the accumulates in one rule, every time the first accumulate
changes, the other accumulates would have to be recalculated. This could
exponentially affect the performance.
Any comments on this would be greatly appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/Performance-boost-separating-accumulate...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Using Enum list in the guvnor
by Sean Su
Has anyone here successfully used Enum in the guided editor in Guvnor?
I am trying to build a patter with the following pseudo condition but could
not get the Enum list displayed in the drop down of the Enum:
"There is an Event with Event.type (Enum EventType) equal to
EventType.someType".
Here, someType is one of the enum defined in EventType.java.
Event.java has getType() method returns EventType.
Everything seems working fine, exception in the drop down of EventType,
there is no enum defined. It only has the standard API from Enum listed
there.
Any input is appreciated.
Thanks
Sean
12 years, 7 months
Best way to write a rule where pattern has multiple constraints
by larryc
I was reviewing some of our DRLs and noticed some rules written like this:
when
RuleContext(billingSystem == "ABC")
RuleContext(policyStatus == "active")
RuleContext(renewalDueDate != null)
then ...
while others were written this way:
when
RuleContext(billingSystem == "ABC", policyStatus == "active",
renewalDueDate != null)
then ...
There should only be one RuleContext fact in the knowledge base at one time.
Which approach is better? Is one approach more efficient for Drools than
the other? Does it matter?
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Best-way-to-write-a-rule-where-pattern-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Re: [rules-users] Existence of feasible solution for planner problem
by ge0ffrey
YuraK wrote
>
> I'm new in Drools Planner. I'm investigating the Hospital bed planning
> (PAS - Patient admission scheduling) problem,
> I'm interesting about an existence of feasible solution for the current
> problem.
>
> The idea is follow:
> 1) Doctor/User is sending a request (booking bed for patient). The drools
> planner application is checking if the feasible solution still exists
> after the adding of new problem facts.
> - if solution exists then user will retrieve a response that the request
> has been handled by the application
> - if solution doesn't exist then user will retrieve a response that the
> request can't be handled by the application
>
> 2) At the end of day the main optimization procedure is running by Drools
> Planner and all user retrieve the detail messages about the booked bed in
> the hospital (e.g information about the bed location).
>
>
> *Does it possible to check somehow (at the first stage) if the feasible
> solution exists (all hard and soft constraints are satisfied) without
> running the main(general) optimization procedure and spending a lot of
> time for the getting response ?
>
No, the problem is NP complete, which means that no algorithm in the world
today can guarantee that a feasible solution exists for an arbitrary dataset
in reasonable time.
More info for this old, 1 billion dollar question:
http://en.wikipedia.org/wiki/P_versus_NP_problem
But that doesn't mean we can't answer that question fast with good accuracy:
1) Run planner in real-time. See last part of this video:
http://vimeo.com/25902052
2) Add new data as soon as it comes in
3a) If the real-time planner finds a feasible solution, notify the user that
it's ok. Like in the video, this should be in milliseconds on seconds. There
are no false positives.
3b) If the real-time planner doesn't find a feasible solution in 5 seconds,
notify the user that it's not ok. This might be a false negative, but if
you'd let a human planner do the same task, he would output far more false
negatives.
YuraK wrote
>
> *I want to avoid the situation when the user send the request and waiting
> a lot for the response if the request has been accepted by the
> application.
>
> *Does it possible to solve the problem via termination conditions?*
> For example: after some steps of drools planner (e.g. 1000 steps) the
> score is still not a zero (not all conditions are satisfied) then can i be
> sure that feasible solution doesn't exists?
>
No (see wikipedia link above). No algorithm today will be able to answer
that with 100% accuracy in reasonable time as the problem scales out. But
given some time, planner can easily get to a 99% accuracy. How much time?
That depends on your use case: Use Planner's Benchmarker toolkit to prove by
sampling that you have such an accuracy.
YuraK wrote
>
>
> I will be appreciated if somebody provides some similar examples or ideas
> how to handle this situation.
>
> Thanks.
>
--
View this message in context: http://drools.46999.n3.nabble.com/Existence-of-feasible-solution-for-plan...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Can i see a Decision Table in Tempate (like:each row one Decision Table)
by srinivasasanda
Hi
I have a doubt Please let me know whether it is possible or not.
There is a option in guvnor create "new rule template" (here we are creating
new rule by using WHEN & THEN options), So my doubt is when i click new
rule template i want to get "Decision Table" format like
Decision table
|
|->Condition Columns
|->Action columsn
|->options
---------here decision table----------------
I want to see above options when i click new rule template.
So, If it possible means each row in template in can see one Decision Table.
Thanks,
Sanda
--
View this message in context: http://drools.46999.n3.nabble.com/Can-i-see-a-Decision-Table-in-Tempate-l...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Drools crash on simple drl
by Shur, Bob
I'm repeating this post because I didn't get an answer last time. Is this the wrong place to report a bug? If so, where is the right place? I'm trying to understand whether this is really a bug or whether I'm doing something wrong.
I have what looks to me like a Drools bug on a simple drl with declared classes. I'm using version drools-distribution-5.3.0.Final.
I'm invoking it with this:
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
List<Object> facts = new ArrayList<Object>();
ksession.execute( facts );
=============================
I get this crash:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sample/Cap
at ASMAccessorImpl_129541121334339192620.getValue(Unknown Source)
at org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAccessor.java:73)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:103)
at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:42)
at org.mvel2.MVEL.executeExpression(MVEL.java:952)
...
==========================
Here's the drl file:
package com.sample
import com.sample.*;
declare Item
id : int;
end
declare Priority
name : String;
priority : int;
end
declare Cap
item : Item;
name : String
end
rule "split cart into items"
when
then
insert(new Item(1));
insert(new Item(2));
insert(new Item(3));
end
rule "Priorities"
when
then
insert(new Priority("A", 3));
insert(new Priority("B", 2));
insert(new Priority("C", 5));
end
rule "Caps"
when
$i : Item()
$p : Priority($name : name)
then
insert(new Cap($i, $name));
end
rule "test"
when
$i : Item()
Cap(item.id == $i.id)
then
System.out.println("Cap");
end
====================
Some observations:
- If I comment out any of the insert lines, the crash goes away
- If I change the first field of class Cap to be id:int instead of item:Item and make the corresponding changes, the crash goes away
12 years, 7 months
Re: [rules-users] Function call in LHS
by San
Hi
I am trying to cal a local function getMaturityAge() in the decision table
condition column like
RuleTable MaturityAge Validation
CONDITION
ACTION
pp:PremiumCalculatorFormBean
getMaturityAge() > "$1"
System.out.println("invalid maturity age");
Premium Payment Term Print out
message?
70 X
The method is defined localy using functions key word.
And moreover whenever I trying to pass pp as the argument to my functions,
its not able to find pp. I am getting cud not parse knowledge error.
can anyone pz help me out.
--
View this message in context: http://drools.46999.n3.nabble.com/Function-call-in-LHS-tp56345p3919318.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months