Re: [rules-users] Get rid of redundant conditions in combined rules.
by Leonardo Gomes
If your problem is performance, don't worry. Conditions evaluation is
shared, so in the second rule you won't re-evaluate the entire working
memory (to know more:http://www.drdobbs.com/184405218).
If you're worried about not having to repeat the conditions on the second
rule, I would create inferred facts when the first rule matches and use then
in the second rule + the additional conditions.
Something like:
Rule1:
when
customer:Customer(town=="London")
then
insert new LondonCustomer( customer );
Rule2:
when
london : LondonCustomer(customer.job=="TEACHER")
then
System.out.println(london.customer.getLname() + " is a
teacher");
2010/10/12 Dominik Hüttner <d.huettner(a)tiq-solutions.de>
> Hello everyone,
>
> I’ve got a question. I’m using drools-guvnor to execute some
> rule-scenarios. I have to solve the following problem: I have an amount of
> objects in my working memory and can’t remove objects from the working
> memory in the then-part of the rule. I want to combine two rules, the first
> rule selects some objects and the second rule checks only these selected
> objects for additional criteria. I have to use two rules, because I want to
> report the objects selected in the first rule, too. Now I have implemented
> this with two rules and in the second rule, the criterias of the first rule
> are copied to the second rule, my question is, is there a way to get rid of
> this redundandance?
>
> I have tried this with a rule flow, but the problem is, this always works
> on the whole working memory, but I can’t remove the not used objects from
> working memory for performance reasons. Is there another way to solve this
> problem?
>
>
>
> Here is an example for what I intend to do:
>
>
>
> Rule1:
>
> when
>
> customer:Customer(town=="London")
>
> then
>
> System.out.println(customer.getLname() + " is inhabitant of
> London");
>
>
>
> Rule2:
>
> when
>
> customer:Customer(town=="London",job=="TEACHER")
>
> then
>
> System.out.println(customer.getLname() + " is a teacher");
>
>
>
> This example illustrates, with the first rule I want to get to know, how
> many customers are from London and in the second rule I want to know, how
> many of the London customers are teachers. I want to create a kind of
> statistics. I have quite a lot of conditions for the first rule, so I don’t
> want to have them redundantly.
>
>
>
> Greetings, Dominik
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
15 years, 7 months
Re: [rules-users] install drools5.2.0.SNAPSHOT solved
by Geoff Hay
Hi
Needed to run:
ant download.drools.bin
and
ant install.drools.runtime
this isn't mentioned in the manual install
Geoff
________________________________
From: rules-users-bounces(a)lists.jboss.org [rules-users-bounces(a)lists.jboss.org] On Behalf Of Geoff Hay [geoffrey.hay(a)otago.ac.nz]
Sent: Wednesday, 20 October 2010 1:15 p.m.
To: rules-users(a)lists.jboss.org
Subject: [rules-users] install drools5.2.0.SNAPSHOT
Hi
Just joined up here and haven't found an answer to this - sorry if it's something already sorted... hopefully it's trivial..
Downloaded the drools5.2.0.SNAPSHOT-install and followed instructions in:
drools-5.2.0.SNAPSHOT-install\install\install.html (manual install)
When I try to do:
ant start.human.task
I get "runtime not found" see [1]
checking JBoss AS...
http://localhost:8080/ http://localhost:8080/gwt-console http://localhost:8080/drools-guvnor
are all working as expected.
so I am not sure which runtime is not being found.
My build.properties[2] refers to my separate install of JBoss AS
I have installled birt, gwt-console, guvnor.war, eclipse-all using ant as per instructions and those files appear in the install/lib folder
hope someone can help
Geoff
[1]
D:\java\drools5.2\drools-5.2.0.SNAPSHOT-install\install>ant start.jboss
Buildfile: build.xml
start.jboss:
BUILD SUCCESSFUL
Total time: 32 seconds
D:\java\drools5.2\drools-5.2.0.SNAPSHOT-install\install>ant start.human.task
Buildfile: build.xml
start.human.task:
[javac] Compiling 1 source file to D:\java\drools5.2\drools-5.2.0.SNAPSHOT-i
nstall\install\task-service\target
BUILD FAILED
D:\java\drools5.2\drools-5.2.0.SNAPSHOT-install\install\build.xml:391: D:\java\d
rools5.2\drools-5.2.0.SNAPSHOT-install\install\runtime not found.
Total time: 0 seconds
[2]
drools.version=5.2.0.SNAPSHOT
drools.url=https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild...
jboss.home=D:\\java\\jbossAS\\jboss-4.2.3.GA\\jboss-4.2.3.GA
jboss.server.configuration=default
eclipse.home=D:\\java\\eclipse-workflow\\eclipse
15 years, 8 months
install drools5.2.0.SNAPSHOT
by Geoff Hay
Hi
Just joined up here and haven't found an answer to this - sorry if it's something already sorted... hopefully it's trivial..
Downloaded the drools5.2.0.SNAPSHOT-install and followed instructions in:
drools-5.2.0.SNAPSHOT-install\install\install.html (manual install)
When I try to do:
ant start.human.task
I get "runtime not found" see [1]
checking JBoss AS...
http://localhost:8080/ http://localhost:8080/gwt-console http://localhost:8080/drools-guvnor
are all working as expected.
so I am not sure which runtime is not being found.
My build.properties[2] refers to my separate install of JBoss AS
I have installled birt, gwt-console, guvnor.war, eclipse-all using ant as per instructions and those files appear in the install/lib folder
hope someone can help
Geoff
[1]
D:\java\drools5.2\drools-5.2.0.SNAPSHOT-install\install>ant start.jboss
Buildfile: build.xml
start.jboss:
BUILD SUCCESSFUL
Total time: 32 seconds
D:\java\drools5.2\drools-5.2.0.SNAPSHOT-install\install>ant start.human.task
Buildfile: build.xml
start.human.task:
[javac] Compiling 1 source file to D:\java\drools5.2\drools-5.2.0.SNAPSHOT-i
nstall\install\task-service\target
BUILD FAILED
D:\java\drools5.2\drools-5.2.0.SNAPSHOT-install\install\build.xml:391: D:\java\d
rools5.2\drools-5.2.0.SNAPSHOT-install\install\runtime not found.
Total time: 0 seconds
[2]
drools.version=5.2.0.SNAPSHOT
drools.url=https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild...
jboss.home=D:\\java\\jbossAS\\jboss-4.2.3.GA\\jboss-4.2.3.GA
jboss.server.configuration=default
eclipse.home=D:\\java\\eclipse-workflow\\eclipse
15 years, 8 months
installing Drools using maven
by Tina Vießmann
Hi,
I would like to install drools for one of my projects using maven. (I've
already ask the maven mailinglist. They said I shall ask here, because
it's Drools related.)
I've set up the repository and the drools reference in my projects POM file.
<repository>
<id>Jboss Drools Nexus Repository</id>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools</artifactId>
<version>5.1.0</version>
<type>pom</type>
</dependency>
I know the referenced repository directory contains no jar file, because
I need the whole drools project. I thought the POM contained in the
repository dir would manage that. Because I'm new to Maven, I don't know
if I've configured something wrong or what's the trick. Running my
project I get:
Validation Messages:
[0] 'dependencies.dependency.version' is missing for
org.drools:drools:jar
So how can I set drools as a project dependency?
Thank you for your help!
Tina
15 years, 8 months
Decision Table evaluating empty cell condition
by Uday Kodukula
Hello,
I am currently working with Drools Decision tables, and have created a
decision table to determine availability of offers.
I have Offer Entities which contain a collection of "groups" that the offer
can belong to. That collection contains strings of ids that identify those
groups.
The decision table essentially has two columns, where the first column
checks to see if any of the comma separated list of group ids are present in
the collection items of the offer entities in working memory. So essentially
I'm trying to do a many to many existence check here.
So for example:
Let us suppose we have the following two offer entities:
Offer 1:
Name: "Acme Mice"
Groups: {"70104","70004","70000"}
Offer 2:
Name: "Acme Keyboard"
Groups "{"70104", "50404, "32825"}
Now in my decision table I have the following condition for checking the
"groups property"
CONDITION
ACTION
o: Offer
forall(||){groups contains $}
o.setAvail($param);
Offers that contain any of the following group ids
Is Available?
"70000","70104"
TRUE
""
TRUE
Now this works fine for those groups that are mentioned, but the second rule
which is the case where the group condition doesn't matter, but still needs
to fire the rule and result in action of set Avail to true, never happens.
This appears to be because the empty string "" is not contained in the
collection of groups.
Has anyone experienced this and know a way around this? I've tried checking
to see if the "" == $param or null, but I get errors like:
Description Resource Path Location Type
[ERR 101] Line 20:41 no viable alternative at input '""' in rule
"Availability_11" in pattern Offer Availability.xls
Thanks for your time!
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Decision-Table-evalua...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 8 months
Re: [rules-users] Get rid of redundant conditions in combined rules.
by Wolfgang Laun
I think that a single helper class
class Marker {
String property;
Object target;
}
would be sufficient:
// 1st consequence
insert( new Tag( "London", customer ) );
// 2nd condition
Tag( property == "London", $target : target )
Customer( this == $target, job == "teacher" )
You may need to have a strategy for retracting obsolete Tag facts.
-W
2010/10/19 Dominik Hüttner <d.huettner(a)tiq-solutions.de>:
> Hi Leonardo,
>
> the performance problem I thought of meant removing and inserting the facts
> again and again, if I would remove the facts, that don’t fit the first rule
> and execute the second rule only on the remaining facts.
>
> The solution you offered, does, what I intend, but the problem is, that I
> have to create a new class for every rule-pair and I want to use it
> flexible, without having to create a new class / model for every rule. Is
> there maybe another way to solve this problem?
>
>
>
> Kind regards,
>
>
>
> Dominik
>
>
>
>
>
>
>
> Von: rules-users-bounces(a)lists.jboss.org
> [mailto:rules-users-bounces@lists.jboss.org] Im Auftrag von Leonardo Gomes
> Gesendet: Dienstag, 12. Oktober 2010 16:37
> An: Rules Users List
> Betreff: Re: [rules-users] Get rid of redundant conditions in combined
> rules.
>
>
>
> If your problem is performance, don't worry. Conditions evaluation is
> shared, so in the second rule you won't re-evaluate the entire working
> memory (to know more:http://www.drdobbs.com/184405218).
>
> If you're worried about not having to repeat the conditions on the second
> rule, I would create inferred facts when the first rule matches and use then
> in the second rule + the additional conditions.
>
> Something like:
>
> Rule1:
>
> when
>
> customer:Customer(town=="London")
>
> then
>
> insert new LondonCustomer( customer );
>
>
>
> Rule2:
>
> when
>
> london : LondonCustomer(customer.job=="TEACHER")
>
> then
>
> System.out.println(london.customer.getLname() + " is a
> teacher");
>
>
>
> 2010/10/12 Dominik Hüttner <d.huettner(a)tiq-solutions.de>
>
> Hello everyone,
>
> I’ve got a question. I’m using drools-guvnor to execute some rule-scenarios.
> I have to solve the following problem: I have an amount of objects in my
> working memory and can’t remove objects from the working memory in the
> then-part of the rule. I want to combine two rules, the first rule selects
> some objects and the second rule checks only these selected objects for
> additional criteria. I have to use two rules, because I want to report the
> objects selected in the first rule, too. Now I have implemented this with
> two rules and in the second rule, the criterias of the first rule are copied
> to the second rule, my question is, is there a way to get rid of this
> redundandance?
>
> I have tried this with a rule flow, but the problem is, this always works on
> the whole working memory, but I can’t remove the not used objects from
> working memory for performance reasons. Is there another way to solve this
> problem?
>
>
>
> Here is an example for what I intend to do:
>
>
>
> Rule1:
>
> when
>
> customer:Customer(town=="London")
>
> then
>
> System.out.println(customer.getLname() + " is inhabitant of
> London");
>
>
>
> Rule2:
>
> when
>
> customer:Customer(town=="London",job=="TEACHER")
>
> then
>
> System.out.println(customer.getLname() + " is a teacher");
>
>
>
> This example illustrates, with the first rule I want to get to know, how
> many customers are from London and in the second rule I want to know, how
> many of the London customers are teachers. I want to create a kind of
> statistics. I have quite a lot of conditions for the first rule, so I don’t
> want to have them redundantly.
>
>
>
> Greetings, Dominik
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
15 years, 8 months
Re: [rules-users] Pattern aggregation
by Greg Barton
It would be nice if we had an example of some rules. That way we can rule out obvious performance killers like cartesian products and multiple "from" clauses in one rule.
GreG
On Oct 18, 2010, at 5:19, Tim 4076 <tm4076(a)gmail.com> wrote:
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
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
15 years, 8 months
How can i create a new object in consequence part
by Navdeep Kumar
Hi..
After execution of each rule, i want to create a new object of a particular
class and want to add that to the list. i know how to set the global list
but i am not sure whether i can create a new instance in the consequence of
the rule.
here is the rule file and description that what i am trying to do.
import java.util.Map;
global java.util.HashMap availablity;
global java.util.HashMap frontAxleAttributes;
global java.util.HashMap frontSuspensionAttributes;
global java.util.ArrayList resultState;
rule "FrontAxle:Capacity|FrontSuspension:Capacity"
dialect "mvel"
when
b:Feature(featureClass.name=="FrontSuspension")
c:Feature(featureClass.name=="FrontAxle")
eval(b.attributes.Capacity>=c.attributes.Capacity)
then
System.out.println(b.attributes.Capacity);
frontAxleAttributes.put("Capacity" ,new Double(c.attributes.Capacity));
frontSuspensionAttributes.put("Capacity", new
Double(b.attributes.Capacity));
frontAxleAttributes.put("Feature Code",b.getCode());
frontSuspensionAttributes.put("Feature Code",c.getCode());
availablity.put(b.featureClass.getName+"-"+c.getFeatureClass().getName(),new
Double(b.attributes.Capacity));
* **// i want to create a new Object of a class named AvailabilityRuleState
and want to add that in the list named resultState. *
* *
end
*//resultState is a list of AvailabilityRuleState Class. Please do check the
global declaration if that is wrong.*
will appreciate your help.
Thanks.
15 years, 8 months
Test Scenario for a Ruleflow in Guvnor
by Keith Lynch
Hi Folks
I've been playing with Guvnor and have been defining Test Scenarios. Mostly
the scenarios meet our requirements for simple rule packages. However we use
small flows which only use rule tasks.
I've seen that the ruleflow-group support works however I'm wondering if a
test scenario can be run against a process/flow?
Cheers
Keith
15 years, 8 months
Changing to JANINO not working?
by Mentor11
Hello,
Iam quite new to JBoss Rules.
So I am currently forced to use some JBoss Rules Features in ActiveMQ.
ActiveMQ uses the JANINO compiler I think.
I tried changing the Compiler but with no effect.
I allways get
the java.lang.NoSuchMethodError:
org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()
So he is using eclipse as far as I can tell.^^
I tried these approaches
KnowledgeBuilderConfiguration builderConfig =
knowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
builderConfig.setProperty("drools.dialect.java.compiler", "JANINO");
KnowledgeBuilder builder =
KnowledgeBuilderFactory.newKnowledgeBuilder(builderConfig);
and the other approach
KnowledgeBuilder builder =
KnowledgeBuilderFactory.newKnowledgeBuilder(config);
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
Properties props = new Properties();
props.setProperty("drools.dialect.java.compiler", "JANINO");
KnowledgeBuilderConfiguration config =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(props, null);
KnowledgeBuilder builder =
KnowledgeBuilderFactory.newKnowledgeBuilder(config);
I am using Drools Version 5.1.1
Can anybody Help me?
I am at the end of my Knowledge.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Changing-to-JANINO-no...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 8 months