Re: [rules-users] Rule one-by-one comparison

2011-08-26 Thread miguel machado
Thank you guys, you rock.

_ miguel, PT





2011/8/26 Swindells, Thomas 

> xPath is also a pretty powerful solution, have one xPath that fines the
> rule node, then against that node run a pair of xpath expression which
> extract the agenda-group value and the literal restriction value(s).
>
> ** **
>
> Thomas
>
> ** **
>
> *From:* rules-users-boun...@lists.jboss.org [mailto:
> rules-users-boun...@lists.jboss.org] *On Behalf Of *Wolfgang Laun
> *Sent:* 26 August 2011 16:58
>
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Rule one-by-one comparison
>
> ** **
>
> Perhaps you consider using JAXB for creating Java classes from the XML
> schema, which lets you unmarshall the XML file into an object tree which is
> easy to traverse and provides you with all the data as objects and lists; no
> string parsing at all.
>
> -W
>
> 
>
> 2011/8/26 miguel machado 
>
> Hi there,
>
> ** **
>
> I'm considering analyzing the pre-compiled xml document as a "last resort":
> I actually find it easier to deal with objects/collections/arrays than with
> Strings and XML, etc. This is a personal stance with no much foundation
> regarding this specific drools scenario, really. 
>
> ** **
>
> What I need to do (before the actual comparison) is to group the rules
> according to the agenda-group plus a variable value within a condition
> within every , such as this:
>
> ** **
>
> 
>
>   ...
>
>   
>
>   ...
>
>   
>
>  
>
>   
>
>   ...
>
> 
>
> ** **
>
> (in this case I'd like to index this rule to a 2-key hashmap => [0da90b15,
> "d:"])
>
> ** **
>
> XML manipulation would mean parsing hundreds of rules, extracting the
> agenda-group and the "object" condition manually. Further down the road, I
> will also need to extract the whole LHS to perform the comparison. I'm
> afraid this would take too long, but I might be wrong.
>
> ** **
>
> Thanks again,
>
> _ miguel, PT
>
> ** **
>
> ** **
>
> ** **
>
> 2011/8/26 Swindells, Thomas 
>
> Wouldn’t it be easier to analyze the pre-converted xml document rather than
> trying to do it on the compiled knowledge base (presumably you keep the old
> xml file around) – this way it is just string and xml manipulation, though
> it depends on how exactly the matches must be.
>
>  
>
> Thomas
>
>  
>
> *From:* rules-users-boun...@lists.jboss.org [mailto:
> rules-users-boun...@lists.jboss.org] *On Behalf Of *miguel machado
> *Sent:* 26 August 2011 15:55
>
>
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Rule one-by-one comparison
>
>  
>
> Hi there,
>
>  
>
> Thanks for replying. I will try to explain my current challenge a bit
> further:
>
>  
>
> I have a ruleset which is sent by an external application in XML format. I
> load it to a new knowledge package and then into a knowlegde base. It is
> made of smaller subsets of 3 rules each (a "set" rule, a "reset" rule and a
> "clear" rule) that control my application's internal logic, which must be
> stateful and kept on disk (basically, there are 2 important hashmaps).
>
>  
>
> Whenever the rules change, a new XML ruleset is sent and my application
> restarts and loads the new file the exact same way. However, I need to
> resume the application state (as it was before the restart). I also have to
> do this selectively, because I only care about the application state on a
> per-rule basis:
>
>  
>
> - If a rule keeps the same LHS, I need to resume the application state
> before restart regarding that rule;
>
> - If a rule has been modified, I may discard the state regarding that rule
> (do not need to load it);
>
>  
>
> I don't think I can refactor this problem into smaller ones, the
> application internal logic is indeed complex I'm afraid. The rules are
> analyzed in a stateless way BUT they control a set of critical information
> which must be stateful (beyond restarts). There is a (not-so-direct)
> correspondence between each (fire, reset, clear) rule subset and the
> information that keeps track of the internal state, so that's why I need to
> verify rule-by-rule what has changed between restarts.
>
>  
>
> I hope this helps to describe the problem.
>
> Thanks again for reading. Any help is greatly appreciated.
>
>  
>
> _ miguel, PT
>
>  
>
>  
>

Re: [rules-users] Rule one-by-one comparison

2011-08-26 Thread miguel machado
Hi there,

I'm considering analyzing the pre-compiled xml document as a "last resort":
I actually find it easier to deal with objects/collections/arrays than with
Strings and XML, etc. This is a personal stance with no much foundation
regarding this specific drools scenario, really.

What I need to do (before the actual comparison) is to group the rules
according to the agenda-group plus a variable value within a condition
within every , such as this:


  ...
  
  ...
  
 
  
  ...


(in this case I'd like to index this rule to a 2-key hashmap => [0da90b15,
"d:"])

XML manipulation would mean parsing hundreds of rules, extracting the
agenda-group and the "object" condition manually. Further down the road, I
will also need to extract the whole LHS to perform the comparison. I'm
afraid this would take too long, but I might be wrong.

Thanks again,
_ miguel, PT



2011/8/26 Swindells, Thomas 

> Wouldn’t it be easier to analyze the pre-converted xml document rather than
> trying to do it on the compiled knowledge base (presumably you keep the old
> xml file around) – this way it is just string and xml manipulation, though
> it depends on how exactly the matches must be.
>
> ** **
>
> Thomas
>
> ** **
>
> *From:* rules-users-boun...@lists.jboss.org [mailto:
> rules-users-boun...@lists.jboss.org] *On Behalf Of *miguel machado
> *Sent:* 26 August 2011 15:55
>
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Rule one-by-one comparison
>
> ** **
>
> Hi there,
>
> ** **
>
> Thanks for replying. I will try to explain my current challenge a bit
> further:
>
> ** **
>
> I have a ruleset which is sent by an external application in XML format. I
> load it to a new knowledge package and then into a knowlegde base. It is
> made of smaller subsets of 3 rules each (a "set" rule, a "reset" rule and a
> "clear" rule) that control my application's internal logic, which must be
> stateful and kept on disk (basically, there are 2 important hashmaps).
>
> ** **
>
> Whenever the rules change, a new XML ruleset is sent and my application
> restarts and loads the new file the exact same way. However, I need to
> resume the application state (as it was before the restart). I also have to
> do this selectively, because I only care about the application state on a
> per-rule basis:
>
> ** **
>
> - If a rule keeps the same LHS, I need to resume the application state
> before restart regarding that rule;
>
> - If a rule has been modified, I may discard the state regarding that rule
> (do not need to load it);
>
> ** **
>
> I don't think I can refactor this problem into smaller ones, the
> application internal logic is indeed complex I'm afraid. The rules are
> analyzed in a stateless way BUT they control a set of critical information
> which must be stateful (beyond restarts). There is a (not-so-direct)
> correspondence between each (fire, reset, clear) rule subset and the
> information that keeps track of the internal state, so that's why I need to
> verify rule-by-rule what has changed between restarts.
>
> ** **
>
> I hope this helps to describe the problem.
>
> Thanks again for reading. Any help is greatly appreciated.
>
> ** **
>
> _ miguel, PT
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> 2011/8/26 Swindells, Thomas 
>
> Can you share what you actual requirement is and why you need to do it?***
> *
>
> Can you perhaps change the problem into one that is simpler to solve?
>
> Ie rather than comparing knowledge bases can you get the input to these
> knowledgebases?
>
> Can you control what that input is, if it is a DSL or a spreadsheet then
> your comparision job will probably become a lot simpler.
>
>  
>
> Thomas
>
>  
>
> *From:* rules-users-boun...@lists.jboss.org [mailto:
> rules-users-boun...@lists.jboss.org] *On Behalf Of *miguel machado
> *Sent:* 26 August 2011 13:01
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Rule one-by-one comparison
>
>  
>
> Esteban,
>
>  
>
> Thank you very much for that. I will look into it.
>
> Any other ideas, anyone?
>
>  
>
> _ miguel
>
>  
>
>  
>
>  
>
> 2011/8/26 Esteban Aliverti 
>
> You can try to use drools-verifier. This project basically lets you define
> rules about your rules. 
>
> You can have a look at its tests to see how it works.
>
> You can get more info about drools-verifier here:
> http://community.jboss.org/wiki/DroolsV

Re: [rules-users] Rule one-by-one comparison

2011-08-26 Thread miguel machado
Hi there,

Thanks for replying. I will try to explain my current challenge a bit
further:

I have a ruleset which is sent by an external application in XML format. I
load it to a new knowledge package and then into a knowlegde base. It is
made of smaller subsets of 3 rules each (a "set" rule, a "reset" rule and a
"clear" rule) that control my application's internal logic, which must be
stateful and kept on disk (basically, there are 2 important hashmaps).

Whenever the rules change, a new XML ruleset is sent and my application
restarts and loads the new file the exact same way. However, I need to
resume the application state (as it was before the restart). I also have to
do this selectively, because I only care about the application state on a
per-rule basis:

- If a rule keeps the same LHS, I need to resume the application state
before restart regarding that rule;
- If a rule has been modified, I may discard the state regarding that rule
(do not need to load it);

I don't think I can refactor this problem into smaller ones, the application
internal logic is indeed complex I'm afraid. The rules are analyzed in a
stateless way BUT they control a set of critical information which must be
stateful (beyond restarts). There is a (not-so-direct) correspondence
between each (fire, reset, clear) rule subset and the information that keeps
track of the internal state, so that's why I need to verify rule-by-rule
what has changed between restarts.

I hope this helps to describe the problem.
Thanks again for reading. Any help is greatly appreciated.

_ miguel, PT





2011/8/26 Swindells, Thomas 

