Re: [rules-users] Rules from Multiple DRLs use the same namespace

2011-10-18 Thread Wolfgang Laun
Your description seems somewhat incomplete.

On 18 October 2011 21:53, rajee.sakthi  wrote:

> Hi,
>
> I am a newbie to DROOLs. I want to cross check with you for any potential
> issues that you see about my DROOLs usage.
> I have a requirement to create multiple DRLs that use the same namespace.
> Hence, I am adding rules from DRL1, DRL2, DRL3 to a package named
> "com.myproj.pkg".
> And at some point I am removing rules of DRL1 from the knowledge package
> leaving rest of the rules.
>
So the rules from DRL2 and DRL3 remain in the package.


>
> When all the rules from the package are removed, then I am removing the
> knowledge package.
>
Which, according my previous statment (which reflects your description),
will never happen.


> This is all done with StatefulSession.
>
> So my rules removal code looks like this:
>
> String pkgName = kpkg.getName();
> Collection rules = kpkg.getRules();
>
> for(Rule rule : rules) {
>knowledgeBase.removeRule(pkgName, rule.getName());
> }
>
> KnowledgePackage pkgAfterRemove =
> knowledgeBase.getKnowledgePackage(pkgName);
> Collection rulesAfterCleanup = pkgAfterRemove.getRules()
> if(rulesAfterCleanup == null || rulesAfterCleanup.isEmpty()) {
>knowledgeBase.removeKnowledgePackage(pkgName);
> }
>
> I tested this logic and it works fine but does anyone see any side effects
> of such logic?
>

A knowledge base is just a bunch of data with rules, functions, etc. There's
not much point in removing the package after all the rules are gone, so why
bother?

And one wonders: is the remaining knowledge base still good for creating
sessions?

-W


> I did a short search in the forum and couldnt find any similar posts.
>
> Thanks a bunch,
> Rajee
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Rules-from-Multiple-DRLs-use-the-same-namespace-tp3432304p3432304.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] Why this rule fires immediately ?

2011-10-18 Thread Wolfgang Laun
First time around I also stumbled over this, especially because the
documention fails to describe the actual behaviour, which is certainly not
intuitive. All uses of "length n" that I know *do not* include things of
length n-1, n-2,... 1. Imagine going into a shop and asking for a belt of
length 60" and getting one of 12". A Java array of length 10 isn't 3 or 5 or
9 elements long. Many mathematical procedures that use a data window of
length n must avoid shorter samples, or use different treatment, e.g., an
initial value problem, or statistical evaluation.

-W


On 18 October 2011 23:33, Mark Proctor  wrote:

> Think about the logic you have written.
>
> length(3) does not mean that it must have 3, but that it is the last
> three. So it could be 0, 1, 2 or 3 in length.
>
> As soon s you have 1, 2, or 3 insertions if any one of those creates an
> average of > 30 the rule fires.
>
> So you are inserting  a ZZZBean that creates an average, even if it's an
> average with a count of 1, over 30.
>
> Mark
> On 18/10/2011 07:20, eskomk wrote:
> > Hi all,
> >
> > Here is the rule:
> >
> > CLIP -->
> > rule "ZZZOver30" dialect "mvel"
> >
> > when
> >  $tsb : ZZZBean($prof : profileID)
> >  $avg : Number( doubleValue>  30 ) from accumulate(
> >  ZZZBean( $tempr : temperature, profileID == $prof) over
> > window:length( 3 ),
> >  average( $tempr ) )
> > then
> >  // do something
> > end
> > CLIP<--
> >
> > The intention as you can see is that the rule fires if the average
> > temperature rises above 30 degrees (of Celsius) in some measuring period.
> > For testing purposes the rule takes a specific number of temperatures
> > (window:length), in production environment the window will be time
> > (window:time(Xm)).
> >
> > My question is, why this rule fires immediately after drools-expert is
> > started ?
> > Is there something wrong in syntax ?
> >
> > In startup there are obviously no objects of this kind (ZZZBean) in
> Working
> > Set's memory, so it really shouldn't fire.
> >
> > We are running Drools ver. 5.1.1 as a web service on top of apache, and
> the
> > facts (events) are fed to Drools via REST interface as XML.
> >
> > thanks and regards,
> > Esko
> > -
> > Esko Hujanen
> > www.ebsolut.fi
> >
> >
> > --
> > View this message in context:
> http://drools.46999.n3.nabble.com/Why-this-rule-fires-immediately-tp3430427p3430427.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] Help! Activations firing out of salience order

