Re: [rules-users] Changeset does not monitor folder correctly
Thanks that did it! From: lhorton To: rules-users@lists.jboss.org Sent: Friday, September 23, 2011 6:33 PM Subject: Re: [rules-users] Changeset does not monitor folder correctly I wrote a small test for loading your drl files with different change sets, and both methods worked fine and the rules executed the same way for both. I don't have time today to do a more extensive test. my change sets are: http://drools.org/drools-5.0/change-set"; xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"; xs:schemaLocation="http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd";> and for the directory one: http://drools.org/drools-5.0/change-set"; xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"; xs:schemaLocation="http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd";> source for my test is: KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("myagent"); kagent.applyChangeSet(ResourceFactory.newFileResource( "C:/rules/resources/ChangeSetDrl.xml")); KnowledgeBase kbase = kagent.getKnowledgeBase(); StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(); Patient p = new Patient(); p.setCreateDate(new Date()); p.setUserId(5); System.out.println("START EXECUTE WITH DRL CHANGE SET"); ksession.execute(p); kagent.dispose(); System.out.println("END EXECUTE WITH DRL CHANGE SET"); kagent = KnowledgeAgentFactory.newKnowledgeAgent("myagent"); kagent.applyChangeSet(ResourceFactory.newFileResource( "C:/rules/resources/ChangeSetDir.xml")); kbase = kagent.getKnowledgeBase(); ksession = kbase.newStatelessKnowledgeSession(); p = new Patient(); p.setCreateDate(new Date()); p.setUserId(5); System.out.println("START EXECUTE WITH DIRECTORY CHANGE SET"); ksession.execute(p); System.out.println("END EXECUTE WITH DIRECTORY CHANGE SET"); kagent.dispose(); and the output from the test is: START EXECUTE WITH DRL CHANGE SET User 5 Fri Sep 23 15:26:16 PDT 2011 (package test) Patient 5 Fri Sep 23 15:26:16 PDT 2011(package test) Hello World package test Hello World TWO package test two Hello World ONE package test two END EXECUTE WITH DRL CHANGE SET START EXECUTE WITH DIRECTORY CHANGE SET User 5 Fri Sep 23 15:26:16 PDT 2011 (package test) Patient 5 Fri Sep 23 15:26:16 PDT 2011(package test) Hello World package test Hello World TWO package test two Hello World ONE package test two END EXECUTE WITH DIRECTORY CHANGE SET -- View this message in context: http://drools.46999.n3.nabble.com/Changeset-does-not-monitor-folder-correctly-tp3337573p3363189.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
Hi, If you have a lot of rules like it you might be able to use the jBPM (what what the Drools Flow) to help with this. Otherwise plan old java might be easier... Wendy From: "Swindells, Thomas" To: Rules Users List Sent: Monday, September 26, 2011 6:53 AM Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially As I said, try reading the expert doc, there's some examples in there which you can base your code on. Once you've done that or if you have any questions about the samples/what the documentation means then post them and we'd be pleased to help, but the first step is to structure your code correctly using objects that follow the bean conventions and rules structured correctly with conditions against objects and appropriate modify statements. Thomas > -Original Message- > From: rules-users-boun...@lists.jboss.org [mailto:rules-users- > boun...@lists.jboss.org] On Behalf Of Saurabh Pandey > Sent: 26 September 2011 11:51 > To: rules-users@lists.jboss.org > Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want > to > run sequentially > > @thomas thanks for your comments I am new to drools, can u plz give me an > alternative to the above code. > > -- > View this message in context: http://drools.46999.n3.nabble.com/Drools-all- > lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- > tp3368215p3368917.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@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 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Changeset does not monitor folder correctly
Sorry to send this out again but does anyone have any other ideas as to what I could be doing wrong? Thank you, Wendy From: Wendy Mungovan To: Rules Users List Sent: Tuesday, September 20, 2011 4:21 PM Subject: Re: [rules-users] Changeset does not monitor folder correctly From test.drl: package test import com.sample.Patient; rule "test" when $p:Patient($userId: userId) then System.out.println("Patient "+ $userId + " " + $p.getCreateDate() + "(package test)" ); end rule "user" when $p: Patient($userId: userId) then System.out.println("User " + $userId + " " + $p.getCreateDate() + " (package test)" ); end rule "hello" when then System.out.println("Hello World package test"); end From test-two.drl: package test.two rule "hello one test two" when then System.out.println("Hello World ONE package test two"); end rule "hello two test two" when then System.out.println("Hello World TWO package test two"); end From: lhorton To: rules-users@lists.jboss.org Sent: Tuesday, September 20, 2011 3:41 PM Subject: Re: [rules-users] Changeset does not monitor folder correctly If you will post your drl files, maybe we can see what the problem might be. -- View this message in context: http://drools.46999.n3.nabble.com/Changeset-does-not-monitor-folder-correctly-tp3337573p3353222.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] accumulate function
The total of just one SegmentsGroup8 What about something like this: $allGroups: ArrayList( ) from accumulate( $seg: SegmentsGroup8( ), init( ArrayList controlTotals = new ArrayList(); ), action( controlTotals.add($seg.getCnt()); ), reverse( controlTotals.remove($seg.getCnt()); ), result( controlTotals) ) $sum: Number() from accumulate($cntTotal: ControlTotal() from $allGroups, sum($cntTotal.getC6066())) This might also work .. but I'm not sure $allGroups: List() from collect(SegmentsGroup8()) $sum: Number() from accumulate($cntTotal: ControlTotal() from $allGroups.getCnt(), sum($cntTotal.getC6066())) From: pamerida To: rules-users@lists.jboss.org Sent: Wednesday, September 21, 2011 11:43 AM Subject: Re: [rules-users] accumulate function Thanks for your reply Wendy, but I have a question, would that code get me the sum of all the SegmentsGroup8?, or will that give me the sum of each individual SegmentGroup8??, cause what I need is the sum of all the controltotal of all the segmentGroup8 asserted into the WM... thanks so much for your help... -- View this message in context: http://drools.46999.n3.nabble.com/accumulate-function-tp3353507p3355812.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] accumulate function
I'm assuming that c6066 is really a number and not a stringif not you will need to change this to parse the string into a number. I think something like this should do it. You first get the list from a SegmentGroup8 then sum the values you need. This is untested code. $seg: SegmentGroup8() $sum: Number() from accumulate( $cntTotal: ControlTotal() from $seg.getCnt(), sum($cntTotal.getC6066())) From: pamerida To: rules-users@lists.jboss.org Sent: Tuesday, September 20, 2011 5:35 PM Subject: [rules-users] accumulate function Hi everyone, I have this scenario: I have assserted a few elements of the type "SegmentGroup8" into the working memory, this SegmentGroup8 class have inside a list called private List cnt; What I need to achieve is to perform a "sum" of one of the fields called c6066 inside the ControlTotal for all the SegmentGroup8 asserted into the WM... I would like to use the accumulate functions but I really dont know how, any help would be appreciated, thanks in advance... the classes code is the following... public class SegmentGroup8 implements Serializable { private List cnt; private List moa; public List getCnt() { return cnt; } public void setCnt(List cnt) { this.cnt = cnt; } .. } public class ControlTotal extends Segment implements Serializable { private String c6069; private String c6066; public String getC6069() { return c6069; } public void setC6069(String c6069) { this.c6069 = c6069; } public String getC6066() { return c6066; } public void setC6066(String c6066) { this.c6066 = c6066; } . } -- View this message in context: http://drools.46999.n3.nabble.com/accumulate-function-tp3353507p3353507.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Changeset does not monitor folder correctly
>From test.drl: package test import com.sample.Patient; rule "test" when $p:Patient($userId: userId) then System.out.println("Patient "+ $userId + " " + $p.getCreateDate() + "(package test)" ); end rule "user" when $p: Patient($userId: userId) then System.out.println("User " + $userId + " " + $p.getCreateDate() + " (package test)" ); end rule "hello" when then System.out.println("Hello World package test"); end From test-two.drl: package test.two rule "hello one test two" when then System.out.println("Hello World ONE package test two"); end rule "hello two test two" when then System.out.println("Hello World TWO package test two"); end From: lhorton To: rules-users@lists.jboss.org Sent: Tuesday, September 20, 2011 3:41 PM Subject: Re: [rules-users] Changeset does not monitor folder correctly If you will post your drl files, maybe we can see what the problem might be. -- View this message in context: http://drools.46999.n3.nabble.com/Changeset-does-not-monitor-folder-correctly-tp3337573p3353222.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Changeset does not monitor folder correctly
The package names are different test and test-two. I think it has to do something with: KnowledgeAgent mapping resource=[FileResource file='Rules\DailyRules\test.drl'] to KnowledgeDefinition=[Rule name=hello one test two, agendaGroup=MAIN, salience=0, no-loop=false] because rule "hello one test two" is in the test-two.drl file not the test.drl file. Wendy -- View this message in context: http://drools.46999.n3.nabble.com/Changeset-does-not-monitor-folder-correctly-tp3337573p3348146.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Changeset does not monitor folder correctly
Hi, I'm trying to use a change set to monitor a folder for drl files but I can't get it to work right. If I list all the files in the folder all the rules load correctly and everything thing is happy. If I just specify a folder the mapping resource are associating rules from the test-two.drl file with the test.drl file. Also the 'KnowledgeAgent adding' adds two test.two (which is the package for the test-two.drl file) instead of a test and a test.two. Which is what happens when I list the files in the change-set. >From the documentation it seems like this should work. Has anyone run into this before? What am I doing wrong? I'm using 5.2.0.M1. Wendy [2011:09:257 20:09:317:info] ResourceChangeScanner reconfigured with interval=60 [2011:09:257 20:09:317:info] ResourceChangeScanner created with default interval=60 [2011:09:257 20:09:327:info] ResourceChangeScanner reconfigured with interval=60 [2011:09:257 20:09:327:info] ResourceChangeScanner reconfigured with interval=60 [2011:09:257 20:09:327:info] ResourceChangeNotification scanner has started [2011:09:257 20:09:327:debug] ResourceChangeScanner attempt to scan 0 resources [2011:09:257 20:09:347:debug] ResourceChangeScanner thread is waiting for 60 seconds. [2011:09:257 20:09:377:info] ResourceChangeNotification created [2011:09:257 20:09:417:info] ResourceChangeNotification has started listening for ChangeSet publications [2011:09:257 20:09:417:debug] ResourceChangeNotification thread is waiting for queue update [2011:09:257 20:09:667:debug] ResourceChangeNotification monitor added monitor=org.drools.io.impl.ResourceChangeScannerImpl@1f4cf6f [2011:09:257 20:09:677:debug] KnowledgeAgent building resource map [2011:09:257 20:09:677:info] KnowledgeAgent has started listening for ChangeSet notifications [2011:09:257 20:09:677:info] KnowledgeAgent created, with configuration: monitorChangeSetEvents=true scanResources=true scanDirectories=true newInstance=true (null: 4, 103): cvc-elt.1: Cannot find the declaration of element 'change-set'. [2011:09:257 20:09:797:info] KnowledgeAgent applying ChangeSet [2011:09:257 20:09:797:debug] KnowledgeAgent subscribing to directory=[UrlResource path='file:Rules/DailyRules/'] [2011:09:257 20:09:797:debug] ResourceChangeNotification subscribing listener=org.drools.agent.impl.KnowledgeAgentImpl@aee320 to resource=[UrlResource path='file:Rules/DailyRules/'] [2011:09:257 20:09:797:debug] ResourceChangeScanner subcribing notifier=org.drools.io.impl.ResourceChangeNotifierImpl@1c160cb to resource=[UrlResource path='file:Rules/DailyRules/'] [2011:09:257 20:09:817:debug] KnowledgeAgent mapping resource=[FileResource file='Rules\DailyRules\test-two.drl'] to KnowledgeDefinition=null [2011:09:257 20:09:817:debug] KnowledgeAgent notifier subscribing to resource=[FileResource file='Rules\DailyRules\test-two.drl'] [2011:09:257 20:09:817:debug] ResourceChangeNotification subscribing listener=org.drools.agent.impl.KnowledgeAgentImpl@aee320 to resource=[FileResource file='Rules\DailyRules\test-two.drl'] [2011:09:257 20:09:817:debug] ResourceChangeScanner subcribing notifier=org.drools.io.impl.ResourceChangeNotifierImpl@1c160cb to resource=[FileResource file='Rules\DailyRules\test-two.drl'] [2011:09:257 20:09:817:debug] KnowledgeAgent mapping resource=[FileResource file='Rules\DailyRules\test.drl'] to KnowledgeDefinition=null [2011:09:257 20:09:817:debug] KnowledgeAgent notifier subscribing to resource=[FileResource file='Rules\DailyRules\test.drl'] [2011:09:257 20:09:817:debug] ResourceChangeNotification subscribing listener=org.drools.agent.impl.KnowledgeAgentImpl@aee320 to resource=[FileResource file='Rules\DailyRules\test.drl'] [2011:09:257 20:09:817:debug] ResourceChangeScanner subcribing notifier=org.drools.io.impl.ResourceChangeNotifierImpl@1c160cb to resource=[FileResource file='Rules\DailyRules\test.drl'] [2011:09:257 20:09:878:debug] KnowledgeAgent rebuilding KnowledgeBase using ChangeSet [2011:09:257 20:09:936:debug] KnowledgeAgent obtaining pkg resource=[FileResource file='Rules\DailyRules\test-two.drl'] [2011:09:257 20:09:936:debug] KnowledgeAgent mapping resource=[FileResource file='Rules\DailyRules\test-two.drl'] to KnowledgeDefinition=[Rule name=hello one test two, agendaGroup=MAIN, salience=0, no-loop=false] [2011:09:257 20:09:936:debug] KnowledgeAgent notifier subscribing to resource=[FileResource file='Rules\DailyRules\test-two.drl'] [2011:09:257 20:09:936:debug] ResourceChangeNotification subscribing listener=org.drools.agent.impl.KnowledgeAgentImpl@aee320 to resource=[FileResource file='Rules\DailyRules\test-two.drl'] [2011:09:257 20:09:936:
Re: [rules-users] Collect with same value
Right. But we don't want to match if the size dropped below 5 during the last 20 m. so if the size for BLUE are: Time 0 5 10 15 20 25 30 35 40 45 50 Size 5 6 7 6 6 6 6 6 6 4 6 at times 25,30,35,40 we would want to trigger but not at 0, 45 or 50. -- View this message in context: http://drools.46999.n3.nabble.com/Collect-with-same-value-tp3242904p3245998.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Collect with same value
I'm still not sure I can make my rule work like that. Sorry, my real problem is a little more complicated then I initially described. We are trying to detect if some set of conditions stay within a set of ranges over a period of time. So still using the example below. The color is really the key for the shape and the size can change over time. For example, we would want to know if any shape's size was larger than 5 for 20 min. I see how you are making a map that would have a list of all the shapes of the same color. So $map['BLUE'] would return all shapes and $shape: Shapes( $color: color, size > 5 ) could change to $shape: Shapes( $color: color, size > 5 ) over window:time(20m) to only get Shape sizes for the last 20 min. now this would be a map where the key would be the color and the value would be the min size over a 20 min window. //untested $map: Map() from accumulate ( $shape: Shapes( $color: color) over window:time(20m), init( Map m = new HashMap(); ), action( Number min = m.get( $color ); if( min == null ) m.put($shape.size); else if (min > $shape.size) m.put($shape.size);), result( m ) ) and then I would need to iterate through the map and find all the ones whose min size > 5? -- View this message in context: http://drools.46999.n3.nabble.com/Collect-with-same-value-tp3242904p3245580.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Collect with same value
thank you. From: Wolfgang Laun-2 [via Drools] To: wendy Sent: Wednesday, August 10, 2011 1:31 PM Subject: Re: [rules-users] Collect with same value rule "get big shapes by color" when $map: Map() from accumulate ( $shape: Shapes( $color: color, size > 5 ), init( Map m = new HashMap(); ), action( List list = m.get( $color ); if( list == null ) list = new ArrayList(); list.add( shape ); ), result( m ) ) then // process $map to get all lists of same color end Untested. -W On 10 August 2011 17:20, wendy <[hidden email]> wrote: Hi, > I'm trying to write the following rule but am having some trouble. > > We have a object say Shape and which has attributes size and color. I >want to get a list of all shapes with the same color that have size > 5. >How can I make sure the color is the same for all objects in the collect >without having different rules for 'red', 'green'...? > >Thank you, >Wendy > > >-- >View this message in context: >http://drools.46999.n3.nabble.com/Collect-with-same-value-tp3242904p3242904.html >Sent from the Drools: User forum mailing list archive at Nabble.com. >___ >rules-users mailing list >[hidden email] >https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list [hidden email] https://lists.jboss.org/mailman/listinfo/rules-users If you reply to this email, your message will be added to the discussion below:http://drools.46999.n3.nabble.com/Collect-with-same-value-tp3242904p3243337.html To unsubscribe from Collect with same value, click here. -- View this message in context: http://drools.46999.n3.nabble.com/Collect-with-same-value-tp3242904p3243377.html Sent from the Drools: User forum mailing list archive at Nabble.com.___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Collect with same value
Hi, I'm trying to write the following rule but am having some trouble. We have a object say Shape and which has attributes size and color. I want to get a list of all shapes with the same color that have size > 5. How can I make sure the color is the same for all objects in the collect without having different rules for 'red', 'green'...? Thank you, Wendy -- View this message in context: http://drools.46999.n3.nabble.com/Collect-with-same-value-tp3242904p3242904.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools and ArrayList
Sorry I'm not quire sure I'm following your errors... Are you saying you are having null pointer exceptions with this version: global List list rule "count from global List - but don't do it" when Number( $i: intValue ) from accumulate( Person( age > 20 ) from list, count(1) ) then System.out.println( $i + " Persons" ); end -- View this message in context: http://drools.46999.n3.nabble.com/Drools-and-ArrayList-tp3140821p3158948.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools and ArrayList
I think normally setGlobal variables are only used when you want to be able to call back out to the java code again. (I'm not an expert by any stretch so please take that with a grain of salt.) So you might be able to just insert the list. I'm going to assume the List is really List if that is not true please let me know. what about something like this? First is collects all the NombersUnTypeDefault that match your constraints from list then it counts them using an accumulate function. global java.util.List list rule "Calcul redondance" when $i: Number() from accumulate($c: NombersUnTypeDefault() from collect(NombersUnTypeDefault($code == "AAA", $int == 1) from list) , count($c)); then System.out.println($i); end -- View this message in context: http://drools.46999.n3.nabble.com/Drools-and-ArrayList-tp3140821p3144161.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools and ArrayList
Have you tried using the accumulate function? //taken from the link below and modified a bit to use count.. (it is untested) rule "Count the number of items in the order" when $order : Order() $total : Number( ) from accumulate( OrderItem( order == $order), count( ) ) then System.out.println("There are "+$total+ " number of items in the order"); end http://docs.redhat.com/docs/en-US/JBoss_Enterprise_SOA_Platform/4.3/html/JBoss_Rules_Reference_Guide/ch05s05s02s10.html -- View this message in context: http://drools.46999.n3.nabble.com/Drools-and-ArrayList-tp3140821p3141665.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Absence Pattern question
Thanks, This did it: rule "AnoB" timer(int: 3m) when $a: A() not($b: B( this after[-1ms] $a)) then I needed to add [-1ms] so it would not match things with A and B at the same exact time. -- View this message in context: http://drools.46999.n3.nabble.com/Absence-Pattern-question-tp3140377p3140552.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Absence Pattern question
Hi, I'm having trouble writing an absence pattern. What I'm trying to do is detect when there is an A followed by no Bs for 3+minutes. I don't care if there is more than one A. What I'm running into is that when I try to use 'over window:time' the time within drools is the end time of the window. So this means I need to write the no Bs for 3+ min first: not( $b: B() over window:time(3m)) then try to find the A before it: $now: Long() from RuleUtilityFunctions.getSessionClockTime() $a: A( this before [3m] $now) then I should have to check to make sure that I don't have any Bs between $a's time and the start of the no B window: not( B( time >= $a.time, time <= $now)) This is not working. I think that it has something to do with my function to get the session clock time (RuleUtilityFunctions.getSessionClockTime()) and how things get evaluated within the Rete engine. Because it does not seem like $now is getting re-evaluated on future calls that pass the $b condition. If I replace $now with the call to getSessionClockTime() everything just seems to get weird. I've tried to write the rule forward too. Look for A followed by no B but that does not seem to work because A is matched at the current time and the rule triggers because there is no B because the future B data has not be inserted into working memory yet. What is the right way to write this rule? Is there a way to get the start and end time of the time window that met the over window:time() condition? Thank you, Wendy -- View this message in context: http://drools.46999.n3.nabble.com/Absence-Pattern-question-tp3140377p3140377.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] sliding window combination ?
I think that you should be able to. $zCollection: ArrayList() from collect(Z over window:length(z_length)) $xCollection:ArrayList() from collect(X over window:length(y) from $ZCollection) I'm sorry I did not check the syntax so it might not be quite right but I've done accumulates over collections made in another line before and it worked. Wendy From: Andre To: rules-users@lists.jboss.org Sent: Sat, July 2, 2011 11:08:56 AM Subject: [rules-users] sliding window combination ? hi, is it possible to combine sliding windows ? like: if in timewindow x occur y(length-window) of z elements which have the same string in z.name then do something ... -- View this message in context: http://drools.46999.n3.nabble.com/sliding-window-combination-tp3132340p3132340.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Common Practices for warning or debug rules/messages
Thank you, That sounds like a good idea if we could automatically fix the data or the rules were more fatal instead of warn/error level, but in our case it will require some human intervention and I don't think we will want to stop everything until it gets fixed. I will keep this in mind if we run into any real critical errors though. Wendy From: Edson Tirelli-4 [via Drools] To: wendy Sent: Sat, July 2, 2011 1:34:42 PM Subject: Re: [rules-users] Common Practices for warning or debug rules/messages Hi, I think this is the best use case for agenda-groups + auto-focus... i.e., you add your rules to your kbase, and the rules remain there and will not fire, unless an extraordinary condition is detected, in which case the auto-focus will trigger, "pausing" the execution of the other rules to do whatever is necessary to handle the extraordinary condition. After it is fixed, the processing resumes with the regular rules. Not sure if that is what you are looking for, but hope it helps. Edson 2011/6/29 wendy <[hidden email]> Hi, > I'm working on a system that has a large number of rules and we are >getting to the point where we think it would be useful to have some 'debug' >or 'warning' type rules (for lack of a better word).The warning rules >would be rules that would signal to us that something is wrong with the >underlying data and would require someone to go in and fix something. I was >wondering if there are some standard practice as to how to write, maintain, >format... these rules. I can think of a couple of ways to do this but I >would like the communities opinion. We would also like the ability to turn >on/off these debug or warning rules easily while the rest of the system >keeps on processing. > >Thank you, >Wendy > > > >-- >View this message in context: >http://drools.46999.n3.nabble.com/Common-Practices-for-warning-or-debug-rules-messages-tp3124178p3124178.html > >Sent from the Drools: User forum mailing list archive at Nabble.com. >___ >rules-users mailing list >[hidden email] >https://lists.jboss.org/mailman/listinfo/rules-users > -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list [hidden email] https://lists.jboss.org/mailman/listinfo/rules-users If you reply to this email, your message will be added to the discussion below:http://drools.46999.n3.nabble.com/Common-Practices-for-warning-or-debug-rules-messages-tp3124178p3132693.html To unsubscribe from Common Practices for warning or debug rules/messages, click here. -- View this message in context: http://drools.46999.n3.nabble.com/Common-Practices-for-warning-or-debug-rules-messages-tp3124178p3137120.html Sent from the Drools: User forum mailing list archive at Nabble.com.___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Common Practices for warning or debug rules/messages
Hi, I'm working on a system that has a large number of rules and we are getting to the point where we think it would be useful to have some 'debug' or 'warning' type rules (for lack of a better word).The warning rules would be rules that would signal to us that something is wrong with the underlying data and would require someone to go in and fix something. I was wondering if there are some standard practice as to how to write, maintain, format... these rules. I can think of a couple of ways to do this but I would like the communities opinion. We would also like the ability to turn on/off these debug or warning rules easily while the rest of the system keeps on processing. Thank you, Wendy -- View this message in context: http://drools.46999.n3.nabble.com/Common-Practices-for-warning-or-debug-rules-messages-tp3124178p3124178.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] FW: Basic rules question
Abhay, You can use the normal Java gets (if your object has them). when $prod : Product ($prod.getMemory().getRam().getType() == "DDR")... instead of $prod.getMemory()... you I think should also be able to use 'this.getMemory()' (I have not tried these out to make sure) Wendy From: Abhay B. Chaware To: Rules Users List Sent: Mon, May 9, 2011 11:56:42 PM Subject: Re: [rules-users] FW: Basic rules question OK. Another one. How do I access and use a property of a member variable ( object ) of an object, in rules ? e.g. in the same example, I need to check 1) if a product of type ‘laptop’ is inserted in memory AND 2) if the product’s MEMORY property ( object ) has an object of type DDR ram attached. In other words, here is the relationship of facts - PRODUCT has member variable MEMORY ( which is an object ) MEMORY has member variable RAM ( which is again an object ) RAM has member variable TYPE ( which should be equal to “DDR” ) From within rules ‘when’ part, how do I check if there is a PRODUCT inserted in memory whose MEMORY has a RAM of type DDR assigned ? Regards, Abhay Chaware Sr. Designer | KPIT Cummins Infosystems Ltd | Board: +91 020 6652 5000 | Extn: 2989 | abhay.chaw...@kpitcummins.com |www.kpitcummins.com PPlease consider the environment before printing this e-mail From:rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Michael Anstis Sent: Monday, May 09, 2011 4:27 PM To: Rules Users List Subject: Re: [rules-users] FW: Basic rules question Yes :) 2011/5/9 Abhay B. Chaware Mike, What I meant was, There are say 10 objects of RAM in memory whose type is DDR. Now my “Product” object has a member variable named “compatibleRAMs”, and I would like to set an arraylist containing these 10 objects to the “compatibleRAMs” variable of “Product” object in memory. I am reading about the “collect” which can be used to create collections from fact objects in memory. Something like. When $prod : Product (type==’laptop’) $compatibleRAMs : ArrayList() from collect (RAM (type == ‘DDR’)) Then $prod.setCompatibleRAMs($compatibleRAMs); Am I on the right track ? -abhay From:rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Michael Anstis Sent: Monday, May 09, 2011 3:52 PM To: Rules Users List Subject: Re: [rules-users] FW: Basic rules question Abhay, Do you need a list? You can assign RAM to COMPUTERS with this:- when $c : Computer( $type : type ) $r : RAM( compatibleWith == $type ) then $c.addRAM( $r ); end This would add all RAM (in Working Memory) compatible with COMPUTER to computer. You could use a list of RAM as a Fact in WM and change your rule to use that:- when $l : MyList( ) $c : Computer( $type : type ) $r : RAM( compatibleWith == $type ) from $l then $c.addRAM( $r ); end Or you can define a rule to construct the list too:- when $l : MyList( $t : typeRAM ) RAM( $c : $t ) then $l.add( $r ) end I assume you'd need to differentiate different lists for different types; so I have shown use of "MyList" which could subclass ArrayList and have a "Type of RAM" attribute. Drools doesn't "do" generics. With kind regards, Mike 2011/5/9 Abhay B. Chaware Wendy, Thanks for helping me out so far. I have another question. What if I have all my “RAM” objects inserted into working memory. How should I write my rule’s “when” portion to get a collection of all the RAM objects matching type “DDR” ? In other words, can I get collection of facts assigned to a variable and use it in the “then” part ? Thanks Abhay == From:rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wendy Mungovan Sent: Friday, May 06, 2011 5:47 PM To: Rules Users List Subject: Re: [rules-users] Basic rules question Q2: So the rule would be something like: rule "RAM type" when $product: Product(type == "laptop"); then //you are looking for the best way to set valid RAM types in the then part of the rule? $product.setRamType("DDR"); //or $product.setValidRamOptions( getValidRamOptions("DDR")); end where getValidRamOptions would be a custom function included through 'import function' so you can then load the choices from some where else. Or if RamOptions were an object in memory you could have a rule like: rule "RAM type" when $product: Product(type == "laptop"); $ramOptions: RAMOptions(type == "DDR"); then $product.setValidRamOptions( $ramOptions.getList()); end Wendy == Re
Re: [rules-users] Missing results with multiple time rules
Sorry, I've been testing this more and I think that it is with in our code that I'm doing something wrong that is causing this issue not how I'm writing the rules. Probably with updating the psudo-clock time in the wrong spot. Is it ok if I ask a related question? Is there a way to accumulate multiple values at once? The way I've written the rule now we first collect a set of objects then try to find the min, max and/or average values of some fields as well as creating a string of all the 'name' components. Is it possible to write an accumulate function that can calculate multiple values at the same time? This is what I'm doing now. It seem in efficient // ... removed the includes dialect "java" declare SIGINT_track @role(event) @timestamp(time) end rule "Rule_87_0_Find" when $LaunchpadA: Launchpad ( ) $SIGINT_trackA: ArrayList( size >= 3, size <= 5) from collect( $SIGINT_trackA_list : SIGINT_track ( eval(distLess(location, $LaunchpadA.location,2000.0)) ) over window:time(720ms) ) $MIN_SIGINT_trackA_time: Number() from accumulate( $i: SIGINT_track() from $SIGINT_trackA, min($i.time)); $TEXTLIST_SIGINT_trackA_name: String() from accumulate( SIGINT_track($id: name) from $SIGINT_trackA, init(ArrayList ids = new ArrayList();), action( ids.add($id); ), reverse( ids.remove($id);), result(converter(ids)) ); $MIN_SIGINT_trackA_time: Number() from accumulate( $i: SIGINT_track() from $SIGINT_trackA, min($i.time)); $AVERAGE_SIGINT_trackA_time: Number() from accumulate( $i: SIGINT_track() from $SIGINT_trackA, average($i.time)); then // debug print statement to see if we are getting here System.out.println("Rule 87 " + $TEXTLIST_SIGINT_trackA_name); // ... code to do stuff in our system end -- View this message in context: http://drools.46999.n3.nabble.com/Missing-results-with-multiple-time-rules-tp2918309p2919375.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Missing results with multiple time rules
Hi, I'm having an issue trying to run multiple time window patterns at the same time. If I run them separately they produce the correct results but when I load them both rules into working memory I only get results for the second one. If I remove the 'over window:time(720ms)' aspect from both rules I do get results for both as expected. The rules right now are very similar (I'm trying to test out how we write drl files) I'm not sure if that has something to do with it or not. In one rule I'm trying to find 3 or more objects that match my constraints over the time window and in the other between 3 and 5 objects. I'm using drools 5.2.0 from last Tuesday droolsjbpm-drools-20c84a4. Any help you can provide would be appreciated, Wendy -- View this message in context: http://drools.46999.n3.nabble.com/Missing-results-with-multiple-time-rules-tp2918309p2918309.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Basic rules question
Q2: So the rule would be something like: rule "RAM type" when $product: Product(type == "laptop"); then //you are looking for the best way to set valid RAM types in the then part of the rule? $product.setRamType("DDR"); //or $product.setValidRamOptions( getValidRamOptions("DDR")); end where getValidRamOptions would be a custom function included through 'import function' so you can then load the choices from some where else. Or if RamOptions were an object in memory you could have a rule like: rule "RAM type" when $product: Product(type == "laptop"); $ramOptions: RAMOptions(type == "DDR"); then $product.setValidRamOptions( $ramOptions.getList()); end Wendy From: Abhay B. Chaware To: Rules Users List Sent: Fri, May 6, 2011 8:33:53 AM Subject: Re: [rules-users] Basic rules question Q1. Thanks , that makes sense. Q2. I am trying to modify facts, based on events. So in the example given, I am saying if user selects "laptop" then only "DDR" type RAM should be available to choose from, in the RAM category. Thanks abhay ____ From: rules-users-boun...@lists.jboss.org [rules-users-boun...@lists.jboss.org] On Behalf Of Wendy Mungovan [w.mungo...@yahoo.com] Sent: Friday, May 06, 2011 5:47 PM To: Rules Users List Subject: Re: [rules-users] Basic rules question Abhay, Q1: I think that this will depend on how many different products you have. If there is a small number it is more straight forward to have a rule for each one (so the 2nd option). This allows all you logic to be in one place. If there are a large number of products and writing a rule for each one is intractable you probably would want to look into some generalizations of the rules. Is that helpful? Q2: I'm not quite sure what you are getting at in Q2. Are you trying to write validation rules or rules that are modifying the facts? Wendy From: Abhay B. Chaware To: "rules-users@lists.jboss.org" Sent: Fri, May 6, 2011 4:59:46 AM Subject: [rules-users] Basic rules question Hi I am a newbie to rule based applications and trying to get the concept of rules. I have couple of questions about rules to start with, not specifically about Drools though. Q1 - Should rules be data/model specific or can/should they be generic or both == e.g. If selected product “TYPE” is “laptop”, then category “RAM” should have all “DDR” type items compatible ( selecting items matching certain property ) OR If selected product is “IBM T42”, then category “RAM” should have “512MB DDR” , “1024MB DDR”, “2048MB DDR” compatible. ( assigning individual items in rules ) OR Combination of both Q2 – How should be the data modeled in above case == e.g. in product master, each item ( e.g. T40, T42 ) should have a “TYPE” ( e.g. desktop or laptop ) , all items in category “RAM” should have a “TYPE” ( e.g. DDR ) and then control the assignment of RAM options to the PRODUCT through Rule using “DDR” type ? OR in product master, each item ( e.g. T40, T42 ) should have a “TYPE” ( e.g. desktop or laptop ) , all items in category “RAM” should have a “compatibleProduct” column ( e.g. desktop or laptop ) and control the assignment of RAM to PRODUCT through “dynamic” rules by selecting all the RAMs by passing the “TYPE” of the product to the database handler. Am I making my point clear ? Thanks Abhay This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Basic rules question
Abhay, Q1: I think that this will depend on how many different products you have. If there is a small number it is more straight forward to have a rule for each one (so the 2nd option). This allows all you logic to be in one place. If there are a large number of products and writing a rule for each one is intractable you probably would want to look into some generalizations of the rules. Is that helpful? Q2: I'm not quite sure what you are getting at in Q2. Are you trying to write validation rules or rules that are modifying the facts? Wendy From: Abhay B. Chaware To: "rules-users@lists.jboss.org" Sent: Fri, May 6, 2011 4:59:46 AM Subject: [rules-users] Basic rules question Hi I am a newbie to rule based applications and trying to get the concept of rules. I have couple of questions about rules to start with, not specifically about Drools though. Q1 - Should rules be data/model specific or can/should they be generic or both == e.g. If selected product “TYPE” is “laptop”, then category “RAM” should have all “DDR” type items compatible ( selecting items matching certain property ) OR If selected product is “IBM T42”, then category “RAM” should have “512MB DDR” , “1024MB DDR”, “2048MB DDR” compatible. ( assigning individual items in rules ) OR Combination of both Q2 – How should be the data modeled in above case == e.g. in product master, each item ( e.g. T40, T42 ) should have a “TYPE” ( e.g. desktop or laptop ) , all items in category “RAM” should have a “TYPE” ( e.g. DDR ) and then control the assignment of RAM options to the PRODUCT through Rule using “DDR” type ? OR in product master, each item ( e.g. T40, T42 ) should have a “TYPE” ( e.g. desktop or laptop ) , all items in category “RAM” should have a “compatibleProduct” column ( e.g. desktop or laptop ) and control the assignment of RAM to PRODUCT through “dynamic” rules by selecting all the RAMs by passing the “TYPE” of the product to the database handler. Am I making my point clear ? Thanks Abhay This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Question on modeling facts
How many train stops are you talking about? If it is only a few it might not matter if you don't have the many trains. When you are writing your rule if you narrow down by matching schedule first and then comparing all the stops that might help. An alternative to comparing two collections in drools would be to write a custom function that could do some simple checks first like make sure that the size of both lists are the same. Another option if the list of train stops is a POJO itself is to make its hashkey so that two lists with the same values will have matching hashkeys. Wendy From: Brett Bergquist To: rules-users@lists.jboss.org Sent: Tue, May 3, 2011 3:20:52 PM Subject: [rules-users] Question on modeling facts I am trying to write rules to distill down a minimal train schedule from a set of overlapping train schedules. A train schedule contains a train identifier, a schedule that it runs on, and a set of train stops. A rule that I would like to write is to combine one or more train schedules if more than one train runs on the same day (ie has the same schedule) and stops at the same stops. This ignores the train identifier and will discard all other train schedules that have a different train identifier but have the same schedule and stops. I am wondering how to model the equality test for the same set of stops. Can I have my Train fact contain a collection of stops and then compare the collections for equality? Will this be efficient? Is there a better way to model this? Any and all help will be greatly appreciated. Brett -- View this message in context: http://drools.46999.n3.nabble.com/Question-on-modeling-facts-tp2895595p2895595.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] 5.2.0.M2 issue using import functions
Thank you that did it. I switched over to using the 5.2.0-SNAPSHOT. -- View this message in context: http://drools.46999.n3.nabble.com/5-2-0-M2-issue-using-import-functions-tp2865621p2895420.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] 5.2.0.M2 issue using import functions
Does anyone have any ideas for this? Your help would be much appreciated. Thank you. Wendy -- View this message in context: http://drools.46999.n3.nabble.com/5-2-0-M2-issue-using-import-functions-tp2865621p2890431.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] 5.2.0.M2 issue using import functions
Hi, I've been using Drools 5.1 and I'm in the process of switching over to 5.2.0.M2. I have a file containing many custom public static functions that our rules use. With 5.1 I could just "import function MyRuleFunction.*;" and then use them in the 'when' part of the rule: $example: ArrayList(size>3) from collect ($p: Person( eval ( exampleImportedFunction( name, "Bob"))) but with 5.2.0.M2 I'm getting an "unable to resolve method using strict-mode: Person.exampleImportedFunction(java.lang.String, java.lang.String) which makes it look like it is only searching for functions on Person but not in the 'import functions'. If I add "import function MyRuleFunction.exampleImportedFunction;" it works fine but I don't want to have to do that for every function in my file. Functions used in the consequent don't seem to need to be imported specifically (* works fine). Has something changed between 5.1 and 5.2.0.M2 that effects this? Thank you, Wendy -- View this message in context: http://drools.46999.n3.nabble.com/5-2-0-M2-issue-using-import-functions-tp2865621p2865621.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users