>  Can you share what you actual requirement is and why you need to do it?**
> **
>
> Can you perhaps change the problem into one that is simpler to solve?
>
> Ie rather than comparing knowledge bases can you get the input to these
> knowledgebases?
>
> Can you control what that input is, if it is a DSL or a spreadsheet then
> your comparision job will probably become a lot simpler.
>
> ** **
>
> Thomas
>
> ** **
>
> *From:* rules-users-boun...@lists.jboss.org [mailto:
> rules-users-boun...@lists.jboss.org] *On Behalf Of *miguel machado
> *Sent:* 26 August 2011 13:01
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Rule one-by-one comparison
>
> ** **
>
> Esteban,
>
> ** **
>
> Thank you very much for that. I will look into it.
>
> Any other ideas, anyone?
>
> ** **
>
> _ miguel
>
> ** **
>
> ** **
>
> ** **
>
> 2011/8/26 Esteban Aliverti 
>
> You can try to use drools-verifier. This project basically lets you define
> rules about your rules. 
>
> You can have a look at its tests to see how it works.
>
> You can get more info about drools-verifier here:
> http://community.jboss.org/wiki/DroolsVerifier
>
> ** **
>
> And here you can see how are we using drools-verifier inside Guvnor:
> http://ilesteban.wordpress.com/2010/04/05/guvnors-field-constraints/ ****
>
> ** **
>
> Best Regards,
>
>
> 
>
> Esteban Aliverti
> - Developer @ http://www.plugtree.com
> - Blog @ http://ilesteban.wordpress.com
>
> 
>
> 2011/8/26 miguel machado 
>
>  Hi there everybody,
> 
>
> ** **
>
> I need to perform rule comparison on a project I'm working on using drools
> expert 5.0. For a specific feature implementation, I have two different
> knowledge bases with several rules which I need to compare, one by one. By
> comparing, I mean "inspect" certain conditions within the LHS.
>
> ** **
>
> Currently, I'm able to obtain several attributes from rules
> (org.drools.rule.Rule), such as the agenda-group and the rule name and a few
> others, but I haven't been able to do it all. Going deeper, there is
> LiteralConstraint (for simple conditions) which I can parse and obtain data.
> However, I don't know how to do it for OR-conditions, which I guess
> represents a MultiRestrictionFieldConstraint. Perhaps there is another way?
> 
>
> ** **
>
> I know this may seem like a very unorthodox thing to do, but I don't think
> there is a better way of comparing knowledge packages (except for full text
> comparison). Is there?
>
> ** **
>
> Thanks in advance,
>
> _ miguel, PT
>
> ** **
>
> ** **
>
> -- 
>
> "To understand what is recursion you must first understand recursion"
>
> ** **
>
> ** **
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>

Re: [rules-users] Rule one-by-one comparison

2011-08-26 Thread miguel machado
Esteban,

Thank you very much for that. I will look into it.
Any other ideas, anyone?

_ miguel



2011/8/26 Esteban Aliverti 

> You can try to use drools-verifier. This project basically lets you define
> rules about your rules.
> You can have a look at its tests to see how it works.
> You can get more info about drools-verifier here:
> http://community.jboss.org/wiki/DroolsVerifier
>
> And here you can see how are we using drools-verifier inside Guvnor:
> http://ilesteban.wordpress.com/2010/04/05/guvnors-field-constraints/
>
> Best Regards,
>
> 
>
> Esteban Aliverti
> - Developer @ http://www.plugtree.com
> - Blog @ http://ilesteban.wordpress.com
>
>
> 2011/8/26 miguel machado 
>
>>  Hi there everybody,
>>
>> I need to perform rule comparison on a project I'm working on using drools
>> expert 5.0. For a specific feature implementation, I have two different
>> knowledge bases with several rules which I need to compare, one by one. By
>> comparing, I mean "inspect" certain conditions within the LHS.
>>
>> Currently, I'm able to obtain several attributes from rules
>> (org.drools.rule.Rule), such as the agenda-group and the rule name and a few
>> others, but I haven't been able to do it all. Going deeper, there is
>> LiteralConstraint (for simple conditions) which I can parse and obtain data.
>> However, I don't know how to do it for OR-conditions, which I guess
>> represents a MultiRestrictionFieldConstraint. Perhaps there is another way?
>>
>> I know this may seem like a very unorthodox thing to do, but I don't think
>> there is a better way of comparing knowledge packages (except for full text
>> comparison). Is there?
>>
>> Thanks in advance,
>> _ miguel, PT
>>
>>
>> --
>> "To understand what is recursion you must first understand recursion"
>>
>>
>> ___
>> 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
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Rule one-by-one comparison

2011-08-26 Thread miguel machado
Hi there everybody,

I need to perform rule comparison on a project I'm working on using drools
expert 5.0. For a specific feature implementation, I have two different
knowledge bases with several rules which I need to compare, one by one. By
comparing, I mean "inspect" certain conditions within the LHS.

Currently, I'm able to obtain several attributes from rules
(org.drools.rule.Rule), such as the agenda-group and the rule name and a few
others, but I haven't been able to do it all. Going deeper, there is
LiteralConstraint (for simple conditions) which I can parse and obtain data.
However, I don't know how to do it for OR-conditions, which I guess
represents a MultiRestrictionFieldConstraint. Perhaps there is another way?

I know this may seem like a very unorthodox thing to do, but I don't think
there is a better way of comparing knowledge packages (except for full text
comparison). Is there?

Thanks in advance,
_ miguel, PT


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools 5.1 overview

2010-08-05 Thread miguel machado
thanks a lot, i'll look into it!

_ miguel




2010/8/5 Mark Proctor 

>  On 05/08/2010 10:44, miguel machado wrote:
>
> Hi all,
>
>  I just recently noticed that drools 5.1 is out and i'd like to
> congratulate the jboss team for this great milestone achievement. I've also
> noticed that there is separate documentation for this version on
> http://jboss.org/drools/documentation.html but i haven't been able to find
> the major updates on the project, since 5.0.0.
>
>  I presume the *changelog* so far is huge, so what I was looking is some
> kind of blog post or release announcement so i can update a few reports i've
> been writing on drools features, modules, architecture, API, requirements,
> integration mechanisms, etc.
>
>  Any help is very much appreciated.
> Thanks in advance,
> _ miguel
>
>
> http://downloads.jboss.com/drools/docs/5.1.0.34406.FINAL/drools-introduction/html/ch02.html#d4e33
>
>
>
>
> --
> "To understand what is recursion you must first understand recursion"
>
>
> ___
> rules-users mailing 
> listrules-us...@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] drools 5.1 overview

2010-08-05 Thread miguel machado
Hi all,

I just recently noticed that drools 5.1 is out and i'd like to congratulate
the jboss team for this great milestone achievement. I've also noticed that
there is separate documentation for this version on
http://jboss.org/drools/documentation.html but i haven't been able to find
the major updates on the project, since 5.0.0.

I presume the *changelog* so far is huge, so what I was looking is some kind
of blog post or release announcement so i can update a few reports i've been
writing on drools features, modules, architecture, API, requirements,
integration mechanisms, etc.

Any help is very much appreciated.
Thanks in advance,
_ miguel



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] rule fires while condition is false

2010-05-06 Thread miguel machado
I think you need to use "modify" for that to happen. Otherwise, it doesn't
get re-evaluated. Or maybe it did, but you're using the no-loop /
lock-on-active attributes.

_ miguel



On Thu, May 6, 2010 at 3:51 PM, Shai Bentin  wrote:

> It seems that drools did not re evaluate the EnrichedApplication again
> and thus the value of NetRepayement as fas as it was concerned was 0.
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Bug in "not" ???

2010-05-06 Thread miguel machado
glad i could help.
_ miguel



2010/5/6 

>  Actually, in the light of day, I see why it behaved as it did. It doesn’t
> seem to be caused by the AccountHolder as such, but more the Employment
> object – if there are two of them, one with an accountholder and
> BusinessName that met the criteria, and one without, then the rule will fire
> whether the not is used or not, just on different instances of Employment.
>
>
>
> Thanks for triggering the thought process, Miguel.
>
>
>
> *Tom Murphy*
> *Business Process Consultant
> Wells Fargo HCFG - CORE Deal Decisioning Platform
> 800 S. Jordan Creek Parkway | West Des Moines, IA 50266
> MAC: **X2301-01B**
> **Office: **515 324 4853** | **Mobile: 515 423 4334**
> **This message may contain confidential and/or privileged information.  If
> you are not the addressee or authorized to receive this for the addressee,
> you must not use, copy, disclose, or take any action based on this message
> or any information herein.  If you have received this message in error,
> please advise the sender immediately by reply e-mail and delete this
> message.  Thank you for your cooperation.*
>
>
>
> *From:* rules-users-boun...@lists.jboss.org [mailto:
> rules-users-boun...@lists.jboss.org] *On Behalf Of *miguel machado
> *Sent:* Thursday, May 06, 2010 4:19 AM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Bug in "not" ???
>
>
>
> This is not entirely true: you may have different objects in memory in such
> a way that both fires rule. In this case, if you had two (or more!)
> AccountHolders for the same Employment, each of those having different
> BusinessName's associated, both rules (with and without the 'not') would
> fire.
>
>
>
> Does that make sense?
>
> _ miguel
>
>
>
>
>
>
>
> 2010/5/5 
>
> The following rule fires both when the “not” is there, and also if the
> “not” is commented out. Clearly, both cannot be true, so there is something
> wrong somewhere.
>
>
>
>
> --
> "To understand what is recursion you must first understand recursion"
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Smooks Data Loader uses

2010-05-06 Thread miguel machado
Other than the examples shown in the docs, i don't think i can help. I'll
have to ask someone familiar with drools AND smooks.

_ miguel



On Wed, May 5, 2010 at 9:50 AM, JNaylies  wrote:

>
> no one could help me?
>
> maybe something is not clear. Please tell me what ;)
>
> Regards
> Jérôme
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Smooks-Data-Loader-uses-tp773488p778366.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
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] how "exists" works exactly?

2010-05-06 Thread miguel machado
No idea.. that piece of code works for me, using drools 5.0.1 :-/



2010/5/6 Antonio Neto 