2011-10-18 Thread Edson Tirelli
   This was a duplicate of https://issues.jboss.org/browse/JBRULES-3111 that
was fixed last week. It will be released in 5.3.0.final.

   Edson

2011/10/18 Swindells, Thomas 

> Ouch looks like we and anybody on 5.1.1 needs to desperately update then.*
> ***
>
> Though I am rather concerned by this issue
> https://issues.jboss.org/browse/JBRULES-3211  “Rules fires on incorrect
> condition” – has this been looked at/is the issue correct as a rules engine
> which fires random rules when it shouldn’t would be problematic!
>
> ** **
>
> Thomas
>
> ** **
>
> *From:* rules-users-boun...@lists.jboss.org [mailto:
> rules-users-boun...@lists.jboss.org] *On Behalf Of *Wolfgang Laun
> *Sent:* 18 October 2011 11:05
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Help! Activations firing out of salience
> order
>
> ** **
>
> There used to be a subtle bug in the PriorityHeapQueue containing the
> activations.
>
> See https://issues.jboss.org/browse/JBRULES-3044
>
> -W
>
> 2011/10/18 Swindells, Thomas 
>
> In our project we have been experiencing a large number of intermittent
> unit test failures when we are testing our rules (on drools 5.1.1).
>
> After a lot of debugging, examining our rules for logic errors,
> experimenting and generally scratching our head trying to work out what is
> wrong, we have noticed that sometimes (but very intermittently) activations
> are firing in the wrong order.
>
>  
>
> In our rulebase we have two rules, Rule A salience 80 and Rule B salience
> 70. Whilst debugging we made Rule A and B are identical other than rule B
> having some additional constraints on the end. 
>
> Dumping out the agenda events we have observed the following actions
> occurring:
>
> BEFORE_FIRED rule X
>
> CREATED_ACTIVATION Rule A
>
> CREATED_ACTIVATION Rule B
>
> AFTER_FIRED rule X
>
>  
>
> … (no references to either rule/activation)
>
>  
>
> BEFORE_FIRED Rule B
>
> CANCELLED Rule A
>
> AFTER_FIRED Rule B
>
>  
>
> How can Rule B be firing before Rule A when both activations exist?
>
> Does anybody know of any bugs in 5.1.1 that may be causing this? 
>
> We have a branch of code on 5.3 and that also has had intermittent unit
> test failures, we’ve not had chance to examine whether this is the same
> pattern or just a different logic issue.
>
>  
>
> Please help,
>
>  
>
> Thomas
>
>  
>
>  
>
> ** **
> --
>
>
>
> **
> 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
>
>


-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why this rule fires immediately ?

2011-10-18 Thread Mark Proctor
Think about the logic you have written.

length(3) does not mean that it must have 3, but that it is the last 
three. So it could be 0, 1, 2 or 3 in length.

As soon s you have 1, 2, or 3 insertions if any one of those creates an 
average of > 30 the rule fires.

So you are inserting  a ZZZBean that creates an average, even if it's an 
average with a count of 1, over 30.

Mark
On 18/10/2011 07:20, eskomk wrote:
> Hi all,
>
> Here is the rule:
>
> CLIP -->
> rule "ZZZOver30" dialect "mvel"
>
> when
>  $tsb : ZZZBean($prof : profileID)
>  $avg : Number( doubleValue>  30 ) from accumulate(
>  ZZZBean( $tempr : temperature, profileID == $prof) over
> window:length( 3 ),
>  average( $tempr ) )
> then
>  // do something
> end
> CLIP<--
>
> The intention as you can see is that the rule fires if the average
> temperature rises above 30 degrees (of Celsius) in some measuring period.
> For testing purposes the rule takes a specific number of temperatures
> (window:length), in production environment the window will be time
> (window:time(Xm)).
>
> My question is, why this rule fires immediately after drools-expert is
> started ?
> Is there something wrong in syntax ?
>
> In startup there are obviously no objects of this kind (ZZZBean) in Working
> Set's memory, so it really shouldn't fire.
>
> We are running Drools ver. 5.1.1 as a web service on top of apache, and the
> facts (events) are fed to Drools via REST interface as XML.
>
> thanks and regards,
> Esko
> -
> Esko Hujanen
> www.ebsolut.fi
>
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/Why-this-rule-fires-immediately-tp3430427p3430427.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] Rules from Multiple DRLs use the same namespace

