Batch processing of facts in Drools?
by Ryan Fitzgerald
Hi,
In our application, we want to process a large amount of facts. However, to avoid an overload on memory and drools, we would like to process the facts in batches.
Our rules are setup so that we only insert a small number of initial or "root" facts, and then these facts trigger rules to fire that cause many other facts to be inserted, themselves triggering other rules.
One way of batching this would be for the application to only insert the root facts into memory one by one and not inserting the next root fact until the previous one (and the batch of facts associated with it) have been processed and subsequently revoked.
However, instead of the batching being controlled by the application, I would like to use a rule to do this i.e. insert all the root facts into memory and then call fireAllRules and have them processed one at a time.
Does anyone have an idea how I can write a rule that causes a set of facts to trigger their rules, one fact at a time?
Thanks.
14 years, 9 months
Re: [rules-users] rules-users Digest, Vol 40, Issue 41
by Nilima R
The documentation available for Guvnor does not contain any examples .Is
there any other documentation available so that we can understand how to
create functions,dsl and other features available in Guvnor.
Nilima
____________________________________________
Experience certainty. IT Services
Business Solutions
Outsourcing
____________________________________________
From:
rules-users-request(a)lists.jboss.org
To:
rules-users(a)lists.jboss.org
Date:
03/11/2010 01:19 AM
Subject:
rules-users Digest, Vol 40, Issue 41
Sent by:
rules-users-bounces(a)lists.jboss.org
Send rules-users mailing list submissions to
rules-users(a)lists.jboss.org
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
rules-users-request(a)lists.jboss.org
You can reach the person managing the list at
rules-users-owner(a)lists.jboss.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."
Today's Topics:
1. A general question about this mailing list (Nathan Bell)
2. Re: A general question about this mailing list (Geoffrey De Smet)
3. Re: Problems count and sumarizing data in facts (Yamil Bracho)
----------------------------------------------------------------------
Message: 1
Date: Wed, 10 Mar 2010 11:31:00 -0600
From: "Nathan Bell" <Nathan.Bell(a)pharmacyonesource.com>
Subject: [rules-users] A general question about this mailing list
To: <rules-users(a)lists.jboss.org>
Message-ID: <608FA11CE83EC54C98A8E4715C0EED571966DF(a)rphpost.rph.int>
Content-Type: text/plain; charset="us-ascii"
I'm fairly new to this list, but I have already seen a great deal of
helpful information being shared. The problem is that a collection of
emails makes a poor knowledge base. Has there ever been an attempt to
set up a forum/wiki/knowledgebase for the Drools community? I would be
willing to help with setting that up if it is something the community
wants. I'm guessing that this has been talked about before, so I want to
check-in with the community and ask why it does not exist already. Is
there some barrier that I am not aware of that would make a different
format undesirable?
Thank You,
Nathan Bell
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.jboss.org/pipermail/rules-users/attachments/20100310/90dfc6b...
------------------------------
Message: 2
Date: Wed, 10 Mar 2010 19:25:39 +0100
From: Geoffrey De Smet <ge0ffrey.spam(a)gmail.com>
Subject: Re: [rules-users] A general question about this mailing list
To: rules-users(a)lists.jboss.org
Message-ID: <hn8o73$b59$1(a)dough.gmane.org>
Content-Type: text/plain; charset=windows-1252; format=flowed
I personally don't believe much in a wiki (there is a drools wiki btw),
because it gets stale fast.
I believe much more in the reference manual, which is checked in in
Subversion.
In the Drools Planner manual I 've already added "meta" information,
such as where jira is and how to build from source etc etc.
https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/t...
With kind regards,
Geoffrey De Smet
Nathan Bell schreef:
> I?m fairly new to this list, but I have already seen a great deal of
> helpful information being shared. The problem is that a collection of
> emails makes a poor knowledge base. Has there ever been an attempt to
> set up a forum/wiki/knowledgebase for the Drools community? I would be
> willing to help with setting that up if it is something the community
> wants. I?m guessing that this has been talked about before, so I want to
> check-in with the community and ask why it does not exist already. Is
> there some barrier that I am not aware of that would make a different
> format undesirable?
>
>
>
> Thank You,
>
>
>
> Nathan Bell
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
------------------------------
Message: 3
Date: Wed, 10 Mar 2010 19:38:09 +0000
From: Yamil Bracho <yamilbracho(a)hotmail.com>
Subject: Re: [rules-users] Problems count and sumarizing data in facts
To: Drools UserList <rules-users(a)lists.jboss.org>
Message-ID: <SNT130-w419F987761CE0A1C882981AA330(a)phx.gbl>
Content-Type: text/plain; charset="windows-1252"
Thanks Thomas.
I rewrote the rule as:
rule "Sumatoria de lineas detalle vs Header" salience 10 when Number(
$total : doubleValue) from accumulate( Map(this["_TYPE_"] ==
"D", $monto : eval(Double.parseDouble(this.get("MONTO")))),
sum($monto)) $map : Map(this["_TYPE_"] == "H",
this["MT_TOTAL"] != $total) then System.out.println("TOTAL=" +
$total); listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"Error en el Detalle: El n?mero del lineas de detalle (" + $total +
") no empareja con lo del
encabezado (" + $map.get("NU_REGISTROS") + ")")); end
but I am getting errors in the parseDouble:
[828,29]: [ERR 101] Line 828:29 no viable alternative at input 'Double' in
rule "Sumatoria de lineas detalle vs Header" in pattern Map[828,67]: [ERR
102] Line 828:67 mismatched input ')' expecting 'then' in rule "Sumatoria
de lineas detalle vs Header"
Any hint...
From: TSwindells(a)nds.com
To: rules-users(a)lists.jboss.org
Date: Wed, 10 Mar 2010 15:13:49 +0000
Subject: Re: [rules-users] Problems count and sumarizing data in facts
To convert from string to double you have to full back to java:
Something along the lines of
$monto : eval(Double.parseDouble(this.get(?MONTO?)))
However even with doing this your rules are unlikely to work consistently
as you expect. Using equality tests on doubles is fundamentally unsafe as
doubles
aren?t represented exactly and may not exactly match the value you think
you have. Force instance 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1 != 1.0
(dependent on floating point chipset etc). If you are dealing with
currency then it is far simpler and safer
to just operate with integers and divide by 100 when you want to display
the value. The other alternative is to use BigDecimal which will store an
exact representation but will probably require more work with getting your
accumulate function correct. Your
last option is to use Math.abs(left-right) < 0.1 to see if they are
approximately equal. More details can be found here
http://firstclassthoughts.co.uk/java/traps/java_double_traps.html
Thomas
From: rules-users-bounces(a)lists.jboss.org [
mailto:rules-users-bounces@lists.jboss.org]
On Behalf Of Yamil Bracho
Sent: 10 March 2010 14:27
To: Drools UserList
Subject: Re: [rules-users] Problems count and sumarizing data in facts
I solved the counting of detail lines this way:
rule "Contador de lineas detalle vs Header"
salience 10
when
Number($count : intValue) from accumulate(
$mp : Map(this["_TYPE_"] == "D"), count($mp))
$map : Map(this["_TYPE_"] == "H",
this["NU_REGISTROS"] != $count)
then
System.out.println("NumRecs=" + $count);
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"El n?mero del lineas de detalle
(" + $count +
") no empareja con lo del
encabezado (" + $map.get("NU_REGISTROS") + ")"));
end
However, I still got problem with summarize the amounts. I wrote
rule "Sumatoria de lineas detalle vs Header"
salience 10
when
Number( $total : doubleValue) from accumulate(
Map(this["_TYPE_"] == "D",
$monto : ((Number) this["MONTO"]),
sum($monto)))
$map : Map(this["_TYPE_"] == "H",
this["MT_TOTAL"] != $total)
then
System.out.println("TOTAL=" + $total);
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"Error en el Detalle: El n?mero
del lineas de detalle (" + $total +
") no empareja con lo del
encabezado (" + $map.get("NU_REGISTROS") + ")"));
end
And i am getting mismatched input" so my question is how to convert a
string to double in this line "$monto : ((Number) this["MONTO"])," ?
TIA
Yamil
From: yamilbracho(a)hotmail.com
To: rules-users(a)lists.jboss.org
Date: Tue, 9 Mar 2010 17:41:43 +0000
Subject: [rules-users] Problems count and sumarizing data in facts
Hi, I have two kind of facts in a map.
There is a field called _TYPE_ (H)eader, D)etail)
In the Header line I have two String fields, one for the number of details
lines ("NU_REGISTROS") and another for the sum of the detail line
("MT_TOTAL")
In the detail lines I only have a String field called "MONTO"
I would like to build two rules. One to check the count of detail lines
versus the field in the header line so I wrote :
rule "Contador de lineas detalle vs Header"
salience 10
when
$numRecs : Number()
from accumulate(Map(this["_TYPE_"] == "D", $d :
this["_NUMLINE_"]), count($d))
$map : Map(this["_TYPE_"] == "H",
this["NU_REGISTROS"] != $numRecs)
then
System.out.println("NumRecs=" + $numRecs);
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"Error en el Detalle: El n?mero
del lineas de detalle (" + $total +
") no empareja con lo del
encabezado (" + $map.get("NU_REGISTROS") + ")"));
end
However I always got "NumRecs=1" when i print out the value of $numRecs
but I am absolute sure there is two details lines...
Second when i try to sumarize the total field in the details line i got
(MONTO in the detail line is a string):
rule "Sumatoria de lineas detalle vs Header"
salience 10
when
$total : Number()
from accumulate(Map(this["_TYPE_"] == "D",
$monto : this["MONTO"]),
sum(eval(Double.valueOf((String) $monto
))))
$map : Map(this["_TYPE_"] == "H",
this["MT_TOTAL"] != $total)
then
System.out.println("TOTAL=" + $total);
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"Error en el Detalle: El n?mero
del lineas de detalle (" + $total +
") no empareja con lo del
encabezado (" + $map.get("NU_REGISTROS") + ")"));
end
but I got
Rule Compilation error : [Rule name='Sumatoria de lineas detalle vs
Header']
rule/Rule_Sumatoria_de_lineas_detalle_vs_Header_0.java (9:1313) :
The method eval(Double) is undefined for the type
Rule_Sumatoria_de_lineas_detalle_vs_Header_0
Any help in those tow problems
TIA
Yamil
Actual?zate gratis al nuevo Internet Explorer 8 y
navega m?s seguro
Compartir tus mejores FOTOS es f?cil en Messenger
?DESCUBRE c?mo!
**************************************************************************************
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
**************************************************************************************
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.
An NDS Group Limited company. www.nds.com
_________________________________________________________________
Recibe en tu m?vil un SMS con tu Hotmail recibido. ?Date de alta ya!
http://serviciosmoviles.es.msn.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.jboss.org/pipermail/rules-users/attachments/20100310/0149706...
------------------------------
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
End of rules-users Digest, Vol 40, Issue 41
*******************************************
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
14 years, 9 months
Issue with comparing values from multiple lists
by Gaurav
Hi All,
I am facing issues with iterating multiple lists and matching the
statements.
1. dealTechList - This is a list which contains DealTypeTotal class and
which has following params.
protected String summaryType ;
protected double listPrice;
protected double discount;
protected double valueDiscount;
protected double netPrice;
2. routingRuleList - This is another list which has all the routing rules
data which contains RoutingRule Object.
I want to collect all the routing rules satisfying these conditions.
a. summaryType should match with Routing Rules nonStdTerms.
b. listPrice of techList should fall between routing rules' listPriceFrom
and listPriceTo.
b. discount of techList should fall between routing rules' discountFrom and
discountTo.
$selectedASTRulesWithOutHier : ArrayList()
from collect ($routingRule : RoutingRule(currency == $curr
&& flexAttribute4 !="SDM"
&& (
listPriceFrom <= ???? && listPriceTo > ???
&& discountPriceFrom <= ??? && discountPriceTo > ??
&& nonStdTerm == ??? )
)
from $routingRuleList)
There could be multiple DealTypeTotal objects present in dealTechList.
Can some one please suggest any solution to this problem.
Thanks,
Gaurav
--
View this message in context: http://n3.nabble.com/Issue-with-comparing-values-from-multiple-lists-tp44...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 9 months
Re: [rules-users] rules-users Digest, Vol 40, Issue 41
by Nathan Bell
True. I probably should not have included wiki in that list. What I am
thinking of is more along the lines of a forum (think stackoverflow.com)
where conversations are recorded, can be commented on, voted on, rated,
etc. Some mechanism where conversations like the ones that occur in this
mailing list are persisted and become searchable.
-Nathan
Date: Wed, 10 Mar 2010 19:25:39 +0100
From: Geoffrey De Smet <ge0ffrey.spam(a)gmail.com>
Subject: Re: [rules-users] A general question about this mailing list
To: rules-users(a)lists.jboss.org
Message-ID: <hn8o73$b59$1(a)dough.gmane.org>
Content-Type: text/plain; charset=windows-1252; format=flowed
I personally don't believe much in a wiki (there is a drools wiki btw),
because it gets stale fast.
I believe much more in the reference manual, which is checked in in
Subversion.
In the Drools Planner manual I 've already added "meta" information,
such as where jira is and how to build from source etc etc.
https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/
trunk/target/docs/drools-planner/html_single/index.html
With kind regards,
Geoffrey De Smet
Nathan Bell schreef:
> I?m fairly new to this list, but I have already seen a great deal of
> helpful information being shared. The problem is that a collection of
> emails makes a poor knowledge base. Has there ever been an attempt to
> set up a forum/wiki/knowledgebase for the Drools community? I would be
> willing to help with setting that up if it is something the community
> wants. I?m guessing that this has been talked about before, so I want
to
> check-in with the community and ask why it does not exist already. Is
> there some barrier that I am not aware of that would make a different
> format undesirable?
>
>
>
> Thank You,
>
>
>
> Nathan Bell
>
>
>
>
>
------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
------------------------------
Message: 3
Date: Wed, 10 Mar 2010 19:38:09 +0000
From: Yamil Bracho <yamilbracho(a)hotmail.com>
Subject: Re: [rules-users] Problems count and sumarizing data in facts
To: Drools UserList <rules-users(a)lists.jboss.org>
Message-ID: <SNT130-w419F987761CE0A1C882981AA330(a)phx.gbl>
Content-Type: text/plain; charset="windows-1252"
Thanks Thomas.
I rewrote the rule as:
rule "Sumatoria de lineas detalle vs Header" salience 10 when
Number( $total : doubleValue) from accumulate(
Map(this["_TYPE_"] == "D", $monto :
eval(Double.parseDouble(this.get("MONTO")))), sum($monto))
$map : Map(this["_TYPE_"] == "H", this["MT_TOTAL"] !=
$total) then System.out.println("TOTAL=" + $total);
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"Error en el Detalle: El n?mero del lineas de detalle (" + $total +
") no empareja con lo del encabezado (" + $map.get("NU_REGISTROS") +
")")); end
but I am getting errors in the parseDouble:
[828,29]: [ERR 101] Line 828:29 no viable alternative at input 'Double'
in rule "Sumatoria de lineas detalle vs Header" in pattern Map[828,67]:
[ERR 102] Line 828:67 mismatched input ')' expecting 'then' in rule
"Sumatoria de lineas detalle vs Header"
Any hint...
From: TSwindells(a)nds.com
To: rules-users(a)lists.jboss.org
Date: Wed, 10 Mar 2010 15:13:49 +0000
Subject: Re: [rules-users] Problems count and sumarizing data in facts
To convert from string to double you have to full back to java:
Something along the lines of
$monto : eval(Double.parseDouble(this.get(?MONTO?)))
However even with doing this your rules are unlikely to work
consistently as you expect. Using equality tests on doubles is
fundamentally unsafe as doubles
aren?t represented exactly and may not exactly match the value you
think you have. Force instance 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1
!= 1.0 (dependent on floating point chipset etc). If you are dealing
with currency then it is far simpler and safer
to just operate with integers and divide by 100 when you want to
display the value. The other alternative is to use BigDecimal which
will store an exact representation but will probably require more work
with getting your accumulate function correct. Your
last option is to use Math.abs(left-right) < 0.1 to see if they are
approximately equal. More details can be found here
http://firstclassthoughts.co.uk/java/traps/java_double_traps.html
Thomas
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org]
On Behalf Of Yamil Bracho
Sent: 10 March 2010 14:27
To: Drools UserList
Subject: Re: [rules-users] Problems count and sumarizing data in facts
I solved the counting of detail lines this way:
rule "Contador de lineas detalle vs Header"
salience 10
when
Number($count : intValue) from accumulate(
$mp : Map(this["_TYPE_"] == "D"), count($mp))
$map : Map(this["_TYPE_"] == "H",
this["NU_REGISTROS"] != $count)
then
System.out.println("NumRecs=" + $count);
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"El n?mero del lineas de
detalle (" + $count +
") no empareja con lo del
encabezado (" + $map.get("NU_REGISTROS") + ")"));
end
However, I still got problem with summarize the amounts. I wrote
rule "Sumatoria de lineas detalle vs Header"
salience 10
when
Number( $total : doubleValue) from accumulate(
Map(this["_TYPE_"] == "D",
$monto : ((Number) this["MONTO"]),
sum($monto)))
$map : Map(this["_TYPE_"] == "H",
this["MT_TOTAL"] != $total)
then
System.out.println("TOTAL=" + $total);
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"Error en el Detalle: El
n?mero del lineas de detalle (" + $total +
") no empareja con lo del
encabezado (" + $map.get("NU_REGISTROS") + ")"));
end
And i am getting mismatched input" so my question is how to convert a
string to double in this line "$monto : ((Number) this["MONTO"])," ?
TIA
Yamil
From: yamilbracho(a)hotmail.com
To: rules-users(a)lists.jboss.org
Date: Tue, 9 Mar 2010 17:41:43 +0000
Subject: [rules-users] Problems count and sumarizing data in facts
Hi, I have two kind of facts in a map.
There is a field called _TYPE_ (H)eader, D)etail)
In the Header line I have two String fields, one for the number of
details lines ("NU_REGISTROS") and another for the sum of the detail
line ("MT_TOTAL")
In the detail lines I only have a String field called "MONTO"
I would like to build two rules. One to check the count of detail lines
versus the field in the header line so I wrote :
rule "Contador de lineas detalle vs Header"
salience 10
when
$numRecs : Number()
from accumulate(Map(this["_TYPE_"] == "D", $d :
this["_NUMLINE_"]), count($d))
$map : Map(this["_TYPE_"] == "H",
this["NU_REGISTROS"] != $numRecs)
then
System.out.println("NumRecs=" + $numRecs);
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"Error en el Detalle: El
n?mero del lineas de detalle (" + $total +
") no empareja con lo del
encabezado (" + $map.get("NU_REGISTROS") + ")"));
end
However I always got "NumRecs=1" when i print out the value of $numRecs
but I am absolute sure there is two details lines...
Second when i try to sumarize the total field in the details line i got
(MONTO in the detail line is a string):
rule "Sumatoria de lineas detalle vs Header"
salience 10
when
$total : Number()
from accumulate(Map(this["_TYPE_"] == "D",
$monto : this["MONTO"]),
sum(eval(Double.valueOf((String) $monto
))))
$map : Map(this["_TYPE_"] == "H",
this["MT_TOTAL"] != $total)
then
System.out.println("TOTAL=" + $total);
listBitacora.add(new BitacoraDTO($map.get("_NUMLINE_"),
"Error en el Detalle: El
n?mero del lineas de detalle (" + $total +
") no empareja con lo del
encabezado (" + $map.get("NU_REGISTROS") + ")"));
end
but I got
Rule Compilation error : [Rule name='Sumatoria de lineas detalle vs
Header']
rule/Rule_Sumatoria_de_lineas_detalle_vs_Header_0.java (9:1313)
: The method eval(Double) is undefined for the type
Rule_Sumatoria_de_lineas_detalle_vs_Header_0
Any help in those tow problems
TIA
Yamil
Actual?zate gratis al nuevo Internet Explorer 8 y
navega m?s seguro
Compartir tus mejores FOTOS es f?cil en Messenger
?DESCUBRE c?mo!
************************************************************************
**************
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
************************************************************************
**************
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.
An NDS Group Limited company. www.nds.com
_________________________________________________________________
Recibe en tu m?vil un SMS con tu Hotmail recibido. ?Date de alta ya!
http://serviciosmoviles.es.msn.com/
14 years, 9 months
Accumulator function
by Glenn Macgregor
Hi All,
I am building an accumulator function to get the maximum value with a limit, so for instance I have need to find the highest negative (closest to 0 without being positive). I am calling the accumulator maxnegative, I have created the function but can't seem to figure out how to get the engine to recognize it. The only documentation I have seen about it states you need to add a config line to the configuration file or use a system property. What configuration file is this referring to and/or what system property can I set to make this work.
Thanks
Glenn
14 years, 9 months
A general question about this mailing list
by Nathan Bell
I'm fairly new to this list, but I have already seen a great deal of
helpful information being shared. The problem is that a collection of
emails makes a poor knowledge base. Has there ever been an attempt to
set up a forum/wiki/knowledgebase for the Drools community? I would be
willing to help with setting that up if it is something the community
wants. I'm guessing that this has been talked about before, so I want to
check-in with the community and ask why it does not exist already. Is
there some barrier that I am not aware of that would make a different
format undesirable?
Thank You,
Nathan Bell
14 years, 9 months
Template salience
by Bertrand Grottier
Hello,
Is it possible to specify a template salience such as:
function long getNbJours(String pStrDDeb, String pStrDFin)
{
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Date dDeb = sdf.parse(pStrDDeb) ;
Date dFin = sdf.parse(pStrDFin) ;
long diff = dFin.getTime() - dDeb.getTime() ;
return (diff / (24 * 60 * 60 * 1000)) ;
}
template "tarification_produit"
rule "Periode(a){row.rowNumber}"
salience getNbJours("@{ddeb}", "@{dfin}")
when
$p : Produit(id == 1, eval( dDeb.before( getDate("@{ddeb}") ) ) )
then
$p.setId(2) ;
$p.setPrix(@{prix}) ;
update( $p );
end
end template
I encounter a java.lang.NullPointerException.
Thank you in advance for your help.
Regards,
Benoît
_________________________________________________________________
Hotmail arrive sur votre téléphone ! Compatible Iphone, Windows Phone, Blackberry, …
http://www.messengersurvotremobile.com/?d=Hotmail
14 years, 9 months
Rule looping question
by Glenn Macgregor
Hi All,
I am in the process of creating some rules for a POC I am doing using drools, having some issues understanding why I have an infinite loop in a rule.
Rule in question:
rule "Check Parameter Threshold Update Breach"
no-loop true
when
ParameterUpdateEvent($name : name)
from entry-point "ParamUpdateStream"
$param : Parameter(name == $name)
Number($averageUpdateValue : doubleValue)
from accumulate(ParameterUpdateEvent(name == $param.name, $value : value)
over window:time(15m)
from entry-point "ParamUpdateStream", average($value))
$tholdBreach : Parameter.Threshold(windowSize == 15,
threshold >= $averageUpdateValue) from $param.thresholds
$firedAlert : AlertInformation(name == $param.name,
severity != $tholdBreach.severity)
then
System.out.println("Updating alert from '" + $firedAlert.getSeverity() +
"' to '" + $tholdBreach.getSeverity() +
"' alarm: Average update value for " +
$param.getName() + " = " + $averageUpdateValue);
$firedAlert.setSeverity($tholdBreach.getSeverity());
update($firedAlert);
//insert(new AlertInformation($param.getName(), $tholdBreach.getSeverity()));
//modify($firedAlert);
end
I understand what is happening up to the $tholdBreach : Parameter.Threshold line. Each Parameter can have a list of thresholds and what I want this line to do is pick the correct threshold if any are breached. For instance Param1 has 2 thresholds: MINOR and CRITICAL, the MINOR threshold should fire if averageUpdateValue is >= 50, the CRITICAL threshold should fire if averageUpdateValue is >= 40. The first problem I need to solve (in a better way) is getting the correct threshold out of this, the way I do it now is but putting the MINOR threshold in the list before the CRITICAL one. This means that it will be checked first from the line in question. This, to me, is not a good solution. Is there a more deterministic way to do this, I was thinking of somehow using the difference between the threshold and the averageUpdateValue to get the right now but I don't see how that can work from a rule stand point.
The other question I have is this rule loops infinitely when the averageUpdateValue is below 40 (CRITICAL threshold) between a MINOR alarm and a CRITICAL alarm and I don't see why or how because tholdBreach should always be the CRITICAL alarm and the rule would stop on the next line, but it is alernatly returning CRITICAL then MINOR which is confusing. To confuse this even more when I comment out the update($firedAlert) and replace that with a retract($firedAlert) and insert(new ...) it does not loop.
Any ideas would be great.
Thanks
Glenn
14 years, 9 months
Template rules & eval
by Bertrand Grottier
Hello,
I want to use template rules. Here is my .drt file:
template header
ddeb
dfin
prix
package com.tarification
import java.util.Date ;
import tarification.Produit ;
import java.text.SimpleDateFormat;
function Date getDate(String pStrDate)
{
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
return sdf.parse(pStrDate) ;
}
template "tarification_produit"
rule "Periode(a){row.rowNumber}"
when
$p : Produit(id == 1, eval( dDeb.before( getDate("@{ddeb}") ) ) )
then
$p.setId(2) ;
$p.setPrix(@{prix}) ;
update( $p );
end
end template
I modified an example provided with Drools but encounter the following exception:
Exception in thread "main" org.drools.RuntimeDroolsException: Exception executing predicate com.tarification.Rule_Periode2_0Predicate0Invoker@2110b61d
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:279)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:143)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:147)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at tarification.TestTemplate.executeExample(TestTemplate.java:49)
at tarification.TestTemplate.main(TestTemplate.java:26)
Caused by: java.lang.NullPointerException
at com.tarification.Rule_Periode2_0.predicate0(Rule_Periode2_0.java:9)
at com.tarification.Rule_Periode2_0Predicate0Invoker.evaluate(Rule_Periode2_0Predicate0Invoker.java:23)
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:272)
... 11 more
I am puzzle because when I copy the drl generated string in a drl file, everything works fine.
Any idea ? Thank you in advance.
Regards,
Benoît
_________________________________________________________________
Hotmail et MSN dans la poche? HOTMAIL et MSN sont dispo gratuitement sur votre téléphone!
http://www.messengersurvotremobile.com/?d=Hotmail
14 years, 9 months
Loading facts by xml
by Bertrand Grottier
Hello,
I keep trying loading facts by xml based on "Example 3.37. Constructing a pipeline".
Now, I encounter a java.lang.RuntimeException when inserting the fact in the working memory:
com.thoughtworks.xstream.mapper.CannotResolveClassException: Produit : Produit
It guess it comes from the definition of my xml file. In the example, a reference to path/facts.xml is mentionned but I could not found this file. I would like to see an example.
Where is it ?
Otherwise can someone provide me with an other example ?
Regards,
Benoît
_________________________________________________________________
Découvrez comment SURFER DISCRETEMENT sur un site de rencontres !
http://clk.atdmt.com/FRM/go/206608211/direct/01/
14 years, 9 months