> Oi Miguel,
>
> when I try this in the "doMove" method using the "workingMemory" instead of
> "ksession" I got this error
>
> Exception in thread "main" java.lang.UnsupportedOperationException: this
> is implementedby StatefulKnowledgeImpl
> at org.drools.reteoo.ReteooWorkingMemory.getFactHandles
> (ReteooWorkingMemory.java:363)
>     ...
> ...
>
> Any idea?
>
> Obrigado
>
> Antonio
>
>
> 2010/5/6 miguel machado 
>
> Olá Antonio,
>>
>> // retract all of it just in case
>> for (Object fact : ksession.getFactHandles()) {
>>   ksession.retract((FactHandle) fact);
>> }
>>
>> Hope this helps.
>> _ miguel
>>
>>
>>
>> 2010/5/5 Antonio Neto 
>>
>> Hi,
>>>
>>> Thank you very much for all replies.
>>>
>>> I've tried also with not ( EPackage(...)), but the result is the same.
>>>
>>> I think that I remove the EClass from the facts in my solution, but they
>>> continue in my workingMemory.
>>>
>>> How I can see the facts of the workingMemory object (and how remove it)?
>>>
>>> Thanks
>>>
>>> Best regards
>>>
>>> Antonio
>>>
>>> 2010/5/5 
>>>
>>>> Hi Antonio,
>>>> Documentation states that the complement to "not" is "exists", whereas
>>>> "not" keyword is used to match the absence of a fact (in Working Memory),
>>>> and "exists" keyword is used to test the existence of one or more facts (in
>>>> Working memory).
>>>>
>>>> So if you want to test that a fact is not in working memory, then you
>>>> should  use the
>>>> not(MyClass()) pattern.
>>>>
>>>> Hope this helps,
>>>> Francois.
>>>>
>>>> Antonio Neto  a écrit :
>>>>
>>>>
>>>> > Any idea? Please...
>>>> >
>>>> > 2010/5/4 Antonio Neto 
>>>> >
>>>> >> Hi all,
>>>> >>
>>>> >> I don't know exactly why I have a problem in my "exists" function.
>>>> I've
>>>> >> tried many different ways, but it does not work. Anybody could help
>>>> me,
>>>> >> please?
>>>> >>
>>>> >>
>>>> >> I have the following rules:
>>>> >>
>>>> >> *rule "diff"
>>>> >> when
>>>> >> $var1: EReference(name == "employee")
>>>> >> $var2: EClass(name == "Company", EAllReferences contains $var1)
>>>> >> not (exists( EPackage(EClassifiers contains $var2 ) ))
>>>> >> then
>>>> >> insertLogical(new IntConstraintOccurrence("diff", 10));
>>>> >> end
>>>> >>
>>>> >> rule "ClassesNotReferenced"
>>>> >> when
>>>> >> $q1 : EClass();
>>>> >> $q2 : EPackage(EClassifiers contains $q1);
>>>> >> not( exists ( EReference(EType == $q1) ));
>>>> >> then
>>>> >> insertLogical(new
>>>> IntConstraintOccurrence("ClassesNotReferenced",
>>>> >> 1, $q1));
>>>> >> end*
>>>> >>
>>>> >>
>>>> >> and in my facts (and my EPackage) I have 4 instances of EClass
>>>> "Company"
>>>> >> with a EReference "employee", and another EClass "Person".  I still
>>>> have a
>>>> >> "move" that removes EClasses in my Drools Solver.
>>>> >>
>>>> >> I need to have only one classe "Company" after processing. But it
>>>> removes
>>>> >> only the EClass "Person", when it was supposed to remove one EClass
>>>> "Person"
>>>> >> and 3 ECLasses "Company". Leaving one EClass "Company" in the end.
>>>> >>
>>>> >> The problem is:  when Drools tries to remove a EClass "Person" it
>>>> thinks
>>>> >> that  the EClass "Company" does not exists. But in fact there are 3
>>>> others.
>>>> >>
>>>> >> Any clue about it, please ?
>>>> >>
>>>> >> Thanks
>>>> >>
>>>> >> Bests regards
>>>> >>
>>>> >> Antonio
>>>> >>
>>>> >>
>>>> >>
>>>> >
>>>>
>>>> ___
>>>> 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
>>>
>>>
>>
>>
>> --
>> "To understand what is recursion you must first understand recursion"
>>
>> ___
>> 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
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Bug in "not" ???

2010-05-06 Thread miguel machado
This is not entirely true: you may have different objects in memory in such
a way that both fires rule. In this case, if you had two (or more!)
AccountHolders for the same Employment, each of those having different
BusinessName's associated, both rules (with and without the 'not') would
fire.

Does that make sense?
_ miguel



2010/5/5 

> The following rule fires both when the “not” is there, and also if the
> “not” is commented out. Clearly, both cannot be true, so there is something
> wrong somewhere.




-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] rule fires while condition is false

2010-05-06 Thread miguel machado
Hi there,

er.. why don't you remove your "eval" and just evaluate in the object
binding?

$var = TypeOfObject( netRepaymentAmountAbilityIncludingLiabilities <= 0.65)

Other than that, i don't think a lotta people are still using drools4 and i
have no idea why that is happening. Apparently, it makes no sense :-/
_ miguel


On Thu, May 6, 2010 at 5:53 AM, Shai Bentin  wrote:

> I'm running drools 4. It has been running for a long time with no issues.
>
> I have this weird issue now and I'm wondering what can explain this.
>
> I have the following rule defined.
>
> rule "netRepaymentWithLiabilities1"
> agenda-group "autoUnderwriting"
> when
> #conditions
> enrichedApplication: EnrichedApplicationVersionTO()
> eval
> (enrichedApplication.getNetRepaymentAmountAbilityIncludingLiabilities()
> <= 0.65)
> decision: Decision()
> then
> #actions
> System.out.println("!! " +
> (enrichedApplication.getNetRepaymentAmountAbilityIncludingLiabilities()
> <= 0.65));
> decision.setDecision("APPROVED", "NetRepaymentWthLiblt");
> end
>
> This rule invokes although
> 'enrichedApplication.getNetRepaymentAmountAbilityIncludingLiabilities()'
>  > 1.
> More over in the then part it prints 'false', so how come it invoked
> while the condition is not fulfilled? What can cause this?
>
> Shai
>
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] how "exists" works exactly?

2010-05-06 Thread miguel machado
Olá Antonio,

// retract all of it just in case
for (Object fact : ksession.getFactHandles()) {
  ksession.retract((FactHandle) fact);
}

Hope this helps.
_ miguel



2010/5/5 Antonio Neto 

> Hi,
>
> Thank you very much for all replies.
>
> I've tried also with not ( EPackage(...)), but the result is the same.
>
> I think that I remove the EClass from the facts in my solution, but they
> continue in my workingMemory.
>
> How I can see the facts of the workingMemory object (and how remove it)?
>
> Thanks
>
> Best regards
>
> Antonio
>
> 2010/5/5 
>
>> Hi Antonio,
>> Documentation states that the complement to "not" is "exists", whereas
>> "not" keyword is used to match the absence of a fact (in Working Memory),
>> and "exists" keyword is used to test the existence of one or more facts (in
>> Working memory).
>>
>> So if you want to test that a fact is not in working memory, then you
>> should  use the
>> not(MyClass()) pattern.
>>
>> Hope this helps,
>> Francois.
>>
>> Antonio Neto  a écrit :
>>
>>
>> > Any idea? Please...
>> >
>> > 2010/5/4 Antonio Neto 
>> >
>> >> Hi all,
>> >>
>> >> I don't know exactly why I have a problem in my "exists" function. I've
>> >> tried many different ways, but it does not work. Anybody could help me,
>> >> please?
>> >>
>> >>
>> >> I have the following rules:
>> >>
>> >> *rule "diff"
>> >> when
>> >> $var1: EReference(name == "employee")
>> >> $var2: EClass(name == "Company", EAllReferences contains $var1)
>> >> not (exists( EPackage(EClassifiers contains $var2 ) ))
>> >> then
>> >> insertLogical(new IntConstraintOccurrence("diff", 10));
>> >> end
>> >>
>> >> rule "ClassesNotReferenced"
>> >> when
>> >> $q1 : EClass();
>> >> $q2 : EPackage(EClassifiers contains $q1);
>> >> not( exists ( EReference(EType == $q1) ));
>> >> then
>> >> insertLogical(new
>> IntConstraintOccurrence("ClassesNotReferenced",
>> >> 1, $q1));
>> >> end*
>> >>
>> >>
>> >> and in my facts (and my EPackage) I have 4 instances of EClass
>> "Company"
>> >> with a EReference "employee", and another EClass "Person".  I still
>> have a
>> >> "move" that removes EClasses in my Drools Solver.
>> >>
>> >> I need to have only one classe "Company" after processing. But it
>> removes
>> >> only the EClass "Person", when it was supposed to remove one EClass
>> "Person"
>> >> and 3 ECLasses "Company". Leaving one EClass "Company" in the end.
>> >>
>> >> The problem is:  when Drools tries to remove a EClass "Person" it
>> thinks
>> >> that  the EClass "Company" does not exists. But in fact there are 3
>> others.
>> >>
>> >> Any clue about it, please ?
>> >>
>> >> Thanks
>> >>
>> >> Bests regards
>> >>
>> >> Antonio
>> >>
>> >>
>> >>
>> >
>>
>> ___
>> 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
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Need Sample Java Code

2010-05-06 Thread miguel machado
You can also write your rules in DRL which is much, much easier (especially
in eclipse) and then convert it to XML, like this:

public static synchronized String convertDrlToXmlRule(String drlRule)
throws DroolsParserException {
DrlParser parser = new DrlParser();
PackageDescr descr = parser.parse(drlRule);
XmlDumper dumper = new XmlDumper();
String xmlDumped = dumper.dump(descr);
// XmlPackageReader xmlReader = new XmlPackageReader();
return xmlDumped;
}

Also, there are some examples in the documentation pages.
_ miguel



2010/5/5 Esteban Aliverti 

> You can always take a look at the tests in the source code.
>
> 2010/5/5 ashok kumar 
>
>> Hi Team,
>>
>> I need sample java code that on Drools v5.0.. can anyone share the rule
>> XML file format along with the sample code
>> that fires the rules defined in XML? Do i need to save the file with
>> '.xml' extension or it will be XML data in .drl file?
>> Please throw some light on this..
>>
>> Thanks,
>> JFly.
>>
>>
>>
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> 
>
> Esteban Aliverti
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Chained Rules