2011-10-18 Thread rajee.sakthi
Hi,

I am a newbie to DROOLs. I want to cross check with you for any potential
issues that you see about my DROOLs usage.
I have a requirement to create multiple DRLs that use the same namespace.
Hence, I am adding rules from DRL1, DRL2, DRL3 to a package named
"com.myproj.pkg".
And at some point I am removing rules of DRL1 from the knowledge package
leaving rest of the rules.

When all the rules from the package are removed, then I am removing the
knowledge package.

This is all done with StatefulSession.

So my rules removal code looks like this:

String pkgName = kpkg.getName();
Collection rules = kpkg.getRules();

for(Rule rule : rules) {   
knowledgeBase.removeRule(pkgName, rule.getName());
}

KnowledgePackage pkgAfterRemove =
knowledgeBase.getKnowledgePackage(pkgName);
Collection rulesAfterCleanup = pkgAfterRemove.getRules()
if(rulesAfterCleanup == null || rulesAfterCleanup.isEmpty()) {
knowledgeBase.removeKnowledgePackage(pkgName);
}

I tested this logic and it works fine but does anyone see any side effects
of such logic?

I did a short search in the forum and couldnt find any similar posts.

Thanks a bunch,
Rajee

--
View this message in context: 
http://drools.46999.n3.nabble.com/Rules-from-Multiple-DRLs-use-the-same-namespace-tp3432304p3432304.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] Help! Activations firing out of salience order

2011-10-18 Thread Swindells, Thomas
Ouch looks like we and anybody on 5.1.1 needs to desperately update then.
Though I am rather concerned by this issue 
https://issues.jboss.org/browse/JBRULES-3211  "Rules fires on incorrect 
condition" - has this been looked at/is the issue correct as a rules engine 
which fires random rules when it shouldn't would be problematic!

Thomas

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: 18 October 2011 11:05
To: Rules Users List
Subject: Re: [rules-users] Help! Activations firing out of salience order

There used to be a subtle bug in the PriorityHeapQueue containing the 
activations.

See https://issues.jboss.org/browse/JBRULES-3044

-W
2011/10/18 Swindells, Thomas mailto:tswinde...@nds.com>>
In our project we have been experiencing a large number of intermittent unit 
test failures when we are testing our rules (on drools 5.1.1).
After a lot of debugging, examining our rules for logic errors, experimenting 
and generally scratching our head trying to work out what is wrong, we have 
noticed that sometimes (but very intermittently) activations are firing in the 
wrong order.

In our rulebase we have two rules, Rule A salience 80 and Rule B salience 70. 
Whilst debugging we made Rule A and B are identical other than rule B having 
some additional constraints on the end.
Dumping out the agenda events we have observed the following actions occurring:
BEFORE_FIRED rule X
CREATED_ACTIVATION Rule A
CREATED_ACTIVATION Rule B
AFTER_FIRED rule X

... (no references to either rule/activation)

BEFORE_FIRED Rule B
CANCELLED Rule A
AFTER_FIRED Rule B

How can Rule B be firing before Rule A when both activations exist?
Does anybody know of any bugs in 5.1.1 that may be causing this?
We have a branch of code on 5.3 and that also has had intermittent unit test 
failures, we've not had chance to examine whether this is the same pattern or 
just a different logic issue.

Please help,

Thomas





**
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] Help! Activations firing out of salience order

2011-10-18 Thread Wolfgang Laun
There used to be a subtle bug in the PriorityHeapQueue containing the
activations.

See https://issues.jboss.org/browse/JBRULES-3044

-W

2011/10/18 Swindells, Thomas 

