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.
14 years, 2 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
>
>
14 years, 2 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
14 years, 2 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.
14 years, 2 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
14 years, 2 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.
14 years, 2 months
Flows, Subflows and fault.
by Swindells, Thomas
I've just started to use Drools Flow in anger and I'm really struggling to understand the correct way to use it and think I am missing something.
This is what I want to achieve:
The app code executes a StartProcess command and waits for the process to return (1 main process per session, 1 session per thread).
The process either succeeds, or it fails with a result.
A process could be complicated so I want to split it up into a parent process calling subprocesses.
I want to minimize boilerplate code (particularly in the ruleflow files) and keep the workflows as simple and maintainable as possible.
It sounds simple enough and doesn't seem to be particularly unusual.
Issue 1: startProcess is semi-synchronous. It starts the process, runs through as many nodes as it can until it gets to a non-synchronous task (rules, long lived customer work item etc) at which point it returns - or it returns when the entire process has been completed.
Challenge 1a: How to detect when the process has finished and use it in a synchronous manner.
Solution: A ProcessEventListener which completes a countdown latch when teh process has completed.
Challenge 1b: Subprocesses also trigger process events
Solution: Have the latch track the first process that started (the parent) and only return when that process completes.
Issue 2: Drools Flow is littered with error checking code which just prints to System.err and either carrys on or just stop. Eg if a work item handler isn't registered the process just stalls with a message.
Solution: Make sure code is perfectly written and doesn't have any bugs... hope that it doesn't happen in production ... complain on mailing list and add TODO to raise issue.
Issue 3: Fault nodes seem to be the correct way to say that something has gone wrong and the process should terminate.
Challenge: How does the calling code actually work out what the fault was and get the variable? The guide talks very very briefly about exception handlers but from what I can understand this is a way for the process to define what to do in this conditions. I want the process to be aborted and the calling application to be informed of this and the details.
Solution: Add an event listener which detects when a fault node is being entered and extracts the details - seems like a big hack surely there is a better way.
Issue 4: If a child process executes a fault node it is aborted. The parent process is set to wait for completion and has the child node as not being independent so I would expect that the parent process should also be marked as aborted.
Challenge: The parent process isn't marked as complete - it still has a status of Executing. However the process is stalled. Looking at subprocessNodeInstance internalTrigger (line 117) if the node returns a state of completed then trigger completed is called, otherwise it just adds a process listener - which will never be called as the process has already aborted. The parent process just stalls left in the state of active forever.
Sollution: ?? Hack my fault listener to work round the issue and update the parent process, make the processEventListener assert that if a child process is aborted then we should return? Ask on the mailing list to get me out of a blind alley and point me to the correct drools way of doing it...
Thomas
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
14 years, 2 months
mavn drools 5.1 plug-in
by Kumar, Ravendra
Hi all,
Could any of you please suggest best maven plug-in to build/compile .drl
files for drools 5?
Thanks
Ravendra
Please help Logica to respect the environment by not printing this email / Pour contribuer comme Logica au respect de l'environnement, merci de ne pas imprimer ce mail / Bitte drucken Sie diese Nachricht nicht aus und helfen Sie so Logica dabei, die Umwelt zu sch�tzen. / Por favor ajude a Logica a respeitar o ambiente nao imprimindo este correio electronico.
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
14 years, 2 months
List of valid values
by Chris Selwyn
I am developing a set of rules around validating messages in a B2B
messaging environment and I would like to have my rules builders have
control of the valid set of values for a particular field preferably
without creating a new fact model.
Since I am working in a B2B messaging world, I can see how to define an
enumeration in an XSD and how to access those in the Guvnor to create a
dropdown menu.
I can also see how to define a set of enumeration values in the Guvnor
which uses a hardcoded set of values to define the legal values for
populating a dropdown menu.
I can even see how to have the dropdown menu populated from a Java
class. The class appears to have to be on the classpath of the
application... It is not good enough to make it be part of the jar that
contains the fact model. This means that the set of legal values is part
of the "technical" domain rather than the "business" domain. I guess I
can always have the class load the values from a database, properties
file or some such but that means a separate place to store the values.
However, I feel that I would like to have the set of valid values be
part of what is accessible and configurable through the Guvnor.
Is there somewhere I can store the set as an artefact in Guvnor and be
accessible at runtime for me to do the check with?
Or should I just code the values into a set in a function?
Chris Selwyn
14 years, 2 months