2010-05-06 Thread miguel machado
there is the 'extends' feature.. i guess that's what you're looking for.

rule "xyz"
...
end

rule "abc" extends "xyz"...
...
end

it's been recently talked about in this forum.
_ miguel


On Tue, May 4, 2010 at 10:46 AM, djb  wrote:

>
> Hi all,
>
> I know there are some basic ways to chain rules together, by setting flags
> in consequences that are checked in the conditions of other rules...
>
> but in a large system based on rule templates, where thousands of rules are
> generated, it is not feasible to chain rules in this manner, especially
> when
> they are chained in a somewhat arbitrary fashion
> (eg. True if Rule 130 AND Rule 200 AND Rule 480 fire)
>
> has anyone had this situation before?  would I need to execute this as a
> post-processing step?  or, is there any design pattern that will allow
> rules
> to be chained, preferably in a manageable way?
>
> regards,
> Daniel
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Chained-Rules-tp775491p775491.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
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] expert: usage of ruleflow-groups

2010-05-06 Thread miguel machado
oh!

I'm so sorry... typos in XML are impossible to detect :(
Again, thank you so much for your help. I'll correct this and will use the
agenda-groups the way you suggested.

_ miguel



On Wed, May 5, 2010 at 10:01 AM, Wolfgang Laun wrote:

> How did you specify the agenda group in the XML? There aren't much
> checks being done in XML handling, so it's easy to slip up. Here's how
> I interpret the XML schema:
>
> 
>  
>   ...
>
> -W
>
>
>
>
> 2010/5/5 miguel machado :
> > Hi,
> > Yeah, i think this might be a bug indeed. I just tried converting to DRL
> > using the "dumper" and the agenda-group item doesn't show up in the
> > generated DRL file. It is possible that that this tag isn't being
> > interpreted for the same reason it isn't being converted into the DRL
> > format. Can someone please confirm this?
> > Anyway, if this doesn't work.. is there any kind of workaround? Maybe
> using
> > ruleflow-group's or any other technique?
> > Thank you.
> > _ miguel
> >
> >
> > On Wed, May 5, 2010 at 9:11 AM, Wolfgang Laun 
> > wrote:
> >>
> >> If you don't have auto-focus, rules from other agenda groups should not
> >> fire.
> >> XML should not matter. A bug might be possible, e.g., due to
> >> misinterpretation
> >> of the rules in XML.
> >> -W
> >>
> >
> >
> > --
> > "To understand what is recursion you must first understand recursion"
> >
> > ___
> > 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
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] expert: usage of ruleflow-groups

2010-05-05 Thread miguel machado
Hi,

Yeah, i think this might be a bug indeed. I just tried converting to DRL
using the "dumper" and the agenda-group item doesn't show up in the
generated DRL file. It is possible that that this tag isn't being
interpreted for the same reason it isn't being converted into the DRL
format. Can someone please confirm this?

Anyway, if this doesn't work.. is there any kind of workaround? Maybe using
ruleflow-group's or any other technique?

Thank you.
_ miguel



On Wed, May 5, 2010 at 9:11 AM, Wolfgang Laun wrote:

>
> If you don't have auto-focus, rules from other agenda groups should not
> fire.
> XML should not matter. A bug might be possible, e.g., due to
> misinterpretation
> of the rules in XML.
> -W
>
>

-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Getting an Error While Executing Rule in Drools 5.0

2010-05-05 Thread miguel machado
@puneet it may be a good ideia memory wise. I'm doing it right now, in order
to compile rules just once.

_ miguel


2010/5/5 Puneet duggal 

> @ Nikhil,
>
> I am not sure weather it a good practice to seralize a package and store it
> , i am new to it and  i am storing the drl  files in db .
> Can we retrive our DRL file after retriving the packge from database.??
>
>
> On 5/4/10, Nikhil S. Kulkarni  wrote:
>
>>  Hi,
>>
>>
>>
>> I have compiled some rules and added it in packages. Then
>> I serialized those packages and stored in database in the form of CLOB data
>>
>> Now  I am able to get Packages back from database and loaded it in
>> RuleBase.
>>
>> But while executing Rule, I am getting the following Exception.
>>
>>
>>
>> java.lang.NullPointerException
>>
>> at
>> org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:91)
>>
>> at
>> org.drools.base.evaluators.EqualityEvaluatorsDefinition$StringEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1962)
>>
>> at
>> org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:92)
>>
>> at
>> org.drools.rule.OrCompositeRestriction.isAllowed(OrCompositeRestriction.java:25)
>>
>> at
>> org.drools.rule.MultiRestrictionFieldConstraint.isAllowed(MultiRestrictionFieldConstraint.java:97)
>>
>> at
>> org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:143)
>>
>> at
>> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:360)
>>
>> at
>> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:344)
>>
>> 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
>> org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:201)
>>
>>
>>
>> The similar kind of issue is already logged by someone.
>>
>>
>>
>> Please inform If anyone has an idea about this.
>>
>> Waiting for Reply.
>>
>>
>>
>> Thanks & Regards,
>>
>> Nikhil S. Kulkarni
>>
>>
>>
>>
>>
>> MASTEK LTD.
>> Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
>> In the US, we're called MAJESCOMASTEK
>>
>>
>> ~~
>>
>> Opinions expressed in this e-mail are those of the individual and not that 
>> of Mastek Limited, unless specifically indicated to that effect. Mastek 
>> Limited does not accept any responsibility or liability for it. This e-mail 
>> and attachments (if any) transmitted with it are confidential and/or 
>> privileged and solely for the use of the intended person or entity to which 
>> it is addressed. Any review, re-transmission, dissemination or other use of 
>> or taking of any action in reliance upon this information by persons or 
>> entities other than the intended recipient is prohibited. This e-mail and 
>> its attachments have been scanned for the presence of computer viruses. It 
>> is the responsibility of the recipient to run the virus check on e-mails and 
>> attachments before opening them. If you have received this e-mail in error, 
>> kindly delete this e-mail from desktop and server.
>>
>> ~~
>>
>> ___
>> 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
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] expert: usage of ruleflow-groups

2010-05-05 Thread miguel machado
Hi again,

Thank you for clearing that up. I didn't think it worked that way because
i've tried it before and it didn't work. Anyway, according to what you're
saying...

* this is the stack as soon as i insert my objects: | MAIN |

* this is the stack as soon as i setFocus on a specific agenda-group: |
FOCUSED_GROUP | MAIN | (from left to right)

* as soon as all activations from FOCUSED_GROUP fire, that agenda-group is
popped out of the stack and the rule engine fires the remaining activations
from MAIN

Is this the way it works? I've tried this before with no success. I get
rules firing from agenda-groups that *are not focused before* (besides MAIN,
of course). Maybe this has something to do with the rules being declared in
XML? Or some kind of bug?

Thank you.
_ miguel




On Wed, May 5, 2010 at 6:40 AM, Wolfgang Laun wrote:

> > @Wolfgang:
> > My problem is that i cannot have the different rule groups stacked. I may
> do
> > as you suggested, but i'll have rules firing from other agenda-groups
> after
> > the first agenda-group activations are all gone (because they go into the
> > stack as well, right?).
>
> No, no, no! Nothing goes on the stack unless you setFocus()!
>
> What i'm looking for is a way to isolate the
> > execution and just fire the rules within a specific set (aka just one
> > group). Does this make any sense?
>
> This is *exactly* what my sketchy statement sequence does, in
> an existing application.
> -W
>
> > Thank you for your support. I appreciate all the help i can get.
> > _ miguel
> >
> >
> >
> > On Tue, May 4, 2010 at 4:46 PM, Wolfgang Laun 
> > wrote:
> >>
> >> I've been using agenda groups without any trouble for a similar problem,
> >> doing
> >>  setFocus( ... );
> >>  insert( ... );... insert( ... );
> >>  fireAllRules();
> >> repeatedly.
> >>
> >> You don't have to be afraid of the focus stack growing indefinitely:You
> >> control
> >> the "push" (setFocus()), and if an agenda group's activations are all
> >> gone, the
> >> group is automatically popped from the stack.
> >>
> >> -W
> >>
> >> 2010/5/4 Miguel Machado :
> >> > Hi there,
> >> > I'm having some trouble implementing the desired workflow of rule
> firing
> >> > in
> >> > an application using drools expert. I've read the thread about the
> >> > difference between ruleflow groups and agenda groups, but it is still
> >> > unclear to me how to achieve what i need.
> >> > What i intend to have is the ability to fire a specific set of rules
> >> > according to the object i'm inserting into the ksession.
> >> > I do not want to use agenda-groups because it stacks all the agenda
> >> > groups
> >> > declared on the rule file (as far as i understand) and therefore it
> may
> >> > fire
> >> > activations i do not want to be fired. Instead, i want to isolate them
> >> > completely. I tried using ruleflow groups for this, but i cannot find
> a
> >> > way
> >> > to activate a specific group programmatically, before calling
> >> > fireAllRules(), the way i can with agenda-groups (setFocus() method).
> >> > That being said, i'm asking for help in trying to use either one of
> >> > ruleflow/agenda groups or even both in order to get things working the
> >> > way i
> >> > described.
> >> > Thanks in advance,
> >> > _ miguel
> >> >
> >> > ___
> >> > 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
> >
> >
> >
> > --
> > "To understand what is recursion you must first understand recursion"
> >
> > ___
> > 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
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] expert: usage of ruleflow-groups

2010-05-04 Thread miguel machado
Exactly! That's precisely why i'm trying to find a workaround. I have no way
to activate a specific set of rules except for stacking up activations using
agenda-groups.

Any other suggestions?
Thank you.



2010/5/4 Mauricio Salatino 

