Re: [rules-users] accumulate function not registered
Did a partial rollback and it resolve the problem. Encountered this issue in effort to get around a spring boot from jar problem. Initially refactored code then upgraded to 6.1.0-CR1. Was at that point the issue arose. On rolling back my refactor (and maintaining the drools 6.1.0-CR1 version) the issue was cleared. A little perplexed on that. Suspect it may have something to do with class loading, but only a guess. Does the location of the .drl (resource) files in the project structure affect the build and boot process? -- View this message in context: http://drools.46999.n3.nabble.com/accumulate-function-not-registered-tp4030102p4030116.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] accumulate function not registered
can you please open a jira ticket and possibly add a reproducer? It seems a serious regression, but it would have to be reproduced and fixed in the next few days for this to make it to the final release Thanks! Davide On 06/18/2014 03:26 PM, rogerL wrote: > After upgrade to 6.1.0.CR1 rule compilation is generating a pluggable > accumulate function registration error. > > Partial stack dump: > Caused by: java.lang.RuntimeException: Error while creating KieBase[Message > [id=1, level=ERROR, > path=com/s/c/manager/rules/campaign/priority/prioritize.drl, line=31, > column=0 >text=Unknown accumulate function: 'topPriority' on rule 'Insert highest > priority campaign'. All accumulate functions must be registered before > building a resource.], Message [id=2, level=ERROR, > path=com/s/c/manager/rules/campaign/priority/prioritize.drl, line=31, > column=0 >text=Rule Compilation error $tc cannot be resolved to a variable]] > > The associated rule and accumulate import are: > > import accumulate com.s.c.util.HighestPriorityCampaignAccumulateFunction > topPriority; > > rule "Insert highest priority campaign" > when > not TopCampaign() > accumulate(TargetCampaigns($list : list, list.size >0), $tc : > topPriority( $list ) ) > then > insert(new TopCampaign($tc)); > end > > Is this syntax no longer correct? > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/accumulate-function-not-registered-tp4030102.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] accumulate function not registered
After upgrade to 6.1.0.CR1 rule compilation is generating a pluggable accumulate function registration error. Partial stack dump: Caused by: java.lang.RuntimeException: Error while creating KieBase[Message [id=1, level=ERROR, path=com/s/c/manager/rules/campaign/priority/prioritize.drl, line=31, column=0 text=Unknown accumulate function: 'topPriority' on rule 'Insert highest priority campaign'. All accumulate functions must be registered before building a resource.], Message [id=2, level=ERROR, path=com/s/c/manager/rules/campaign/priority/prioritize.drl, line=31, column=0 text=Rule Compilation error $tc cannot be resolved to a variable]] The associated rule and accumulate import are: import accumulate com.s.c.util.HighestPriorityCampaignAccumulateFunction topPriority; rule "Insert highest priority campaign" when not TopCampaign() accumulate(TargetCampaigns($list : list, list.size >0), $tc : topPriority( $list ) ) then insert(new TopCampaign($tc)); end Is this syntax no longer correct? -- View this message in context: http://drools.46999.n3.nabble.com/accumulate-function-not-registered-tp4030102.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] Accumulate function
You could us a query to obtain a compact pattern for all matching RFIDObservations. And I don't think you need a custom function; collectSet should give you unique values. Untested! query uncrowdedObservations( SensorFixed $rdr, RFIDObservation $obs ) $obs: RFIDObservation( sensor == $rdr ) over window:time( 60s ) not CrowdInAreaEvent( sensor == $rdr, this meets[ 5s ] $obs ) end rule "CrowdInAreaEvent-event" no-loop when $rdr: SensorFixed(type == Sensor.SENSOR_TYPE_RFID, $coverageArea : areaOfInterest ) accumulate( uncrowdedObservation( $rdr, $obs ), $set: accumulateSet( $obs.getTagid() ) ) eval( $set.getSize() > 10 ) then insert( ... ); end -W On 22/05/2012, Matteo Cusmai wrote: > Hi Vincent, > i have an rfid reader and i am collecting tagid from that sensor. > I would like to raise an event when the number of different tags in a time > interval is greater than 20 (for example). > > > > On Tue, May 22, 2012 at 2:33 PM, Vincent LEGENDRE < > vincent.legen...@eurodecision.com> wrote: > >> No. >> You can't use $obs before you bind it (2nd pattern) >> The binding done for accumulate pattern must be used in some accumulate >> fonction in order to be seen outside. >> >> Instead of trying to fix your rule, may be you can describe (with simple >> phrases) what you are trying to do ? >> >> -- >> *De: *"Matteo Cusmai" >> *À: *"Rules Users List" >> *Envoyé: *Mardi 22 Mai 2012 12:33:16 >> *Objet: *[rules-users] Accumulate function >> >> >> Hi all, >> i am going to use a custom accumulate function like that: >> >> rule "CrowdInAreaEvent-event" >> no-loop >> when >> $RFIDReader : SensorFixed(type == Sensor.SENSOR_TYPE_RFID, >> $coverageArea : areaOfInterest ) >> not CrowdInAreaEvent( sensor == $RFIDReader, this meets[ 5s ] >> $obs >> ) >> $count : Integer( intValue > 10 ) >> from accumulate( $obs : RFIDObservation( $tagid : tagid, >> sensor == $RFIDReader ) >> over window:time( 60s ) from entry-point >> lowLevelSensorStream, >> countDistinct( $tagid ) ); >> then >> insert( SituationManager.createCrowdInAreaEvent( "Crowd, number >> people: " + $count, Event.THREAT_LOW, $coverageArea, $RFIDReader, $count, >> 60, 10 ) ); >> end >> >> I need to refer $obs object in order to compare timing of new observation >> with last event. Is it possible to do that? >> >> Thanks a lot, >> Matteo. >> >> ___ >> 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
Hi Vincent, i have an rfid reader and i am collecting tagid from that sensor. I would like to raise an event when the number of different tags in a time interval is greater than 20 (for example). On Tue, May 22, 2012 at 2:33 PM, Vincent LEGENDRE < vincent.legen...@eurodecision.com> wrote: > No. > You can't use $obs before you bind it (2nd pattern) > The binding done for accumulate pattern must be used in some accumulate > fonction in order to be seen outside. > > Instead of trying to fix your rule, may be you can describe (with simple > phrases) what you are trying to do ? > > -- > *De: *"Matteo Cusmai" > *À: *"Rules Users List" > *Envoyé: *Mardi 22 Mai 2012 12:33:16 > *Objet: *[rules-users] Accumulate function > > > Hi all, > i am going to use a custom accumulate function like that: > > rule "CrowdInAreaEvent-event" > no-loop > when > $RFIDReader : SensorFixed(type == Sensor.SENSOR_TYPE_RFID, > $coverageArea : areaOfInterest ) > not CrowdInAreaEvent( sensor == $RFIDReader, this meets[ 5s ] $obs > ) > $count : Integer( intValue > 10 ) > from accumulate( $obs : RFIDObservation( $tagid : tagid, > sensor == $RFIDReader ) > over window:time( 60s ) from entry-point lowLevelSensorStream, > countDistinct( $tagid ) ); > then > insert( SituationManager.createCrowdInAreaEvent( "Crowd, number > people: " + $count, Event.THREAT_LOW, $coverageArea, $RFIDReader, $count, > 60, 10 ) ); > end > > I need to refer $obs object in order to compare timing of new observation > with last event. Is it possible to do that? > > Thanks a lot, > Matteo. > > ___ > 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
No. You can't use $obs before you bind it (2nd pattern) The binding done for accumulate pattern must be used in some accumulate fonction in order to be seen outside . Instead of trying to fix your rule, may be you can describe (with simple phrases) what you are trying to do ? - Mail original - De: "Matteo Cusmai" À: "Rules Users List" Envoyé: Mardi 22 Mai 2012 12:33:16 Objet: [rules-users] Accumulate function Hi all, i am going to use a custom accumulate function like that: rule "CrowdInAreaEvent-event" no-loop when $RFIDReader : SensorFixed(type == Sensor.SENSOR_TYPE_RFID, $coverageArea : areaOfInterest ) not CrowdInAreaEvent( sensor == $RFIDReader, this meets[ 5s ] $obs ) $count : Integer( intValue > 10 ) from accumulate( $obs : RFIDObservation( $tagid : tagid, sensor == $RFIDReader ) over window:time( 60s ) from entry-point lowLevelSensorStream, countDistinct( $tagid ) ); then insert( SituationManager.createCrowdInAreaEvent( "Crowd, number people: " + $count, Event.THREAT_LOW, $coverageArea, $RFIDReader, $count, 60, 10 ) ); end I need to refer $obs object in order to compare timing of new observation with last event. Is it possible to do that? Thanks a lot, Matteo. ___ 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] Accumulate function
Hi all, i am going to use a custom accumulate function like that: rule "CrowdInAreaEvent-event" no-loop when $RFIDReader : SensorFixed(type == Sensor.SENSOR_TYPE_RFID, $coverageArea : areaOfInterest ) not CrowdInAreaEvent( sensor == $RFIDReader, this meets[ 5s ] $obs ) $count : Integer( intValue > 10 ) from accumulate( $obs : RFIDObservation( $tagid : tagid, sensor == $RFIDReader ) over window:time( 60s ) from entry-point lowLevelSensorStream, countDistinct( $tagid ) ); then insert( SituationManager.createCrowdInAreaEvent( "Crowd, number people: " + $count, Event.THREAT_LOW, $coverageArea, $RFIDReader, $count, 60, 10 ) ); end I need to refer $obs object in order to compare timing of new observation with last event. Is it possible to do that? Thanks a lot, Matteo. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Accumulate function, events and stream processing
Ok, i have just tested again: 5.2.0 Final is working, 5.3.0 Final doesn't work So i will create an issue in Drools bug tracking system, as you suggest. Many thanks for your help, happy to check that there is people replying in this forum. -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3710387.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] Accumulate function, events and stream processing
If you are convinced that it is a bug, the normal procedure would be for you to raise a JIRA in the Drools bug tracking system (which you know), where you can upload files for reproducing the bug. -W On 02/02/2012, juankera wrote: > I'm back again to share my last steps. Well, i think i have found what's > wrong. > > First of all, I've just created a project with my drools code outside the > osgi environment. Now it's easier to read the code and test different cases. > > I don't know which is the usual way to share this projects here, could you > please tell how can i package and send you the test case? > > Anyway, my last tests point to a bug in 5.3.0 Final Version. I'm running the > same rules, the same code with 5.2.0 Final (accumulate working fine) and > with 5.3.0 Final (accumulate doesn't work at all). > > Anyone ready to help me?? > > Many thanks. > > -- > View this message in context: > http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3710212.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, events and stream processing
I'm back again to share my last steps. Well, i think i have found what's wrong. First of all, I've just created a project with my drools code outside the osgi environment. Now it's easier to read the code and test different cases. I don't know which is the usual way to share this projects here, could you please tell how can i package and send you the test case? Anyway, my last tests point to a bug in 5.3.0 Final Version. I'm running the same rules, the same code with 5.2.0 Final (accumulate working fine) and with 5.3.0 Final (accumulate doesn't work at all). Anyone ready to help me?? Many thanks. -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3710212.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] Accumulate function, events and stream processing
On 01/02/2012, juankera wrote: > Hey, i've just found this issue. > > https://issues.jboss.org/browse/JBRULES-3075 A window:length was never meant to cause retraction of events. > > Copied from third comment: > > /This actually means the whole "window:length" feature can't be used at all. > events are not cleared from memory and therefor accumulate functions > constantly return wrong results./ window:length works correctly in 5.3.0. Please produce a simple, complete test-case. The code you've shown is incomplete and can't be run. -W > > Is that true? Anyone using window:length out there? > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3706423.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, events and stream processing
Hey, i've just found this issue. https://issues.jboss.org/browse/JBRULES-3075 Copied from third comment: /This actually means the whole "window:length" feature can't be used at all. events are not cleared from memory and therefor accumulate functions constantly return wrong results./ Is that true? Anyone using window:length out there? -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3706423.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] Accumulate function, events and stream processing
No way, working with entry-points doesn't help. I get the same results. Could you please help me with another clues? Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3706414.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] Accumulate function, events and stream processing
laune wrote > > Well, I can't reproduce the failure of "FirstRule" to fire - both > rules fire after the insertion of a single event. > Sorry, i don't understand what you mean. Are you able to put the accumulate function to work? -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703998.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] Accumulate function, events and stream processing
Yes, i have only one DRL with these two rules defined. I have actually these resources: But only a DRL file. Anyway, i've also tried without Decision Tables and only one specific DRL File, with no luck. I will try again with entry-points, as Philipp suggests -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703977.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] Accumulate function, events and stream processing
Well, I can't reproduce the failure of "FirstRule" to fire - both rules fire after the insertion of a single event. Of course, I use a simplified scenario, and there are only these two rules in my knowledge base. Using 5.3.0 final; not OSGi, but I don't see how this should matter. Check the RULES_CHANGESET = "org/openhab/core/drools/changeset.xml"; Does it really refer to one DRL with just these two rules? -W On 31/01/2012, Philipp Herzig wrote: > Have you ever tried out to insert the events into the > WorkingMemoryEntryPoint "EventStream" directly that you have commented out > in your execute method? > and read the window from that eventstream in your rule, that is, > "window:length( 5 ) from entry-point EvenStream". > > Of course, the second rule will fire also if it would be no event but a > simple fact for drools. > Unfortunately, I do not know under which condition the default entrypoint > is populated. > > 2012/1/31 juankera > >> Tried, but won't work. >> >> Ok, step by step. >> >> 1- DRL File >> >> Event declared, FirstRule won't work and SecondRule is working properly >> (neither count or sum) >> >> declare StateEvent >>@role( event ) >> end >> >> rule "FirstRule" >> >> when >>Number( $total : doubleValue ) from accumulate( >>StateEvent(itemName=="Temperatura", $val : newState) over >> window:length( 5 ), >>count ( 1 )) >> then >>System.out.println("" + $total); >> end >> >> rule "SecondRule " >> >> when >>StateEvent(itemName=="Temperatura", $val : newState) >> then >>System.out.println("" + >> ((DecimalType)$val).toBigDecimal().doubleValue()); >> end >> >> 2. Important lines from Engine starting (notice that i'm using stateful >> session) >> >> KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); >> >> kbuilder.add(ResourceFactory.newClassPathResource(RULES_CHANGESET, >> getClass()), ResourceType.CHANGE_SET); >> >> KnowledgeBaseConfiguration kbaseConfig = >> KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); >> kbaseConfig.setOption( EventProcessingOption.STREAM ); >> KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig); >> >> StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); >> >> 3. Attached you can find the full code >> http://drools.46999.n3.nabble.com/file/n3703619/RuleService.java >> RuleService.java >> >> 4. Environment >> >> Drools 5.3.0 FINAL, running on a OSGi environment. >> >> >> >> >> >> -- >> View this message in context: >> http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703619.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 >> > > > > -- > > Philipp Herzig, M.Sc. > > Mail: pher...@googlemail.com > Cell: 0178 - 6156244 > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Accumulate function, events and stream processing
Have you ever tried out to insert the events into the WorkingMemoryEntryPoint "EventStream" directly that you have commented out in your execute method? and read the window from that eventstream in your rule, that is, "window:length( 5 ) from entry-point EvenStream". Of course, the second rule will fire also if it would be no event but a simple fact for drools. Unfortunately, I do not know under which condition the default entrypoint is populated. 2012/1/31 juankera > Tried, but won't work. > > Ok, step by step. > > 1- DRL File > > Event declared, FirstRule won't work and SecondRule is working properly > (neither count or sum) > > declare StateEvent >@role( event ) > end > > rule "FirstRule" > > when >Number( $total : doubleValue ) from accumulate( >StateEvent(itemName=="Temperatura", $val : newState) over > window:length( 5 ), >count ( 1 )) > then >System.out.println("" + $total); > end > > rule "SecondRule " > > when >StateEvent(itemName=="Temperatura", $val : newState) > then >System.out.println("" + > ((DecimalType)$val).toBigDecimal().doubleValue()); > end > > 2. Important lines from Engine starting (notice that i'm using stateful > session) > > KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); > > kbuilder.add(ResourceFactory.newClassPathResource(RULES_CHANGESET, > getClass()), ResourceType.CHANGE_SET); > > KnowledgeBaseConfiguration kbaseConfig = > KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); > kbaseConfig.setOption( EventProcessingOption.STREAM ); > KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig); > > StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); > > 3. Attached you can find the full code > http://drools.46999.n3.nabble.com/file/n3703619/RuleService.java > RuleService.java > > 4. Environment > > Drools 5.3.0 FINAL, running on a OSGi environment. > > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703619.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 > -- Philipp Herzig, M.Sc. Mail: pher...@googlemail.com Cell: 0178 - 6156244 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Accumulate function, events and stream processing
Tried, but won't work. Ok, step by step. 1- DRL File Event declared, FirstRule won't work and SecondRule is working properly (neither count or sum) declare StateEvent @role( event ) end rule "FirstRule" when Number( $total : doubleValue ) from accumulate( StateEvent(itemName=="Temperatura", $val : newState) over window:length( 5 ), count ( 1 )) then System.out.println("" + $total); end rule "SecondRule " when StateEvent(itemName=="Temperatura", $val : newState) then System.out.println("" + ((DecimalType)$val).toBigDecimal().doubleValue()); end 2. Important lines from Engine starting (notice that i'm using stateful session) KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newClassPathResource(RULES_CHANGESET, getClass()), ResourceType.CHANGE_SET); KnowledgeBaseConfiguration kbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); kbaseConfig.setOption( EventProcessingOption.STREAM ); KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); 3. Attached you can find the full code http://drools.46999.n3.nabble.com/file/n3703619/RuleService.java RuleService.java 4. Environment Drools 5.3.0 FINAL, running on a OSGi environment. -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703619.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] Accumulate function, events and stream processing
On 31/01/2012, juankera wrote: > So no entry-point (using default) is OK. > > I've declared this Fact as event, like this: > > declare StateEvent > @role( event ) > end OK - another thing excluded. > > > And I have changed a property in drools.default.rulebase.conf > (drools.eventProcessingMode = STREAM) to make the engine works in stream > mode. > > I'm opening a stateful session too (newStatefulKnowledgeSession();) > > Is that ok? > May i set stream mode in code like config.setOption( > EventProcessingOption.STREAM );? The property setting looks OK, but who knows. Try and use this: KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); config.setOption( EventProcessingOption.STREAM ); ... kSession = newStatelessKnowledgeSession(config); > May i use any specific clock type? window:length should not depend on the clock. If all of this fails, you'll have to provide a complete minimum example demonstrating the problem, and which Drools version you are using. -W > > Thanks > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Accumulate function, events and stream processing
So no entry-point (using default) is OK. I've declared this Fact as event, like this: declare StateEvent @role( event ) end And I have changed a property in drools.default.rulebase.conf (drools.eventProcessingMode = STREAM) to make the engine works in stream mode. I'm opening a stateful session too (newStatefulKnowledgeSession();) Is that ok? May i set stream mode in code like config.setOption( EventProcessingOption.STREAM );? May i use any specific clock type? Thanks -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703245.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] Accumulate function, events and stream processing
On 31/01/2012, juankera wrote: > Hi again, > > No, there isn't any special entry-point. Is that mandatory? As i've read, > there is a default entry-point, true? Correct. I was just checking to exclude a possible error (i.e., not using the names entry-point in the rule). > > About your second question, yes. All my rules are working properly. In fact > i have another rule using only StateEvent(itemName=="Temperatura") as > condition, and it's fired OK. Last things I can think of: - Do you declare StateEvent with @role(event)? - Do you run the Engine in STREAM mode? -W > > Do you think it could be something related to the engine invocation? (code, > not rules) > > > Thanks > > -- > View this message in context: > http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703042.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, events and stream processing
Hi again, No, there isn't any special entry-point. Is that mandatory? As i've read, there is a default entry-point, true? About your second question, yes. All my rules are working properly. In fact i have another rule using only StateEvent(itemName=="Temperatura") as condition, and it's fired OK. Do you think it could be something related to the engine invocation? (code, not rules) Thanks -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703042.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] Accumulate function, events and stream processing
If count() returns 0 then you don't have any matching StateEvent facts in Working Memory. - Do you enter via an entry point? - Does a rule using StateEvent(itemName=="Temperatura") fire? -W On 31/01/2012, juankera wrote: > Thanks for your help. > > This sentence is working properly (i've tried it out of this rule) and > count(1) doesn't give me anything. > > when > Number( $total : doubleValue ) from accumulate( > StateEvent(itemName=="Temperatura", $val : newState) over > window:length( 5 ), > count ( 1 )) > then > > Always returning 0.0, with every fact i put in the working memory. > > Any idea? > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3702702.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, events and stream processing
Thanks for your help. This sentence is working properly (i've tried it out of this rule) and count(1) doesn't give me anything. when Number( $total : doubleValue ) from accumulate( StateEvent(itemName=="Temperatura", $val : newState) over window:length( 5 ), count ( 1 )) then Always returning 0.0, with every fact i put in the working memory. Any idea? -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3702702.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] Accumulate function, events and stream processing
Is ((DecimalType)$val).toBigDecimal() working correctly, given what you have in $val? Also, check that count(1) instead of sum(...) produces the expected value. -W On 30/01/2012, Juanker Atina wrote: > I need your help to put to work an accumulate function. > > So, i will introduce several facts into working memory (StateEvent, which i > declare as event) and i want to accumulate the last five values. > > I have changed a property in drools.default.rulebase.conf > (drools.eventProcessingMode = STREAM) to make the engine works in stream > mode. > > And my rule is: > > > declare StateEvent > @role( event ) > end > > rule "Testing" > > when > $total : Number() from accumulate( > StateEvent(itemName=="Temperatura", $val : newState) over > window:length( 5 ), > sum ( ((DecimalType)$val).toBigDecimal().doubleValue() ) ) > then > #actions > end > > > But it's not working, as the value of $total is 0.0, no matter what i do, > and the rule is firing with every fact in the working memory. > > Any help will be appreciated. > Thanks > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Accumulate function, events and stream processing
I need your help to put to work an accumulate function. So, i will introduce several facts into working memory (StateEvent, which i declare as event) and i want to accumulate the last five values. I have changed a property in drools.default.rulebase.conf (drools.eventProcessingMode = STREAM) to make the engine works in stream mode. And my rule is: declare StateEvent @role( event ) end rule "Testing" when $total : Number() from accumulate( StateEvent(itemName=="Temperatura", $val : newState) over window:length( 5 ), sum ( ((DecimalType)$val).toBigDecimal().doubleValue() ) ) then #actions end But it's not working, as the value of $total is 0.0, no matter what i do, and the rule is firing with every fact in the working memory. Any help will be appreciated. Thanks ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] accumulate function
Thanks Wendy, both solutions look great, I will try them. Thanks for your help. -- View this message in context: http://drools.46999.n3.nabble.com/accumulate-function-tp3353507p3356209.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] 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
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
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
[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
Re: [rules-users] accumulate function help
You want this rule to fire if there are less than 90 measurements labelled "active movement" in the last 7*24*60 measurements? The only thing I can spot is incorrect syntax in the second accumulate: from accumulate(MertAdat(sorszam > ($max_sorszam - 7 * 24 * 60), $cimke : cimke == "aktiv_mozgas"), The required imports are as usual: all the classes you refer to in the rule, Adattypus and MertAdat. If there are more problems, please post the error message(s). -W On Thu, Dec 3, 2009 at 8:04 PM, SzA84 wrote: > > Hi! > > I would like to use the accumulate function in my rule. I found this: > > http://www.docjar.com/html/api/org/drools/compiler/PackageBuilderConfiguration.java.html > > but i don't know exactly, which imports I need to the package and how can I > make it work. > This is my rule: > > rule "aktivitas" > when > Adattipus(ertek == "mozgas") > > $max_sorszam : Number() > from accumulate(MertAdat($sorszam : sorszam), > max($sorszam)) > > $aktiv_mozgas_cimke_szam : Number(intValue < 90) > from accumulate(MertAdat(sorszam > $max_sorszam - (7 > * 24 * 60), $cimke : cimke == "aktiv_mozgas"), > count($cimke)) > then > end > > > Sorry for this simple question! > -- > View this message in context: > http://n3.nabble.com/accumulate-function-help-tp67445p67445.html > Sent from the Drools - User 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] accumulate function help
Hi! I would like to use the accumulate function in my rule. I found this: http://www.docjar.com/html/api/org/drools/compiler/PackageBuilderConfiguration.java.html but i don't know exactly, which imports I need to the package and how can I make it work. This is my rule: rule "aktivitas" when Adattipus(ertek == "mozgas") $max_sorszam : Number() from accumulate(MertAdat($sorszam : sorszam), max($sorszam)) $aktiv_mozgas_cimke_szam : Number(intValue < 90) from accumulate(MertAdat(sorszam > $max_sorszam - (7 * 24 * 60), $cimke : cimke == "aktiv_mozgas"), count($cimke)) then end Sorry for this simple question! -- View this message in context: http://n3.nabble.com/accumulate-function-help-tp67445p67445.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users