>  In our project we have been experiencing a large number of intermittent
> unit test failures when we are testing our rules (on drools 5.1.1).
>
> After a lot of debugging, examining our rules for logic errors,
> experimenting and generally scratching our head trying to work out what is
> wrong, we have noticed that sometimes (but very intermittently) activations
> are firing in the wrong order.
>
> ** **
>
> In our rulebase we have two rules, Rule A salience 80 and Rule B salience
> 70. Whilst debugging we made Rule A and B are identical other than rule B
> having some additional constraints on the end. 
>
> Dumping out the agenda events we have observed the following actions
> occurring:
>
> BEFORE_FIRED rule X
>
> CREATED_ACTIVATION Rule A
>
> CREATED_ACTIVATION Rule B
>
> AFTER_FIRED rule X
>
> ** **
>
> … (no references to either rule/activation)
>
> ** **
>
> BEFORE_FIRED Rule B
>
> CANCELLED Rule A
>
> AFTER_FIRED Rule B
>
> ** **
>
> How can Rule B be firing before Rule A when both activations exist?
>
> Does anybody know of any bugs in 5.1.1 that may be causing this? 
>
> We have a branch of code on 5.3 and that also has had intermittent unit
> test failures, we’ve not had chance to examine whether this is the same
> pattern or just a different logic issue.
>
> ** **
>
> Please help,
>
> ** **
>
> Thomas
>
> ** **
>
> ** **
>
> --
>
>
> **
> 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] Why this rule fires immediately ?

2011-10-18 Thread eskomk
Hi Wolfgang et al,

Thanks for the response.

>> Note that the rule will fire as soon as you insert the first ZZZBean,
>> because a window of lenght N is actually a window of lenght <= N.

Why window:length is implemented this way ?
And with "window:time(5m)" it is presumably the same, actual time being <= 5
minutes ?

Best regards,
Esko
-
Esko Hujanen
www.ebsolut.fi

--
View this message in context: 
http://drools.46999.n3.nabble.com/Why-this-rule-fires-immediately-tp3430427p3430785.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] Help needed - how to get Number and intValue in Guvnor

2011-10-18 Thread Praveen
Hello,

I am new to Drools and trying to write rules using Guvnor GUI.
I have uploaded POJO's that are required for my rules.
I am facing issue trying to get Number()(the one in Bold-Italics) and
intValue in the Guvnor GUI.
Below is the rule for reference, its taken from one of the examples provided
in Drools Planner.


// Accumulate hard constraints
rule "hardConstraintsBroken"
salience -1 // Do the other rules first (optional, for performance)
when
$hardTotal : */Number(/)* from accumulate(
IntConstraintOccurrence(constraintType ==
ConstraintType.NEGATIVE_HARD, $weight : weight),
sum($weight) // Vote for
http://jira.jboss.com/jira/browse/JBRULES-1075
)
then
scoreCalculator.setHardConstraintsBroken($hardTotal.intValue());
end

--
View this message in context: 
http://drools.46999.n3.nabble.com/Help-needed-how-to-get-Number-and-intValue-in-Guvnor-tp3430730p3430730.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] drools persistence contract

2011-10-18 Thread Michal Bali
Hi all,

When persisting a session, process instance or workitem, Drools persists
some parts of the state as byte arrays.
I am trying to upgrade from 5.1 to 5.3 and I have some existing
sessions/processes persisted in the database. I am wondering if it is safe
to upgrade? Will the bytearrays created by 5.1 work fine with 5.3?
Is there any document describing persistence compatibility between versions?
I don’t see much in the “new and noteworthy” in relation to persistence.

Thanks.
Keep up the good work!
Best regards,
Michal
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Help! Activations firing out of salience order

2011-10-18 Thread Swindells, Thomas
In our project we have been experiencing a large number of intermittent unit 
test failures when we are testing our rules (on drools 5.1.1).
After a lot of debugging, examining our rules for logic errors, experimenting 
and generally scratching our head trying to work out what is wrong, we have 
noticed that sometimes (but very intermittently) activations are firing in the 
wrong order.

In our rulebase we have two rules, Rule A salience 80 and Rule B salience 70. 
Whilst debugging we made Rule A and B are identical other than rule B having 
some additional constraints on the end.
Dumping out the agenda events we have observed the following actions occurring:
BEFORE_FIRED rule X
CREATED_ACTIVATION Rule A
CREATED_ACTIVATION Rule B
AFTER_FIRED rule X

... (no references to either rule/activation)

BEFORE_FIRED Rule B
CANCELLED Rule A
AFTER_FIRED Rule B

How can Rule B be firing before Rule A when both activations exist?
Does anybody know of any bugs in 5.1.1 that may be causing this?
We have a branch of code on 5.3 and that also has had intermittent unit test 
failures, we've not had chance to examine whether this is the same pattern or 
just a different logic issue.

Please help,

Thomas





**
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