> if you use the new api's  (5.x StatefulKnowledgeSession instead of
> workingMemory) you don't have that methods exposed.
>
> 2010/5/4 vasilievip 
>
>> You could manually activate and deactivate ruleflow groups using
>> workingMemory.getAgenda().[de]activateRuleflowGroup(name).
>> workingMemory.getAgenda().[de]activateRuleflowGroup(name).
>> session.fireAllRules(); 
>> Source
>> --
>> View this message in context: Re: expert: usage of 
>> ruleflow-groups
>> Sent from the Drools - User mailing list 
>> archiveat
>>  Nabble.com.
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> - http://salaboy.wordpress.com
> - http://www.jbug.com.ar
> - Salatino "Salaboy" Mauricio -
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] expert: usage of ruleflow-groups

2010-05-04 Thread miguel machado
Hi,

First of all, thank you both for your answers.

@mauricio:
I'm currently not using drools flow, only expert, so i'm not very familiar
with the approach you suggested. Isn't it possible to achieve this goal just
by using drools expert?

@Wolfgang:
My problem is that i cannot have the different rule groups stacked. I may do
as you suggested, but i'll have rules firing from other agenda-groups after
the first agenda-group activations are all gone (because they go into the
stack as well, right?). What i'm looking for is a way to isolate the
execution and just fire the rules within a specific set (aka just one
group). Does this make any sense?

Thank you for your support. I appreciate all the help i can get.
_ miguel




On Tue, May 4, 2010 at 4:46 PM, Wolfgang Laun wrote:

> I've been using agenda groups without any trouble for a similar problem,
> doing
>  setFocus( ... );
>  insert( ... );... insert( ... );
>  fireAllRules();
> repeatedly.
>
> You don't have to be afraid of the focus stack growing indefinitely:You
> control
> the "push" (setFocus()), and if an agenda group's activations are all gone,
> the
> group is automatically popped from the stack.
>
> -W
>
> 2010/5/4 Miguel Machado :
> > Hi there,
> > I'm having some trouble implementing the desired workflow of rule firing
> in
> > an application using drools expert. I've read the thread about the
> > difference between ruleflow groups and agenda groups, but it is still
> > unclear to me how to achieve what i need.
> > What i intend to have is the ability to fire a specific set of rules
> > according to the object i'm inserting into the ksession.
> > I do not want to use agenda-groups because it stacks all the agenda
> groups
> > declared on the rule file (as far as i understand) and therefore it may
> fire
> > activations i do not want to be fired. Instead, i want to isolate them
> > completely. I tried using ruleflow groups for this, but i cannot find a
> way
> > to activate a specific group programmatically, before calling
> > fireAllRules(), the way i can with agenda-groups (setFocus() method).
> > That being said, i'm asking for help in trying to use either one of
> > ruleflow/agenda groups or even both in order to get things working the
> way i
> > described.
> > Thanks in advance,
> > _ miguel
> >
> > ___
> > 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
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] expert: usage of ruleflow-groups

2010-05-04 Thread Miguel Machado
Hi there,

I'm having some trouble implementing the desired workflow of rule firing in an 
application using drools expert. I've read the thread about the difference 
between ruleflow groups and agenda groups, but it is still unclear to me how to 
achieve what i need.

What i intend to have is the ability to fire a specific set of rules according 
to the object i'm inserting into the ksession. 

I do not want to use agenda-groups because it stacks all the agenda groups 
declared on the rule file (as far as i understand) and therefore it may fire 
activations i do not want to be fired. Instead, i want to isolate them 
completely. I tried using ruleflow groups for this, but i cannot find a way to 
activate a specific group programmatically, before calling fireAllRules(), the 
way i can with agenda-groups (setFocus() method).

That being said, i'm asking for help in trying to use either one of 
ruleflow/agenda groups or even both in order to get things working the way i 
described.

Thanks in advance,
_ miguel

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools expert: memory issues

2010-04-27 Thread miguel machado
Hi again,

So.. i've tried doing precisely that but i am unable to fire the rules
afterwards. I am dividing the XML rule file into smaller valid XML files so
that i can compile them individually and write to disk the compiled result.
I am using the sample code shown in the docs:

// write compiled rules to disk
ObjectOutputStream out = new ObjectOutputStream(new
FileOutputStream(filename + ".temp"));
out.writeObject(kbuilder.getKnowledgePackages());
out.close();

On a later stage, i load all files holding compiled rules, one at a time, so
i can use the knowledge base and create the knowledge session. Here's what
i'm doing for each of the generated compiled files:

in = new ObjectInputStream(new FileInputStream(filename)); // the ones
*.temp
kpkgs = (Collection) in.readObject();
kbase.addKnowledgePackages(kpkgs);
in.close();

This all works apparently well. Drools loads the sum of all rules defined in
each smaller XML file. However, whenever i try to insert a fact into memory,
i get an exception, just like the following:

java.lang.NullPointerException
at org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:91)
at
org.drools.base.evaluators.EqualityEvaluatorsDefinition$StringEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1962)
at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:92)
at
org.drools.rule.OrCompositeRestriction.isAllowed(OrCompositeRestriction.java:25)
at
org.drools.rule.MultiRestrictionFieldConstraint.isAllowed(MultiRestrictionFieldConstraint.java:97)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:143)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:360)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:344)
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
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:216)
at
pt.itsd.probe.ConfigurationSetup.parseAndCompileConfigFiles(ConfigurationSetup.java:316)
at pt.itsd.probe.ConfigurationSetup.main(ConfigurationSetup.java:131)

I have done some testing and I am unable to trace this exception to any
particular rule, or event any XML chunck. If i load the entire XML file it
takes a lot of memory compiling but it works in the end. Also, if i remove
all the  tags, it also works no matter if i load
them to kbase.

Is there something i can do? or maybe another way of doing it? Any help is
much appreciated.

I'm using drools 5.0.0 from main download page.
_ miguel


2010/4/3 Wolfgang Laun 

> It should be possible to increase heap space to overcome this problem. Of
> course, if a program wil start swapping, performance will go way down.
>
> Dividing the rules file is the only way. But even a very simple script of
> Perl or similar should be able to divide your (IIRC) generated rules file.
>
> -W
>
> 2010/4/3 miguel machado 
>
>> hi there,
>>
>> So like i said, by pre-compiling the rules and loading them in the main
>> system i was able to reduce a lot memory usage and i can get better results.
>> However, now i've come across a different problem. I just added a fre more
>> dozens of rules and the java program responsible for compiling the DRL file
>> throws a java heap space error, something like an OutOfMemoryException.
>>
>> I've read somewhere that dividing the DRL into several files and loading
>> e.g. 500 rules at a time might solve it. Is there another approach to this
>> problem?
>>
>> thanks in advance,
>> _ miguel
>>
>>
>>
>> On Thu, Apr 1, 2010 at 6:12 PM, miguel machado wrote:
>>
>>> hi again,
>>>
>>>  2010/4/1 Edson Tirelli 
>>>
>>>
>>>>Hmm, let me complement Wolfgang's comment:
>>>>
>>>> > After you have taken the compiled packages from the KB and checked for
>>>> errors, the KB has done his duty the KB MUST go :-)
>>>>
>>>
>>> I agree! But i don't exactly know how to do so... i mean, i call this
>>> method which creates the KB from a DRL file and then the kbase and returns
>>> the ksession, the KB object declaration scope is just that exact method, and
>>> once it reaches 300MB+ in memory, it just stays there... the KB object is no
>>> longer in use (or is it?) but memory keeps high.
>>>
>>> I've tried setting KB to &quo

Re: [rules-users] Failed to read schema document when trying to transform from XML to DRL

2010-04-19 Thread miguel machado
I'm having this problem as well. I can live with the System.err messages,
but i could use the XSD for configuration validation. Is there a way of
obtaining this "file"?

thanks in advance,
_ miguel


2010/4/13 Chang Liu 

>  Hi there,
>
>
>
> Error message:
>
> (null: 5, 77): schema_reference.4: Failed to read schema document '
> drools.org/drools-5.0.xsd', because 1) could not find the document; 2) the
> document could not be read; 3) the root element of the document is not
> .
>
>
>
> I ran into this issue when experimenting a project that transforming the
> rules back and forth from DRL to XML with utility classes as documented in
> following link:
>
>
>
>
> http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html/ch04.html#d0e5750
>
>
>
> My code:
>
> …
>
> XmlPackageReader xmlReader = new XmlPackageReader(null);
>
> StringReader sr = new StringReader(rulesInXml);
>
> try {
>
> PackageDescr  packageDescr = xmlReader.read(sr);
>
> DrlDumper drlDumper = new DrlDumper();
>
> String drlString = drlDumper.dump(packageDescr);
>
> }
>
> catch (Exception ex) {
>
> System.out.println(ex);
>
> }
>
> …
>
>
>
> where string “rulesInXml” is the result xml string transformed from a valid
> .drl file. It looks like:
>
> 
>
> 
>   xmlns="http://drools.org/drools-5.0";
>
>   xmlns:xs="http://www.w3.org/2001/XMLSchema-instance";
>
>   xs:schemaLocation="http://drools.org/drools-5.0
> drools.org/drools-5.0.xsd">
>
> 
>
>
>
> 
>
> 
>
> 
>
> Message.HELLO
> 
>
> 
>
> 
>
> 
>
> 
>
>
>
>System.out.println( myMessage );
>
> m.setMessage( "Goodbye cruel world" );
>
> m.setStatus( Message.GOODBYE );
>
> update( m );
>
> 
>
> 
>
>
>
> 
>
> 
>
> 
>
> Message.GOODBYE
> 
>
>
>
> 
>
> 
>
> 
>
> 
>
>
>
>System.out.println( myMessage );
>
> 
>
> 
>
> 
>
>
>
> What did I miss here?
>
>
>
> Moreover, the Drools 5.0 API’s for XML support are poorly-documented. For
> example, the constructors of class “XmlPackageReader” has an arg of
> “SemanticModules” type which is not documented. L
>
>
>
> Any help would be highly appreciated!
>
>
>
> Thanks,
>
> Chang
>  --
> CONFIDENTIALITY NOTICE: The information contained in this email is intended
> only for the person or entity to which it is addressed and may contain
> confidential and/or privileged material. If you are not the intended
> recipient, you are hereby notified that any unauthorized review, use,
> dissemination, distribution or copying of this communication is prohibited
> and may be subject to legal restriction or sanction. If you have received
> this email in error, please notify the sender immediately to arrange for
> return or destruction of the information and all copies. If you are the
> intended recipient but do not wish to receive communications through this
> medium, please advise the sender immediately. Thank you
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Number of rules

