Pattern aggregation
by Tim 4076
Hi,
I'm trying to use drools to do grouping of data according to patterns
defined in my rules, but I'm having issues creating something that works in
a reasonable amount of time (seconds). I've tried all sorts of permutations
without much luck and would like to hear how others would do the same thing.
To give an example: I've got a big batch of transaction records and I want
to aggregate all the records where the consumer id and product category are
the same and the purchases were made within an hour of each other.
The fact that its matching the same values between facts, rather than
against constants seems to scupper it somewhat.
I would go down the ETL route, but the idea is for non-techies to define
their own aggregations using rules.
-Cheers. Tim
15 years, 5 months
Drools source build with error
by 赵侃侃
Hi,
I'm entirely new to the Drools. I downloaded the drools source today at
http://download.jboss.org/drools/release/5.1.1.34858.FINAL/drools-5.1.1-s...
.
I unpacked it and when I tried to build it myself with maven, I got the
following error:
e:\Java\drools>mvn install
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: unknown
Reason: Could not find the model file 'E:\Java\drools\osgi-bundles'. for
project unknown
[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Could not find the model
file 'E:\Java\drools\osgi-bundles'. for proje
ct unknown
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.ProjectBuildingException: Could not find
the model file 'E:\Java\drools\osgi-bundles
'. for project unknown
at
org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1575)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.ja
va:506)
at
org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
at
org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
at
org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:560)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
... 12 more
Caused by: java.io.FileNotFoundException: E:\Java\drools\osgi-bundles
(系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at
hidden.org.codehaus.plexus.util.xml.XmlReader.<init>(XmlReader.java:124)
at
hidden.org.codehaus.plexus.util.xml.XmlStreamReader.<init>(XmlStreamReader.java:67)
at
hidden.org.codehaus.plexus.util.ReaderFactory.newXmlReader(ReaderFactory.java:118)
at
org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1570)
... 18 more
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Oct 18 17:23:07 CST 2010
[INFO] Final Memory: 6M/12M
[INFO]
------------------------------------------------------------------------
It appears to me that the child module osgi-bundles doesn't exist under the
top level directory.
Can someone please advise me how I can successfully build from the source?
Best Regards,
Kevin Zhao
15 years, 5 months
Rule tasks and gwt-console
by Juan Ignacio Barisich
Hello,
I'm working with the gwt-console, and I have two questions:
1) How to get access and add facts the knowledge session ?
2) Is there only one knlowledge session for all the process instances ?
I have a process with a "Rule Task" node. Within the rule I have to access
to the process variables. So, I want to add the process instance to the
knlowledge session.
Then, the rule (in this consecuence) inserts a fact to the knowledge
session, so a later gateway can take a desicion rule-based. But, is there
only one knlowledge session for all the process, this logic will fail. In
this way, it would be better to have one knowledge session instance per
process instance.
Thanks in advance.
--
*Juan Ignacio Barisich*
juan.barisich(a)fluxit.com.ar
www.fluxit.com.ar
53 n366, piso 9
La Plata / Buenos Aires / Argentina
(54)-221-427-5781 int:308
15 years, 5 months
Query about performance in using data as fact or using it as Global variable
by Nikhil S. Kulkarni
Hi ,
I am using drools 5.0 in application. I am facing performance issues. I am using drls, rule flows and rule templates.
My scenario is as follows :-
Consider there is list of 20 companies.
There are about 20000 members in each company.
Now I have several rules in which condition is for specific member and specific company.
e.g.
rule 1
when comp : company
and member : Members
then
.........
End;
So similarly I passed Member list and company list as fact. But it was time consuming process.
So I have done one change.
I kept only comp:company in when condition of rule as I explained above and declare member list as global .
I created a function in rule in which I am iterating over member list and doing the same process.
Now this is taking less time.
Now my question is how efficient is this change.
Though we say that when we write specific condition in rule then it will be fired only in that case.
But when I use Agenda Event Listener class,
I come to know one thing that it creates activation-created for all possible conditions then it will fire activation-Fired for specific condition
And after that it will cancel all the activations.
So as I reduced member level fact condition my time is reduced drastically and performance improved.
So anybody can suggest me that whether I am on right track of improving time and performance or not ?
Waiting for reply.
Thanks & Regards,
Nikhil S. Kulkarni
MASTEK LTD.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 years, 5 months
Exception Handling in the rule consequence
by sumatheja
Hi All,
I have a set of rules. After firing the rules if an exception occurs
in a rule the following rules are not getting evaluated. So i tried writing
a try catch block inside the consequence part of the rule, but then i get an
error saying "'unable to build the consequence.[Error:was expecting type:
java.lang.Object but found type:null]"
Here follows my code
*rule 'Test rule'
ruleflow-group "Test Ruleflow"
no-loop
when
$c:Car()
Driver()
then
try{
$c.getModel()
} catch (Exception Ee) {
System.out.println("caught an exception: "+Ee.toString());
}
end*
However if i remove the try catch block it buils fine.
Can anyone let me know if i'm missing something here.
Thanks in advance :)
--
cheers
Sumatheja
15 years, 5 months
xdrl, null and nested properties
by Veit Guna
Hi.
I'm using Drools 5.1.0 along with .xdrl files. Now I have the problem
with the following sippet:
--cut here--
<dro:and-conditional-element>
<dro:pattern object-type="TaskResults">
<dro:field-constraint field-name="lastResult">
<dro:literal-restriction evaluator="!=" value="null"/>
</dro:field-constraint>
<dro:field-constraint
field-name="lastResult.returnValues["ReturnKey"]">
<dro:literal-restriction evaluator="==" value="returnvalue"/>
</dro:field-constraint>
</dro:pattern>
</dro:and-conditional-element>
--cut here--
It compiles just fine, but when executed it fails with:
Caused by: org.drools.RuntimeDroolsException: Exception executing
predicate lastResult.returnValues["ReturnKey"] == "returnvalue"
Caused by: [Error: unable to access property (null parent): returnValues]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:886)
It seems that the second field constraint is also evaluated, although
the first should already return "false". Are there no short-circuits
within pattern constraints? How would I express that best in xdrl
conform manner? Use eval?
Thanks
Veit
15 years, 5 months
Re: [rules-users] Check if fact is subset of items in the rule
by Michael Anstis
Thanks, please provide a specific example rule too.
Don't forget to keep your posts to the mailing list for the good of the
community.
On 12 October 2010 22:18, Kumar Pandey <kumar.pandey(a)gmail.com> wrote:
> Michale
> Thanks for the response.
> Here's the link for the thread .
>
>
> http://drools-java-rules-engine.46999.n3.nabble.com/Check-if-fact-is-subs...
>
> and the original about matching strings in two arrays.
>
> http://drools-java-rules-engine.46999.n3.nabble.com/Matching-strings-in-t...
>
>
> My use case is that I could have hundreds of rule and each rule could have
> its own set of strings.
> A fact object is run through these rules to see which ones are fired.
> One of the condition to check is that the a list in the fact is not a
> subset of list in the rule.
> That is fire the rule only if list in fact is not a subset of list in rule.
>
> Thanks
> Kumar
>
>
> On Tue, Oct 12, 2010 at 12:38 PM, Michael Anstis <michael.anstis(a)gmail.com
> > wrote:
>
>> OK, I admit I don't have the original thread anymore.
>>
>> If I am not wrong (which is always a possibility) for Wolfgang's operator
>> to work you'd need to externalise the superset from the rule into
>> WorkingMemory. You could have a rule with higher salience construct the
>> superset WM fact.
>>
>> If you don't mind re-posting or providing a link to the complete thread
>> (on Nabble or somewhere) I'll happily try to help further.
>>
>> On 12 October 2010 17:23, <kumar.pandey(a)gmail.com> wrote:
>>
>>> <quote author='Michael Anstis-2'>
>>>
>>> Wolfgang gave a great solution.
>>> </quote>
>>> Don't know if I'm missing something obvious here. I have a superset in
>>> the rule itself. Each rule has a superset list. In this case how would I use
>>> Wolfgang's solution. Its comparing through two arrays in runtime. I have not
>>> been able to construct an array construct with specific values in the rule
>>> itself.
>>>
>>
>>
>
>
15 years, 5 months
How to Capture the rule which does not get executed
by Navdeep Kumar
Hi All,
I am new to Drools. I am working on a project where nature of rules are
dynamic. I want to capture that rule which does not get executed. i need to
store that rule because i have to display that rule in the UI.
Here is my rule file
rule "FrontAxle:Capacity|FrontSuspension:Capacity"
when
b:Feature(featureClass.name=="FrontSuspension")
c:Feature(featureClass.name=="FrontAxle")
//eval(b.getCapacity() >= c.getCapacity())
then
System.out.println("These are compatible");
System.out.println(b.getFeatureClass().getName());
availablity.put(b.getFeatureClass().getName()+"-"+c.getFeatureClass().getName(),"12.35");
//availablity.put(b.getName()+"-"+c.getName(),new Double(b.getCapacity()));
insert(availablity);
end
rule "FrontSuspension:Type|FrontAxle:Type"
when
b:Feature(featureClass.name=="FrontSuspension")
c:Feature(featureClass.name=="FrontAxle")
not Feature(b.attributes.Type=="I Beam" && c.attributes.Type=="Multi Link
Air")
//NOT (FrontAxle.type = "I-Beam" AND FrontSuspension.type = "Multi-link
Air") - mounting restriction
then
System.out.println("I am in 2");
end
rule "FrontAxle:FeatureCode|FrontSuspension:Type"
when
b:Feature(featureClass.name=="FrontSuspension")
Feature(featureClass.name=="FrontAxle" && code=="002ASW")and not
Feature(b.attributes.Type=="Multi Link Air" || b.attributes.Type=="Monoleaf
Spring")
//FrontAxle.featureCode = "002ASW" AND NOT (FrontSuspension.type =
"Multi-link Air" OR FrontSuspension.type = "Monoleaf Spring")
then
System.out.println("I am in 3");
end
now if these two objects named FrontAxle and FrontSuspension are compatible
then it has to meet all the 3 rules, but if any combination of these objects
does not meet one of the rule listed above then i have to store the rule for
the displaying purpose that this combination didn't meet this rule thats why
they are not compatible. any kind of help will be appreciated.
Thanks.
15 years, 5 months
re-fire all rules
by Yaniv Itzhaki
Hi there,
Is there a way to "reset" the working memory so that all the rules will
run again when fireAllRules() is called? (I am running the startProcess
method number of times with the same working memory)
I know that normally rules will only be run again when there was a change
and the fact was updated. but in my case I like to run all rules again
in some situations without having a change on the facts.
so is there a way to do this?
Thanks
Yaniv
15 years, 5 months