2010-04-13 Thread miguel machado
i don't think there is a limit to the number of rules you can declare, it's
just a matter of how long you're willing to wait for drools to compile it
and then to interpret when firing them.

_ miguel


2010/4/13 Bertrand Grottier 

>  Hello,
> What is the number of rules that can be integrated in Drools (using Excel
> for example) ?
> I defined a template rules file, "fed" by an Excel file: a few thousand of
> rules already takes a while to "compile"...
> Benoît
>
> --
> Acheter en ligne en toute sécurité ? Internet Explorer 8 vous protège
> gratuitement ! 
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools vs OPSJ

2010-04-09 Thread miguel machado
He means the latest of the latest version, released last week or so. Not the
one you're using, apparently.


2010/4/9 Bertrand Grottier 

>
>
> --
> Date: Thu, 8 Apr 2010 08:56:35 -0700
> From: greg_bar...@yahoo.com
>
> To: rules-users@lists.jboss.org
> Subject: Re: [rules-users] Drools vs OPSJ
>
> >What version of drools did you use?
> Drools 5.0.1.
>
>
>
> >Did you use a version with the "true modify" feature?
> I feel sorry but I do not understand your question.
> I did not make any particular tuning.
>
>
>
>
> --- On *Thu, 4/8/10, Bertrand Grottier * wrote:
>
>
> From: Bertrand Grottier 
> Subject: [rules-users] Drools vs OPSJ
> To: rules-users@lists.jboss.org
> Date: Thursday, April 8, 2010, 2:08 AM
>
> Hello,
>
> At the present time, I am evaluating Drools vs OPSJ.
>
> Before I started, I had a look at the following tests:
> http://blogs.illation.com.au/2009/09/waltz-benchmark-performance-opsj-vs-drools/.
> Based on these tests, I was expecting better performances from OPSJ over
> Drools regarding the rule firing time.
> However, I obtained opposite results on a basic test. It consists in a sort
> of "join clause": I have a few products and many potentiel prices (10^4) in
> the knowledge session. The aim is to "match" the appropriate prices to each
> products.
>
> My question are the followings:
> - Does someone obtained similar results ?
> - Are there situations where Drools outperforms OPSJ ? (apparently yes).
>
> Thank you in advance.
>
> Regards,
>
> Benoît
>
> --
> Commander un cadeau en ligne discrètement? Voir la solution offerte par
> Internet Explorer8 
>
> -Inline Attachment Follows-
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> --
> Acheter en ligne en toute sécurité ? Internet Explorer 8 vous protège
> gratuitement ! 
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Difference ruleflow agenda-group

2010-04-06 Thread miguel machado
Thanks a lot for clearing that up, i was about to ask the exact same
question. I don't think the documentation is 100% accurate on this
particular subject.

_ miguel



2010/4/6 Mauricio Salatino 

> they both work in a different way.
> agenda-groups works like a stack, when you put the focus on one agenda
> group all the activated rules in that group will be fired, when there is no
> more activated rules on that groups, the stack jumps to the next group in
> the stack firing all the rules activated there, until it reaches the MAIN
> group (when you don't specify any agenda-group).
>
> Ruleflow groups isolate completely the activated rules execution. It only
> execute the activated rules in that ruleflowgroup. It doesn't behave as a
> stack.
>
> 2010/4/6 Bertrand Grottier 
>
>>  Hello,
>> Can someone explain me the difference between ruleflow and agenda-group ?
>> I am asking the question because I managed to create a "ruleflow" based on
>> agenda-group.
>> What is the additionnal value of ruleflow ? Just ease of use or is there
>> anything else ?
>> Thank you in advance.
>> Benoît
>>
>> --
>> Commander un cadeau en ligne discrètement? Voir la solution offerte par
>> Internet Explorer8 
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> - http://salaboy.wordpress.com
> - http://www.jbug.com.ar
> - Salatino "Salaboy" Mauricio -
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools expert: memory issues

2010-04-03 Thread miguel machado
hi there,

So like i said, by pre-compiling the rules and loading them in the main
system i was able to reduce a lot memory usage and i can get better results.
However, now i've come across a different problem. I just added a fre more
dozens of rules and the java program responsible for compiling the DRL file
throws a java heap space error, something like an OutOfMemoryException.

I've read somewhere that dividing the DRL into several files and loading
e.g. 500 rules at a time might solve it. Is there another approach to this
problem?

thanks in advance,
_ miguel



On Thu, Apr 1, 2010 at 6:12 PM, miguel machado wrote:

> hi again,
>
> 2010/4/1 Edson Tirelli 
>
>
>>Hmm, let me complement Wolfgang's comment:
>>
>> > After you have taken the compiled packages from the KB and checked for
>> errors, the KB has done his duty the KB MUST go :-)
>>
>
> I agree! But i don't exactly know how to do so... i mean, i call this
> method which creates the KB from a DRL file and then the kbase and returns
> the ksession, the KB object declaration scope is just that exact method, and
> once it reaches 300MB+ in memory, it just stays there... the KB object is no
> longer in use (or is it?) but memory keeps high.
>
> I've tried setting KB to "null" and then invoking the jvm garbage
> collector, but to no avail. I wish there was a simple way i could just
> destroy a particular object sigh
>
>
>>
>>The above emphasis is mine. KnowledgeBuilder is a higher level object
>> designed to encapsulate the parsing+compilation steps of resources. It is
>> **not** designed to be reused and doing so might create inconsistencies. The
>> memory spike you see when using the kbuilder is due to the java compiler...
>
>
> I understand that, and i'll have that if i must, but the thing is it's not
> just a spike, it is prolonged throughout execution, it doesn't reduce
> afterwards.
>
>
>> Drools itself does not do anything fancy in there other than generate some
>> code (quite inexpensive memory wise) and compile it using either JDT or
>> JANINO (both quite expensive memory wise, when compared to the other steps).
>>
>>
>>So, I strongly discourage you keeping the KB around and as mentioned by
>> Wolfgang, doing so might keep unnecessary objects in memory.
>>
>
> Like i said earlier, it's not that i want to keep KB around, i just can't
> remove it.
>
>
>>
>>Also, just to clarify, deserializing a compiled package means the
>> compiler will not be called (obviously, as everything is already compiled)
>> and that is why it should save you memory.
>>
>
> Thanks for clarifying that! I've tested with a separate application to
> build a compiled file and then load it in the main system and it really
> makes a difference! it's gone to <100MB wow! However, this was just a
> proof-of-concept, as i'm not sure how i could apply the same technique to
> the main standalone application. Do i really have to create a separate
> process/application just for building/compiling the rules, to make sure the
> compilation-object-junk doesn't stay in memory along with the rest?
>
> Thanks for all the feedback and input so far.
> _ miguel
>
>
> --
> "To understand what is recursion you must first understand recursion"
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Importing Fact model in Eclipse

2010-04-03 Thread miguel machado
I've done exactly that using project references and keeping the imports on
the rop of the rules. There are plenty of 'import' examples in the docs.

_ miguel


2010/4/2 Shailesh Hedaoo 

>  i have the JAR in classpath.  i also added the java domain project in
> the "project references".
> but when i create a "guided rule", in the when condition of "guidedl rule"
> - it gives me a 'choose fact model' dropdown which is empty.
> i read somewhere that i need to specify all globals or imports. But i wanst
> able to figure that out exactly.
> looking forward to some more help :).
>
>
> --
> Date: Fri, 2 Apr 2010 22:59:18 +0200
> From: ansgar.konerm...@googlemail.com
> To: rules-users@lists.jboss.org
> Subject: Re: [rules-users] Importing Fact model in Eclipse
>
>
> On 02.04.2010 22:48, Shailesh Hedaoo wrote:
>
> Hi
>   I have created a Drools project and trying to create a guided rule in
> Eclipse 3.5 and Drools 5.0.x.
> I have my own domain objects in another java project to be used by Drools
> project.
> I want to use the java domain model as the "fact model" in my Drools
> project.
> How is that done ? Do i have to go thru the web based "guvnor" first ?
> All I m planing to have is a simple java project which has java classes of
> my domain model of POJOs and in my Drools project i want to use them as
> "fact model". How do i do it in eclipse IDE ?
>
>
> Should suffice to add the fact model jar to the classpath of the project
> containing your rules source code. That's how we did it when still working
> with Eclipse (now switched to IDEA).
>
> If you don't want to compile the jar beforehand, on the rules project's
> root folder, right-click "build path" -> "configure build path", select
> "Projects" tab, click "Add", check your fact model project and confirm
> everything.
>
> Kind regards
>
> Ansgar
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] setting conditional operators in Excel RuleSet

2010-04-03 Thread miguel machado
have you read the documentation? I haven't tried declaring rules through XLS
but i remember reading about it in the docs so I'd say it's possible.

_ miguel




On Fri, Apr 2, 2010 at 10:50 AM, Deepak__A wrote:

> t possible to have conditional operators like OR AND specified in the
> excel?
> I also need to support negation (NOT) operator.
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools expert: memory issues

2010-04-01 Thread miguel machado
hi again,

2010/4/1 Edson Tirelli 

>
>Hmm, let me complement Wolfgang's comment:
>
> > After you have taken the compiled packages from the KB and checked for
> errors, the KB has done his duty the KB MUST go :-)
>

I agree! But i don't exactly know how to do so... i mean, i call this method
which creates the KB from a DRL file and then the kbase and returns the
ksession, the KB object declaration scope is just that exact method, and
once it reaches 300MB+ in memory, it just stays there... the KB object is no
longer in use (or is it?) but memory keeps high.

I've tried setting KB to "null" and then invoking the jvm garbage collector,
but to no avail. I wish there was a simple way i could just destroy a
particular object sigh


>
>The above emphasis is mine. KnowledgeBuilder is a higher level object
> designed to encapsulate the parsing+compilation steps of resources. It is
> **not** designed to be reused and doing so might create inconsistencies. The
> memory spike you see when using the kbuilder is due to the java compiler...


I understand that, and i'll have that if i must, but the thing is it's not
just a spike, it is prolonged throughout execution, it doesn't reduce
afterwards.


> Drools itself does not do anything fancy in there other than generate some
> code (quite inexpensive memory wise) and compile it using either JDT or
> JANINO (both quite expensive memory wise, when compared to the other steps).
>
>
>So, I strongly discourage you keeping the KB around and as mentioned by
> Wolfgang, doing so might keep unnecessary objects in memory.
>

Like i said earlier, it's not that i want to keep KB around, i just can't
remove it.


>
>Also, just to clarify, deserializing a compiled package means the
> compiler will not be called (obviously, as everything is already compiled)
> and that is why it should save you memory.
>

Thanks for clarifying that! I've tested with a separate application to build
a compiled file and then load it in the main system and it really makes a
difference! it's gone to <100MB wow! However, this was just a
proof-of-concept, as i'm not sure how i could apply the same technique to
the main standalone application. Do i really have to create a separate
process/application just for building/compiling the rules, to make sure the
compilation-object-junk doesn't stay in memory along with the rest?

Thanks for all the feedback and input so far.
_ miguel


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to do Exception Handling???

2010-04-01 Thread miguel machado
Hi,

I'm not sure this will help you out, but in what comes to the system i'm
currently developing (using drools expert), i've got this method
"runRuleEngine" that collects facts and fire rules on them and i am able to
catch any sort of error within the drools execution by surrounding that with
try {} catch (Exception e) {}.

The important part is that it took me a while to figure that out cuz eclipse
didn't force me handle that, as if the called method didn't have "throws"
(it usually shows a compilation error otherwise, right?).

Just a thought.
_ miguel



On Wed, Mar 31, 2010 at 9:44 PM, nanic23  wrote:

>
> I have a ruleflow that handles exceptions when they are raised by a "Fault"
> node but I am not being able to accomplish the same if an exception is
> thrown by a workItem or an action node instead.
>
> I have a workItem node with a work item handler that throws a
> RuntimeException. My exception handler in the composite node is not
> catching
> this exception.
>
> So, question
> 1) how can I handle runtime exceptions thrown by my workItemHandlers?
> 2) how can I get a hold of the exception to log the stack trace?
>
> Any ideas or tips are very appreciated.
>
> Nick.
> --
> View this message in context:
> http://n3.nabble.com/How-to-do-Exception-Handling-tp689387p689387.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
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools expert: memory issues

2010-04-01 Thread miguel machado
Hi there,

Actually that's a very good suggestion, i hadn't thought about that. Is
there any heap inspector tool you'd recommend?

In what comes to Wolfgang ideas, it makes sense what he said, but the truth
is making the knowledge builder a static variable actually made memory usage
lower (just a bit). I know it strikes as a surprise because one of the good
practices in java is to reduce the variable/object scope as much as possible
:-/ I'll try to investigate this further.

About the kbase serializing, i'll give it another try.

thanks for all support so far guys.
_ miguel



2010/4/1 Jevon Wright 

> Hi Miguel,
>
> I assume that you've used a memory analyzer to find out conclusively that
> the memory usage is by Drools, and not a memory leak?
>
> One way to do this is to limit the virtual memory to a small amount, add
> -XX:+HeapDumpOnOutOfMemoryError to your environment, and then using Memory
> Analyzer to analyse the dump.
>
> Cheers
> Jevon
>
> On Wed, Mar 31, 2010 at 2:44 AM, Miguel Machado wrote:
>
>> hi all,
>>
>> I'm quite new to the drools rule engine and i've been using it for a
>> project where i need to filter events and execute actions accordingly.
>>
>> I'm currently running a DRL file and creating a stateful session from it,
>> and then running 2/3 facts every time. Every X seconds I collect the
>> available facts and call fireAllRules() + dispose(), always within the same
>> session. The DRL file has circa 2160 rules declared (an external program is
>> producing them), and i'm using the "no-loop", "lock-on-active",
>> "activation-group" and "agenda-group" options on almost every one.
>>
>> My main problem is that the software is consuming too much memory when it
>> loads the rules to the knowledge base variable, it reaches +300Mb which is
>> just not affordable in this project. Is there any way i can work around
>> this? I've tried setting some configuration properties but to no avail. What
>> techniques may i try in order to reduce memory load on drools startup? What
>> would be the best approach for dealing with so many rules?
>>
>> Anything would help, thanks in advance,
>>
>> _ miguel
>>
>>
>> ___
>> 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
>
>


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools expert: memory issues

2010-03-31 Thread miguel machado
Hi there,

First of all, thank you for your detailed and quick response. Next...

2010/3/31 Edson Tirelli 

>
> Miguel,
>
> First we need to understand where is this memory spent. Drools
> externalizes the actual rule compilation to a java compiler (JDT or Janino)
> and I would not be surprised if compiling 2100 rules would consume more than
> 300Mb **during compilation**. I don't think that after compiling, the
> application will continue to use that amount of memory just because of
> rules, although if you have many facts being inserted into your session, it
> obviously will drive consumption up.
>

I usually load into memory 2~4 facts each time, very small objects. I then
"fire all rules" and immediately retract and dispose.


>
> So, some questions:
>
> 1. Do you use one KnowledgeBuilder to compile all your rule files or do you
> use one KnowledgeBuilder per file?
>

Just one, declared as a static variable.


> 2. How much memory is your application using during this step, where you
> add resources to your knowledgeBuilder(s)?
>

Its taking about ±20 MB just before it reads the DRL file, it then takes
5~10s for loading rules into memory and immediately after that line its
taking +300MB.. kinda stabilizes afterwards.


> 3. After compiling your knowledge packages, did you tried to force a GC to
> check how much memory it continues to use?
>

Just tested that, it barely makes a difference :-/ (less than 5MB saved)


> 4. Are you adding all rules to the same KnowledgeBase or using one kbase
> per set of rules? How much memory are you consuming in this step?
>

Most of the time, i've been testing with only one rule file with +2100 rules
and for that i create a single knowledge base, from which i create the
ksession. However, the whole system i'm developing has another component of
event analysis so eventually i'll be testing two separate threads doing
similar things but on different DRL files. I suppose i'll be using two
kbase's, one for each file...

This is the step where memory usage increases dramatically:



kbuilder.add( ResourceFactory.newFileSystemResource( fileName ),
ResourceType.DRL );



5. Did you tried compiling it once, generating the kbase and serializing it
> to a file, and then, instead of recompiling everything, just deserialize the
> file into memory and using it? How much memory it consumes when you
> deserialize from a file?
>

Not sure what you mean there, is it this:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e1070
?
if so, yes, i've tried it and noticed no difference at all, was i supposed
to?


>
>Knowing the answer to the above questions will help to determine if you
> have a problem and how to work around it or fix it.
>

thanks for your help so far. Any help is very much appreciated.

_ miguel


-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools expert: memory issues

2010-03-31 Thread miguel machado
Hi all,

Thanks for your tips. Indeed I had some redundancy in my rule definitions,
now i've removed them and it has reduced memory usage a little bit. Any
other suggestions are welcome :)

thanks again.
_ miguel



2010/3/31 Wolfgang Laun 

> I can only offer a few hints:
>
> Factor out all code that can be done in one of the called methods, e.g., in
>   resetSource( ..., Arrays.asList($value1));
> Here, the Arrays.asList() should be done in resetSource().
>
> Avoid multiple bindings. If you call
>   resetSource( $source,)
> or
>   checkMayReset( $source,...)
> the additional parameters $object and $CI can be retrieved within
> resetSource().
>
> The funny String literals are the one thing that are strikingly different
> from what you usually see in rules. String literals cost for each occurrence
> unless you intern strings using javal.lang.String.intern(). (I haven't tried
> whether Drools would accept that instead.) But calculating the raw cost as
> (46 chars*2 bytes/char+20 bytes)*10 times * 700 rule triples  only accounts
> for 0.8MB, so this alone isn't the culprit.
>
> -W
>
>
> 2010/3/31 Miguel Machado 
>
> Hi, thanks for answering so quickly.
>>
>> My ±2100 rules are grouped in 700 groups of 3 drools rules each, which are
>> related to the same type of event i want to generate, like the following:
>>
>>
>> rule "event1 reset" no-loop salience 9 activation-group "event1_group"
>> lock-on-active agenda-group "a3ce4a97-13d8-4bec-a9ab-5625fcd0f105"
>>  when
>> $source : SourceBO(
>> ciUUID == "3938adc4-246d-43f3-b606-da4c3f09d49b",
>>  $object : object,
>> $CI : ciUUID,
>> $sourceUUID : sourceUUID)
>>  $value1 : SourceValueBO ( valueName == "VALUE1", numericValue < 90 )
>> eval (checkMayReset($source, "fb95632f-fac9-4359-9d7c-dc38d3e48e20", $CI,
>> $object))
>>  then
>> modify ($value1) { setConditionValue(90) };
>> resetSource($source, "fb95632f-fac9-4359-9d7c-dc38d3e48e20", $CI, $object,
>> "event_version", "event_text", Arrays.asList($value1));
>> end
>>
>> rule "event1 fire" no-loop salience 6 activation-group
>> "event1_group" lock-on-active agenda-group
>> "a3ce4a97-13d8-4bec-a9ab-5625fcd0f105"
>>  when
>> $source : SourceBO(
>> ciUUID == "3938adc4-246d-43f3-b606-da4c3f09d49b",
>>  $object : object,
>> $CI : ciUUID,
>> $sourceUUID : sourceUUID )
>>  $value1: SourceValueBO ( valueName == "VALUE1", numericValue > 90 )
>> then
>>  modify ($value1) { setConditionValue(90) };
>> FireCondition $start = new FireCondition("repeat", 0, "duration", "0s");
>>  addToActivationQueue($source, "fb95632f-fac9-4359-9d7c-dc38d3e48e20",
>> $CI, $object, $start, null, "event_version", "event_text",
>> Arrays.asList($value1));
>>  retract($source);
>> end
>>
>> rule "event1 clear" no-loop salience 5 activation-group "event1_group"
>> lock-on-active agenda-group "a3ce4a97-13d8-4bec-a9ab-5625fcd0f105"
>>  when
>> $source : SourceBO(
>> ciUUID == "3938adc4-246d-43f3-b606-da4c3f09d49b",
>>  $object : object,
>> $CI : ciUUID,
>> $sourceUUID : sourceUUID)
>>  then
>> clearActivationQueue($source, "fb95632f-fac9-4359-9d7c-dc38d3e48e20", $CI,
>> $object);
>> end
>>
>> So, i'l try to explain briefly:
>> * The reset rule evaluates 2 patterns and one condition in a static method
>> available via "import function". As a consequence, it modifies the
>> SourceValueBO object and call's the reset function which is another static
>> method.
>> * The fire rule is very similar to the reset rule, the difference being
>> that the value threshold is different (usually the opposite)
>> * The clear rule is like an "else" to the two above. I want it to fire in
>> case it didn't fall for either one of reset and fire rules.
>>
>> The activation group assures that only one of these rules is fired each
>> time i call session.fireAllRules(). And the agenda-group allows me to stack
>> some rules above others, according to the type of facts i insert into
>> memory.
>> Everything seems in place and it works as intended, the thing is i might
>> be dealing with *lots* of events (event1, event2, etc...) and lots of
>> different UUID's which results in a very large DRL file. For instance, if i
>> have 700 events (event1, event ...even

Re: [rules-users] StatefulKnowledgeSessions

2010-03-31 Thread miguel machado
As far as i've read in the documentation, creating
statefulKnowledgeSession's is cheap, even though reading the rulebase is
not. And you can even persist your sessions in database, so i'd say that's
not too much to worry about

But i'm a newbie, more experienced users may disagree.
_ miguel



On Wed, Mar 31, 2010 at 1:59 PM, alim  wrote:

>
> Hi everyone,
>
> I'm trying to find a solution to the following situation:
>
> - KnowledgeBase with approx. 1000 rules
> - Approx. 200 users (hence 200 simultaneous sessions) whereas each session
> might most likely have different values for the working memory facts
>
> So let's say we create a KnowledgeBase (with those 1000 rules) and out of
> this one KnowledgeBase we create for each existing session its own
> StatefulKnowledgeSession.
> Now, how expensive (memory-wise) are these StatefulKnowledgeSessions? Is it
> reasonable to have more than just a few StatefulKnowledgeSessions?
> Or is there an other, better approach?
>
> Thank you very much!
> --
> View this message in context:
> http://n3.nabble.com/StatefulKnowledgeSessions-tp688305p688305.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
>



-- 
"To understand what is recursion you must first understand recursion"
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools expert: memory issues

2010-03-31 Thread Miguel Machado
Hi, thanks for answering so quickly.

My ±2100 rules are grouped in 700 groups of 3 drools rules each, which are 
related to the same type of event i want to generate, like the following:


rule "event1 reset" no-loop salience 9 activation-group "event1_group" 
lock-on-active agenda-group "a3ce4a97-13d8-4bec-a9ab-5625fcd0f105"
when
$source : SourceBO( 
ciUUID == "3938adc4-246d-43f3-b606-da4c3f09d49b",
$object : object, 
$CI : ciUUID, 
$sourceUUID : sourceUUID)
$value1 : SourceValueBO ( valueName == "VALUE1", numericValue < 
90 )
eval (checkMayReset($source, 
"fb95632f-fac9-4359-9d7c-dc38d3e48e20", $CI, $object))
then
modify ($value1) { setConditionValue(90) };
resetSource($source, "fb95632f-fac9-4359-9d7c-dc38d3e48e20", 
$CI, $object, "event_version", "event_text", Arrays.asList($value1));
end

rule "event1 fire" no-loop salience 6 activation-group "event1_group" 
lock-on-active agenda-group "a3ce4a97-13d8-4bec-a9ab-5625fcd0f105"
when
$source : SourceBO( 
ciUUID == "3938adc4-246d-43f3-b606-da4c3f09d49b",
$object : object, 
$CI : ciUUID, 
$sourceUUID : sourceUUID )
$value1: SourceValueBO ( valueName == "VALUE1", numericValue > 
90 )
then
modify ($value1) { setConditionValue(90) };
FireCondition $start = new FireCondition("repeat", 0, 
"duration", "0s");
addToActivationQueue($source, 
"fb95632f-fac9-4359-9d7c-dc38d3e48e20", $CI, $object, $start, null, 
"event_version", "event_text", Arrays.asList($value1));
retract($source);
end

rule "event1 clear" no-loop salience 5 activation-group "event1_group" 
lock-on-active agenda-group "a3ce4a97-13d8-4bec-a9ab-5625fcd0f105"
when
$source : SourceBO(
ciUUID == "3938adc4-246d-43f3-b606-da4c3f09d49b",
$object : object, 
$CI : ciUUID, 
$sourceUUID : sourceUUID) 
then
clearActivationQueue($source, 
"fb95632f-fac9-4359-9d7c-dc38d3e48e20", $CI, $object);
end

So, i'l try to explain briefly:
* The reset rule evaluates 2 patterns and one condition in a static method 
available via "import function". As a consequence, it modifies the 
SourceValueBO object and call's the reset function which is another static 
method.
* The fire rule is very similar to the reset rule, the difference being that 
the value threshold is different (usually the opposite)
* The clear rule is like an "else" to the two above. I want it to fire in case 
it didn't fall for either one of reset and fire rules.

The activation group assures that only one of these rules is fired each time i 
call session.fireAllRules(). And the agenda-group allows me to stack some rules 
above others, according to the type of facts i insert into memory.
Everything seems in place and it works as intended, the thing is i might be 
dealing with *lots* of events (event1, event2, etc...) and lots of different 
UUID's which results in a very large DRL file. For instance, if i have 700 
events (event1, event ...event700), i get 2100 drools rules (event1 reset, 
event1 fire, event1 clear ... event700 reset, event700 fire, event700 clear) 
and over 300MB in consumed memory.

Perhaps if i took another approach? or some performance tunning, i don't know. 
Where can i improve this memory hogging?
_ miguel




On 31 Mar 2010, at 06:53, Wolfgang Laun wrote:

> The figures (+300MB) you quote are frightening, and it would be *very*
> interesting to learn what sort of rules causes this excessive amount
> of heap usage. Could you post typical patterns - if they are
> generated, there ought to be - and guestimates w.r,t, their relative
> frequencies?
> 
> -W
> 
> 
> On 3/30/10, miguel machado  wrote:
>> hi again,
>> 
>> On 30 Mar 2010, at 18:32, Edson Tirelli  wrote:
>> 
>>   I am not sure I understand what you are doing when you say:
>> 
>>> Every X seconds I collect the available facts and call fireAllRules() +
>> dispose(), **always within the same session**.
>> (emphasis is mine)
>> 
>> i meant that i keep using the same object, i just create one stateful
>> session throughout the program execution.
>> 
>>   Compilation indeed uses more memory, but you can compile once and reuse
>> the k

Re: [rules-users] drools expert: memory issues

2010-03-30 Thread miguel machado
hi again,

On 30 Mar 2010, at 18:32, Edson Tirelli  wrote:

   I am not sure I understand what you are doing when you say:

> Every X seconds I collect the available facts and call fireAllRules() +
dispose(), **always within the same session**.
(emphasis is mine)

i meant that i keep using the same object, i just create one stateful
session throughout the program execution.

   Compilation indeed uses more memory, but you can compile once and reuse
the kbase.


exactly, i'm doing that, but it's a +700 rule file and its taking too much
memory. Is there anything i can do to push it down a little bit? i wouldn't
mind slowing it down to reduce memory footprint.

Also, if you are calling dispose, I guess you are running stateful sessions.
Maybe you can give us a more detailed description of your
session/data/application lifecycle?

Sure, i'll try. So i have this thread which initializes by reading the rule
base from a drl file. It then creates a stateful session from it and enters
a lifecycle in which it goes to sleep and only when some other thread wakes
it up, it collects and inserts some facts (usually 2,3 or 4..) into the
session and fire all rules. It's basically this. What i'm very concerned
about is the amount of RAM memory the whole program is consuming. I must
find a way to reduce some of it, because the rule file is being prepared by
an external program and i have no control over the number of rules i might
get. If i test it with a little over 700 rules, it reaches +300Mb which is a
lot.

Maybe the rules are too complex? Shall i try to make them simpler (how)?
what are the big memory hogs when it comes to loading a DRL file to the
knowledge base? From what i've been testing, it doesn't even matter which
rules you will actually need, it just loads the entire DRL file with no
respect to the future activations, am i right? Is there any other aspect i
should take in mind or maybe other approach?

_ miguel
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] drools expert: memory issues

2010-03-30 Thread Miguel Machado
hi all,

I'm quite new to the drools rule engine and i've been using it for a project 
where i need to filter events and execute actions accordingly.

I'm currently running a DRL file and creating a stateful session from it, and 
then running 2/3 facts every time. Every X seconds I collect the available 
facts and call fireAllRules() + dispose(), always within the same session. The 
DRL file has circa 2160 rules declared (an external program is producing them), 
and i'm using the "no-loop", "lock-on-active", "activation-group" and 
"agenda-group" options on almost every one.

My main problem is that the software is consuming too much memory when it loads 
the rules to the knowledge base variable, it reaches +300Mb which is just not 
affordable in this project. Is there any way i can work around this? I've tried 
setting some configuration properties but to no avail. What techniques may i 
try in order to reduce memory load on drools startup? What would be the best 
approach for dealing with so many rules?

Anything would help, thanks in advance,

_ miguel


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users