RE: [rules-users] followup - 'or' for different field constraints

2007-03-27 Thread Olenin, Vladimir (MOH)
Yet on the other hand, if/when it would be possible to use column binding in
field constraints, this functionality will be possible to achieve like this,
ie, rewrite this piece:

 

Record (fieldAsString matches "[xyz]" or fieldAsInt > 1, $myOtherField :
myOtherField)

Record ($field : field, fieldAsString matches "[xyz]" or fieldAsInt > 1,
myOtherField == $myOtherField)

Record (field == $field)

 

 

as

 

$r: (

$r1: (

Record (fieldAsString matches "[xyz]") or

Record (fieldAsInt > 1)

)

$r2: (

Record (fieldAsString matches "[xyz]", myOtherField ==
$r1.myOtherField) or

Record (fieldAsInt > 1, myOtherField == $r1.myOtherField)

)

Record (field == $r2.field)

)

 

More verbose, but I think it should work the same way

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Olenin, Vladimir
(MOH)
Sent: 27 March 2007 11:02
To: Rules Users List
Subject: [rules-users] followup - 'or' for different field constraints

 

... the only thing that would not be allowed is to do the binding on the
this 'connective constraint', since it would make sense. Eg, Record
($invalidBinding : fieldAsString matches "[zxc]" or fieldAsInt > 0) ) ,
since it's kind of 'views' for the 'field' variable, while this one will
work: Record ($correctBidning : field, fieldAsString matches "[zxc]" or
fieldAsInt > 0) ), ie you need to bind the 'original' field, NOT the views.
To think of this, it would actually be need to the AsString,
AsInt, etc getters to be autogenerated Or even better - do that
behind the scene depending on the context, if there is no ambiguity
involved...

 

Vlad

 

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


[rules-users] question - using 'or' to concatenate _different_ field constraint s

2007-03-27 Thread Olenin, Vladimir (MOH)
Hi,

 

I wonder if this is possible in the current 3.1M release (or will be
possible in the 3.2 final) I need to concatenate field constraints with
'or' logic, so smth like:

 

Record (fieldAsString matches "[xyz]" or fieldAsInt > 1, $myOtherField :
myOtherField)

 

The above is just to illustrate an idea (ie, the case above can easily be
written as 'or' concatenation of column constraints). My 'record' object is
far more complex. Moreover, the column concatenation logic can  contain over
4 different columns. Also, I need to use field binding on the matched
columns, eg:

 

Record (fieldAsString matches "[xyz]" or fieldAsInt > 1, $myOtherField :
myOtherField)

Record ($field : field, fieldAsString matches "[xyz]" or fieldAsInt > 1,
myOtherField == $myOtherField)

Record (field == $field)

 

Basically the idea is that I need to define both 'string' and 'number'
constraints on a field. Eg, if 'field' value can be a number "1234567", then
constrains I want to have might be:

-  field (as string) matches "123[0-9]{3}7"

-  field (as int) > 123

 

To do this I have different getters in my fact object linked to the same
field:

 

Class Record {

  String field;

 

  Public String getFieldAsString() {

Return field;

  }

 

  Public int getFieldAsInt() {

Return Integer.parseInt(field);

  }

 

  Public String getField() {

Return field;

  }

}

 

I believe such thing is not possible to do with current implementation. If
not, is it planned for? If not, should it be planned for? It seems like a
very valid use case, since there is a set of applications where business
analysts want to define constraints as a combination of field as a string
pattern AND field as a number (in my particular example - constrains on
account numbers. The pattern is used to define 'account types', while
numeric range is used to define particular organizations with the account
type)

 

Thanks,

 

Vlad

 

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


[rules-users] followup - 'or' for different field constraints

2007-03-27 Thread Olenin, Vladimir (MOH)
... the only thing that would not be allowed is to do the binding on the
this 'connective constraint', since it would make sense. Eg, Record
($invalidBinding : fieldAsString matches "[zxc]" or fieldAsInt > 0) ) ,
since it's kind of 'views' for the 'field' variable, while this one will
work: Record ($correctBidning : field, fieldAsString matches "[zxc]" or
fieldAsInt > 0) ), ie you need to bind the 'original' field, NOT the views.
To think of this, it would actually be need to the AsString,
AsInt, etc getters to be autogenerated Or even better - do that
behind the scene depending on the context, if there is no ambiguity
involved...

 

Vlad

 

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


RE: [rules-users] field binding performance implications

2007-03-22 Thread Olenin, Vladimir (MOH)
I see. The problem though is the logic and 'rule composition' is different
for each group of rules and is NOT data driven (client doesn't want the
logic to be present in the input data). From what I understand generating
descriptors directly would make me define the logic inside the 'parser' or
at the very least somewhere in Java code, unless I opt out for a separate
text format to describe 'just' the logic. But it seems like it'd be more
complicated than generating drl file directly...

Thanks for the suggestion though - I'll think it over again - probably I've
just misinterpreted you...

Vlad
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 21 March 2007 19:17
To: Rules Users List
Subject: Re: [rules-users] field binding performance implications


   Vlad,

   Looking at the macro steps, when you load and run rules in the 
engine, that is what happens:

* PARSING: a parser, will parse whatever syntax you are using into an 
AST tree. The objects that compound that tree are the descriptors I'm 
talking about.
* BUILDING: a rule builder will transform your descriptors (AST Tree) 
into the internal rules representation, doing all the code generation 
and compiling it into binary form.
* RETE-BUILDING: a ReteOO builder will get your compiled rules 
representation and transform into a Rete network, making it ready for 
execution

So, basically, descriptors are the result of the parsing. If you are 
generating rules, better to skip the parsing phase and generate 
descriptors directly. Also, we aim to have full round-trip between 
supported semantics. That means that from the descriptors, you can 
generate DRL, XML, CLP, or whatever syntax you have a dumper for.

Having said all that, you can find the descriptors in the package: 
org.drools.lang.descr in the drools-compiler project. Documentation is 
not good (any volunteers? :)), but they are pretty simple to use, so you 
will have no problems understanding them. Also, if you don't know how to 
represent something using descriptors, it is easy to find out. Just 
write a DRL that does what you want to know how and use the package 
builder to get the descriptors for you to see:

DrlParser parser = new DrlParser();
final PackageDescr pkgDescr = parser.parse( new 
InputStreamReader( getClass().getResourceAsStream( "test_rules.drl" ) ) );

   Hope it helps.

   []s
   Edson


Olenin, Vladimir (MOH) wrote:

>Hmm... Descriptors? What is this?
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
>Sent: 21 March 2007 16:47
>To: Rules Users List
>Subject: Re: [rules-users] field binding performance implications
>
>  Vlad,
>
>Didn't tested myself, but I don't see a reason for performance impacts 
>adding unneeded declarations, except for consuming a bit more of memory, 
>but I would say would be negligible in the numbers you provided.
>Although, may I suggest that you generate Descriptors instead of DRL? 
>This will give you gains in parsing time (as there will not be parsing), 
>besides being easier than using string templates IMO. Also, if you want 
>to store a "text" based version of your rules, you can simply use a 
>dumper to dump wherever syntax you prefer.
>
>[]s
>Edson
>
>
>
>Olenin, Vladimir (MOH) wrote:
>
>  
>
>>Hi,
>>
>>We need to generate drl file from a template. Since the format of the 
>>rules parameters doesn't fall very well within decision table concept 
>>(the parameters are not 'homogeneous', so each row in the input excel 
>>table can mean different things), we decided to define the rules by 
>>automatically generating drl files from a set of templates. To cover 
>>more cases with a single template we'd need to bind every field of 
>>column by default, even if the binding would not be used.
>>
>>For example (Freemarker syntax is used in the template below):
>>
>>Rule ${ruleId}
>>
>>When
>>
>>Record ( $account : account ${operation} ${value} )
>>
>>
>>
>>Then
>>
>>.
>>
>>End
>>
>>In the example above, 'operation', 'value' and 'ruleId' are objects in 
>>the data model that we merge with the template. One case of the rule 
>>would be when both 'operation' and 'value' are empty strings. This 
>>will result in this LHS: Record ( $account : account ). Another case 
>>might be when 'operation' is '==' string and 'value' is '1': Record ( 
>>$account : account == 1 ).
>>
>>The above is a simplified template to demonstrate the

RE: [rules-users] field binding performance implications

2007-03-21 Thread Olenin, Vladimir (MOH)
Hmm... Descriptors? What is this?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 21 March 2007 16:47
To: Rules Users List
Subject: Re: [rules-users] field binding performance implications

  Vlad,

Didn't tested myself, but I don't see a reason for performance impacts 
adding unneeded declarations, except for consuming a bit more of memory, 
but I would say would be negligible in the numbers you provided.
Although, may I suggest that you generate Descriptors instead of DRL? 
This will give you gains in parsing time (as there will not be parsing), 
besides being easier than using string templates IMO. Also, if you want 
to store a "text" based version of your rules, you can simply use a 
dumper to dump wherever syntax you prefer.

[]s
Edson



Olenin, Vladimir (MOH) wrote:

> Hi,
>
> We need to generate drl file from a template. Since the format of the 
> rules parameters doesn't fall very well within decision table concept 
> (the parameters are not 'homogeneous', so each row in the input excel 
> table can mean different things), we decided to define the rules by 
> automatically generating drl files from a set of templates. To cover 
> more cases with a single template we'd need to bind every field of 
> column by default, even if the binding would not be used.
>
> For example (Freemarker syntax is used in the template below):
>
> Rule ${ruleId}
>
> When
>
> Record ( $account : account ${operation} ${value} )
>
> 
>
> Then
>
> .
>
> End
>
> In the example above, 'operation', 'value' and 'ruleId' are objects in 
> the data model that we merge with the template. One case of the rule 
> would be when both 'operation' and 'value' are empty strings. This 
> will result in this LHS: Record ( $account : account ). Another case 
> might be when 'operation' is '==' string and 'value' is '1': Record ( 
> $account : account == 1 ).
>
> The above is a simplified template to demonstrate the point. The real 
> business data model for facts (Record object) would have around 10 
> fields and we can have ~ 5 to 10 columns per rule. I wonder what kind 
> of performance implications does field binding bring? Are there any or 
> this is being optimized / filtered out by some preprocessor?
>
> In other words, is there significant difference in performance for the 
> following LHS expressions:
>
> 1) Record ( $account : account, $name : name == 'xxx', $balance : 
> balance > 100, )
>
> Vs
>
> 2) Record (name == 'xxx', balance > 100, )
>
> Providing the functionality of both of these LHS expressions is the 
> same and field bindings in LHS #1 are never used throughout the rule.
>
> Thanks,
>
> Vlad
>
>
>
>___
>rules-users mailing list
>rules-users@lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


[rules-users] field binding performance implications

2007-03-21 Thread Olenin, Vladimir (MOH)
Hi,

 

We need to generate drl file from a template. Since the format of the rules
parameters doesn't fall very well within decision table concept (the
parameters are not 'homogeneous', so each row in the input excel table can
mean different things), we decided to define the rules by automatically
generating drl files from a set of templates. To cover more cases with a
single template we'd need to bind every field of column by default, even if
the binding would not be used.

 

For example (Freemarker syntax is used in the template below):

 

Rule ${ruleId}

When

Record ( $account : account ${operation}${value}
)



Then

.

End

 

In the example above, 'operation', 'value' and 'ruleId' are objects in the
data model that we merge with the template. One case of the rule would be
when both 'operation' and 'value' are empty strings. This will result in
this LHS:   Record ( $account : account ). Another case might be when
'operation' is '==' string and 'value' is '1':   Record ( $account : account
== 1 ).

 

The above is a simplified template to demonstrate the point. The real
business data model for facts (Record object) would have around 10 fields
and we can have ~ 5 to 10 columns per rule. I wonder what kind of
performance implications does field binding bring? Are there any or this is
being optimized / filtered out by some preprocessor?

 

In other words, is there significant difference in performance for the
following LHS expressions:

 

1) Record ( $account : account,  $name : name == 'xxx',   $balance : balance
> 100, )

Vs

2) Record (name == 'xxx',  balance > 100, )

 

Providing the functionality of both of these LHS expressions is the same and
field bindings in LHS #1 are never used throughout the rule.

 

Thanks,

 

Vlad

 

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


[rules-users] can't refer to the bound column fields from the LHS?..

2007-03-13 Thread Olenin, Vladimir (MOH)
Hi,

 

I always assumed that one can refer to the properties of the bound column in
the LHS like this:

 

MyRecord {

String field1, field2;

}

 

MyRecord2 {

String field1, field3;

}

 

Rule xxx

When

$r1: MyRecord (field1 == "xxx")

$r2: MyRecord2 (field1 == $r1.field1)

Then

System.out.println("found match: "+$r2+", "+$r1);

End

 

Compiler does complain on '$r1' usage in the LHS (as part of constraint for
MyRecord2 fact), but works OK if used only in RHS. The error I'm getting is:
"Unable to find class $r1". "$r1.getField1()" doesn't work either (getting
"mismatched token, expecting ')' " error).

 

Thanks,

 

Vlad

 

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


RE: [rules-users] $drools variable not available under 3.1M?

2007-03-12 Thread Olenin, Vladimir (MOH)
Hmmm... Yes. This one works. Thanks.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 12 March 2007 16:36
To: Rules Users List
Subject: Re: [rules-users] $drools variable not available under 3.1M?

  I believe it is "drools", without the "$"...

Olenin, Vladimir (MOH) wrote:

> Hi,
>
> I was trying to access '$drools' variable from the RHS of the rule, 
> but keep on getting compilation errors: $drools can't be resolved. The 
> docs for 3.0.5 mention that 'drools' variable is made available to the 
> user from the RHS of the rule... I wonder if it's a bug or I'm doing 
> smth wrong? Here is an excerpt from the rule:
>
> Rule "xxx"
>
> When
>
> 
>
> *then*
>
> System.out.println($drools);
>
> *end*
>
> For other purposed I have these list of imports in the header:
>
> *import* org.drools.spi.KnowledgeHelper;
>
> *import* org.drools.base.DefaultKnowledgeHelper;
>
> *import* org.drools.spi.Tuple;
>
> *import* org.drools.*rule*.Rule;
>
> Thanks,
>
> Vlad
>
>
>
>___
>rules-users mailing list
>rules-users@lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


[rules-users] $drools variable not available under 3.1M?

2007-03-12 Thread Olenin, Vladimir (MOH)
Hi,

 

I was trying to access '$drools' variable from the RHS of the rule, but keep
on getting compilation errors: $drools can't be resolved. The docs for 3.0.5
mention that 'drools' variable is made available to the user from the RHS of
the rule... I wonder if it's a bug or I'm doing smth wrong? Here is an
excerpt from the rule:

 

Rule "xxx"

When 



then

System.out.println($drools);

end

 

For other purposed I have these list of imports in the header:

 

import org.drools.spi.KnowledgeHelper;

import org.drools.base.DefaultKnowledgeHelper;

import org.drools.spi.Tuple;

import org.drools.rule.Rule;

 

 

Thanks,

 

Vlad

 

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


RE: [rules-users] Rete diagram legend - what do all the colors me an?...

2007-03-12 Thread Olenin, Vladimir (MOH)
Is 'matches' operator optimized?

 

Vlad 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor
Sent: 12 March 2007 14:53
To: Rules Users List
Subject: Re: [rules-users] Rete diagram legend - what do all the colors me
an?...

 

not really, all I can say is try and work with flat models and '=='
operators for performance - we currently don't optimise != or number ranges.
Avoid eval, predicate and return value unless you really need them. Keep
your consequences short and avoid flow logic in them, i.e. 'if'/'switch '
statements.

Mark
Olenin, Vladimir (MOH) wrote: 

Ok, found the descriptions - for anyone interested, you need to switch into
'JBoss Rules' prospective and open 'Properties' tab. This way whenever you
select a node, information about the node would be displayed there
(Properties tab won't get activated automatically).

 

Mark, any general hints on correlations between diagram 'look' & performance
implications? (eg, "the more 'alpha' nodes, the worse/the better is
performance", "the more connections to the node, the  is performance",
etc)

 

Thanks

 

  _  

From: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
[mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ] On Behalf Of Mark Proctor
Sent: 09 March 2007 18:18
To: Rules Users List
Subject: Re: [rules-users] Rete diagram legend - what do all the colors
mean?...

 

yes if you understand the rete diagram you can can help it with
understanding performance. If you click on a node it tells you the type.
Which are roughly
root, object type node, alpha node, join node, not node, exists node, eval
node and terminal node. Can't remenber which has which colour, but you
should be able to figure it out, we discuss the node types briefly in the
manual.

Mark
Olenin, Vladimir (MOH) wrote: 

Hi,

 

I was trying to make some sense out of Rete Diagram for my rules (DROOLS
3.1M), and one of the questions I have is what all these colors mean? There
are red, blue, yellow, green, orange, white, cyan and black circles I
might be wrong, but I think this should mean something!

 

Also, I noticed that by default the diagram is displayed in 'layers' of
dots. In my case I have 7 layers, the top one being the 'root' I assume
(single white circle). The 'widest' layer is the middle one - the forth
layer. So, generally the diagram has a diamond shape. I wonder if one can
use this kind of visual information to make a rough estimation/assumption on
how efficient his rules/constraints are, some hints into optimization,
etc

 

 

Thanks,

 

Vlad 

 

 
 
 





  _  



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

 

 





  _  



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

 

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


RE: [rules-users] Rete diagram legend - what do all the colors me an?...

2007-03-12 Thread Olenin, Vladimir (MOH)
Ok, found the descriptions - for anyone interested, you need to switch into
'JBoss Rules' prospective and open 'Properties' tab. This way whenever you
select a node, information about the node would be displayed there
(Properties tab won't get activated automatically).

 

Mark, any general hints on correlations between diagram 'look' & performance
implications? (eg, "the more 'alpha' nodes, the worse/the better is
performance", "the more connections to the node, the  is performance",
etc)

 

Thanks

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor
Sent: 09 March 2007 18:18
To: Rules Users List
Subject: Re: [rules-users] Rete diagram legend - what do all the colors
mean?...

 

yes if you understand the rete diagram you can can help it with
understanding performance. If you click on a node it tells you the type.
Which are roughly
root, object type node, alpha node, join node, not node, exists node, eval
node and terminal node. Can't remenber which has which colour, but you
should be able to figure it out, we discuss the node types briefly in the
manual.

Mark
Olenin, Vladimir (MOH) wrote: 

Hi,

 

I was trying to make some sense out of Rete Diagram for my rules (DROOLS
3.1M), and one of the questions I have is what all these colors mean? There
are red, blue, yellow, green, orange, white, cyan and black circles I
might be wrong, but I think this should mean something!

 

Also, I noticed that by default the diagram is displayed in 'layers' of
dots. In my case I have 7 layers, the top one being the 'root' I assume
(single white circle). The 'widest' layer is the middle one - the forth
layer. So, generally the diagram has a diamond shape. I wonder if one can
use this kind of visual information to make a rough estimation/assumption on
how efficient his rules/constraints are, some hints into optimization,
etc

 

 

Thanks,

 

Vlad 

 

 





  _  



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

 

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


[rules-users] bug in 3.1M?

2007-03-09 Thread Olenin, Vladimir (MOH)
Hi,

 

I've run across one thing. If I evaluate two columns within 'exists'
statement it throws compilation error if I don't connect two columns with
'and':

 

Exists (

Column (...)

Column (...)

)

 

With 'and' everything compiles OK:

 

Exists (

Column (...) and

Column (...)

)

 

Which is correct? Or probably both are not correct? From the 3.1M release
notes I can suggest there is another syntax (which works as well):

 

Exists (

Column (...) and

Exists Column (...)

)

 

I thought #1 should work OK I'm not sure what #2 might mean for DROOLS.
>From the rules & data I'm processing and results I'm getting it seems like
it works as #1 should, ie, checking existence of the tuple represented by
the columns within the 'exists' block

 

Thanks,

 

Vlad

 

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


[rules-users] Rete diagram legend - what do all the colors mean?...

2007-03-09 Thread Olenin, Vladimir (MOH)
Hi,

 

I was trying to make some sense out of Rete Diagram for my rules (DROOLS
3.1M), and one of the questions I have is what all these colors mean? There
are red, blue, yellow, green, orange, white, cyan and black circles I
might be wrong, but I think this should mean something!

 

Also, I noticed that by default the diagram is displayed in 'layers' of
dots. In my case I have 7 layers, the top one being the 'root' I assume
(single white circle). The 'widest' layer is the middle one - the forth
layer. So, generally the diagram has a diamond shape. I wonder if one can
use this kind of visual information to make a rough estimation/assumption on
how efficient his rules/constraints are, some hints into optimization,
etc

 

 

Thanks,

 

Vlad 

 

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


RE: [rules-users] 'from accumulate' doesn't work on multiple colu mns?..

2007-03-08 Thread Olenin, Vladimir (MOH)
> Edson wrote:
-
3. Regarding the distinct, I'm not sure if it would be good to have such 
"feature". Need further discussion I guess. But on of the ways to work 
around that is just to have a "driver" fact. I mean, if "f1" means a 
financial account, for instance, have a Financial Account fact:
-- End of quote

Yes, that's how I'm dealing with it right now... But you (or Mark?)
mentioned some time ago regarding similar issue ("Convert logic to DRL
rules") that it's better to aviod this kind of 'indexing' and keep the data
model 'flattened' since it'd allow for more optimizations on DROOLS side. In
my case 'Record' fact has 6-7 fields and the type of rules I have would
require to have such index on almost all these fields (which means I'd have
to assert 'unique value' facts for each of the fields). So, I thought this
kind of problem (as well as combination of unique fields) can be solved
easily with having such keyword ('distinct' or 'unique' or smth like that).
I think that even implementation should not be very difficult, since it
would just require to get all facts of particular type and assert a new set
of 'unique value' facts for each of the fields used in the constraint...
Kind of preprocessing step. But I think such index (index of all fields
within particular fact type) might already being created as part of other
algorithms?...

Vlad




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 07 March 2007 17:43
To: Rules Users List
Subject: Re: [rules-users] 'from accumulate' doesn't work on multiple
columns?..

  Vlad,

Trying to answer both of your e-mails in this one.

1. Right now, accumulate supports only a single Pattern (column), as you 
already realized. That is a limitation we want to remove before the next 
final release, but it is not done yet. I already know how to fix that, 
but didn't had the time to do it yet. We are working hard in the BRMS 
side now. If anyone is willing to help with that, I can provide the 
instructions on how to do the implementation for that feature.

2. Regarding matching the same fact multiple times in a single tuple, 
this is a configuration. In 3.0.x, the default is to not allow the same 
fact to be matched multiple times in a single tuple. In 3.1, the default 
was changed to allow multiple matches. That is why your tested matched 
multiple times. This is one of the BIG warnings we need to add to the 
upgrade documentation.

3. Regarding the distinct, I'm not sure if it would be good to have such 
"feature". Need further discussion I guess. But on of the ways to work 
around that is just to have a "driver" fact. I mean, if "f1" means a 
financial account, for instance, have a Financial Account fact:

rule ...
when
FinancialAccount( $id : id )
Double( doubleValue > 0 ) from accumulate(
Record( finId == $id, $f2 : f2, $val : value )
init( double sum = 0; )
action( sum += ( $f2 < 10 ) ? $val : -$val; )
result( new Double( sum ) ) )
then
// do something
end

Hope it helps.

[]s
Edson

Olenin, Vladimir (MOH) wrote:

> This is as a follow up for the previous question It looks like I 
> made a wrong assumption that 'accumulate' can work on multiple columns:
>
> Integer ( intValue > 0) from accumulate (
>
> Record ( f1 == $f1, f2 < 10, $value1 : value )
>
> Record ( f1 == $f1, f2 >= 10, $value2 : value )
>
> Init ( int sum = 0; ),
>
> Action ( sum += $value1 - $value2 ),
>
> Result ( new Integer (sum) )
>
> )
>
> I'm getting an error ('then' is expected or smth like that at the 
> point where the second 'Record' is defined) and the only way to remove 
> the error is to declare one and only one Column constraint... So, it is 
> not possible then to use multiple columns in 'accumulate'? If not, 
> then it would be even more interesting to get some idea on how to 
> approach the kind of problem I mentioned in the previous post.
>
> Thanks,
>
> Vlad
>
>
>
>___
>rules-users mailing list
>rules-users@lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


RE: [rules-users] 'from accumulate' doesn't work on multiple colu mns?..

2007-03-08 Thread Olenin, Vladimir (MOH)
Thanks, Edson. That explains it. Regarding your #1 point, I can try to help,
especially if it's smth that won't require digging deeply into DROOLS
implementation details (and would help me to implement the rule I mentioned
in the previous post :) )... How much time do you think it will take
providing I'm not familiar with DROOLS codebase? (DROOLS dev-t environment
setup + this feature implementation)

I'm subscribed to dev-t list (from what I recall), so we can move this
discussion there...

Thanks,

Vlad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 07 March 2007 17:43
To: Rules Users List
Subject: Re: [rules-users] 'from accumulate' doesn't work on multiple
columns?..

  Vlad,

Trying to answer both of your e-mails in this one.

1. Right now, accumulate supports only a single Pattern (column), as you 
already realized. That is a limitation we want to remove before the next 
final release, but it is not done yet. I already know how to fix that, 
but didn't had the time to do it yet. We are working hard in the BRMS 
side now. If anyone is willing to help with that, I can provide the 
instructions on how to do the implementation for that feature.

2. Regarding matching the same fact multiple times in a single tuple, 
this is a configuration. In 3.0.x, the default is to not allow the same 
fact to be matched multiple times in a single tuple. In 3.1, the default 
was changed to allow multiple matches. That is why your tested matched 
multiple times. This is one of the BIG warnings we need to add to the 
upgrade documentation.

3. Regarding the distinct, I'm not sure if it would be good to have such 
"feature". Need further discussion I guess. But on of the ways to work 
around that is just to have a "driver" fact. I mean, if "f1" means a 
financial account, for instance, have a Financial Account fact:

rule ...
when
FinancialAccount( $id : id )
Double( doubleValue > 0 ) from accumulate(
Record( finId == $id, $f2 : f2, $val : value )
init( double sum = 0; )
action( sum += ( $f2 < 10 ) ? $val : -$val; )
result( new Double( sum ) ) )
then
// do something
end

Hope it helps.

[]s
Edson

Olenin, Vladimir (MOH) wrote:

> This is as a follow up for the previous question It looks like I 
> made a wrong assumption that 'accumulate' can work on multiple columns:
>
> Integer ( intValue > 0) from accumulate (
>
> Record ( f1 == $f1, f2 < 10, $value1 : value )
>
> Record ( f1 == $f1, f2 >= 10, $value2 : value )
>
> Init ( int sum = 0; ),
>
> Action ( sum += $value1 - $value2 ),
>
> Result ( new Integer (sum) )
>
> )
>
> I'm getting an error ('then' is expected or smth like that at the 
> point where the second 'Record' is defined) and the only way to remove 
> the error is to declare one and only one Column constraint... So, it is 
> not possible then to use multiple columns in 'accumulate'? If not, 
> then it would be even more interesting to get some idea on how to 
> approach the kind of problem I mentioned in the previous post.
>
> Thanks,
>
> Vlad
>
>
>
>___
>rules-users mailing list
>rules-users@lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


[rules-users] 'from accumulate' doesn't work on multiple columns?..

2007-03-07 Thread Olenin, Vladimir (MOH)
This is as a follow up for the previous question It looks like I made a
wrong assumption that 'accumulate' can work on multiple columns:

 

Integer ( intValue > 0) from accumulate (

Record ( f1 == $f1, f2 < 10, $value1 :
value )

Record ( f1 == $f1, f2 >= 10, $value2 :
value )

Init ( int sum = 0; ),

Action ( sum += $value1 - $value2 ),

Result ( new Integer (sum) )

)

 

I'm getting an error ('then' is expected or smth like that at the point
where the second 'Record' is defined) and the only way to remove the error
is to declare one and only one Column constraint... So, it is not possible
then to use multiple columns in 'accumulate'? If not, then it would be even
more interesting to get some idea on how to approach the kind of problem I
mentioned in the previous post.

 

Thanks,

 

Vlad

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


[rules-users] 'distinct' keyword?.... or an alternative... here is an example

2007-03-07 Thread Olenin, Vladimir (MOH)
Hi,

 

I ran into the situation when I need the functionality similar to 'distinct'
keyword from SQL, ie I have a set of facts:

 

Record (f1 = 1, f2 = 1, value = 4)

Record (f1 = 1, f2 = 2, value = 1)

Record (f1 = 1, f2 = 13, value = 2)

Record (f1 = 1, f2 = 14, value = 5)

Record (f1 = 2, f2 = 5, value = 7)

Record (f1 = 2, f2 = 6, value = 3)

Record (f1 = 2, f2 = 15, value = 8)

Record (f1 = 2, f2 = 16, value = 9)

.. etc

 

And I need to calculate two sums _within the same 'f1' field_ for each
unique 'f1' field and compare them:

-  $sum1: f2 <   10

-  $sum2: f2 >= 10

-  If $sum1 > sum2 then do something

 

One of the ways to do that is to iterate through all unique f1 fields and
calculate two sums. Here is where I thought 'distinct' keyword might have
helped. Otherwise I need to assert another set of 'unique f1 fields' facts
to iterate through:

 

Rule XXX

When

Distinct Record ( $f1 : f1 )

Integer ( intValue > 0) from accumulate (

Record ( f1 == $f1, f2 < 10, $value1 :
value )

Record ( f1 == $f1, f2 >= 10, $value2 :
value )

Init ( int sum = 0; ),

Action ( sum += $value1 - $value2 ),

Result ( new Integer (sum) )

)

Then

System.out.println("HURRAH!");

End

 

I realize that one would not be able to bind any other variable from
'distincted' record other than those in the constraint fields, but this is
not really required. The only other solution for the problem above I
managed to come up with is to accumulate the sums in a helper object, which
has the buckets for each unique f1 value and do the eval after 'accumulate
on testing if any of the buckets is a positive number. In other words, not
to iterate through each unique 'f1', but iterate through all records and put
the sum to the correct bucket: Helper.getBucket($f1).addValues($value1,
value2).

 

The other thing is what Edson mentioned some time ago: DROOLS does not allow
internally for the same fact to be selected twice in a tuple. Surprisingly
one of the recent tests I ran against 3.1M did actually select the same fact
in the tuple (see the post from last Friday, March 02: "confused again -
why it selects all possible combinations"). Not sure if it's a bug or an
extended functionality... but this kind of thing should be helpful in
here

 

Are there any other approaches I missed?... What's the best one in terms of
performance? Thanks,

 

Vlad

 

 

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


[rules-users] column binding vs field binding - any performance implications?

2007-03-07 Thread Olenin, Vladimir (MOH)
Hi,

 

I wonder if there are any performance implications of choosing column
binding vs field binding (I'll be using bound variable in eval). Eg, in such
case:

 

Record($field : field)

eval ( $field.equals("xxx") )

 

vs

 

$r: Record()

eval ( $r.field.equals("xxx") )

 

 

Does it start to make difference only when some significant number of
variable get bound?

 

Thanks,

 

Vlad

 

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


RE: [rules-users] what's wrong with this rule?...

2007-03-06 Thread Olenin, Vladimir (MOH)
Edson,

Thanks for the tip - you are right - 'return' keyword should not be used -
got to this one by trial & error just before I saw your reply :). The
problem is that the only 'public' docs available on the new functionality
(Wiki 3.1 release notes:
http://wiki.jboss.org/wiki/Wiki.jsp?page=3.1M1ReleaseNotes) gives the
example of 'accumulate' keyword where 'return' keyword IS used in the
'result' section! So, I guess this needs to be updated?..

Interestingly, "eval ($count < 4)" DOES work correctly and as expected! So,
I guess that's an extra feature? :)

Thanks for the example on how to avoid eval altogether - already tried it
and it works like a charm! Nice functionality! Would it be worth it to
include this in Wiki?

Thanks,

Vlad
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 06 March 2007 16:19
To: Rules Users List
Subject: Re: [rules-users] what's wrong with this rule?...


Vlad,

You should not use the "return" keyword and the ";" inside the result 
block as it is implicit. Also, remember that anything inside eval() is 
pure java code, so you cant do $count < 4 if $count is an Integer object.
Finally, try to always avoid eval() when writing rules.

Try something like:

*rule* "FG.23C"

*when*

*exists*

Record( $psc : psc == "323",

pa == "7[0-9]*",

sa == "F39040"

|== "F38010"

|== "F38090" )

$count : Integer( intValue < 4 ) *from* *accumulate *(

Record( psc == "323",

pa *matches* "8[0-9]995",

sa *matches* "F390[4-8][2-5]" ),

init ( *int* count = 0; ),

action( count += count; ),

result( *new* Integer(count) )

)

*then*

System.out.println( "rule FC.23C has failed" );

System.out.println();

*end*

**
Please, let me know if it works.

[]s
Edson

Olenin, Vladimir (MOH) wrote:

> Hi,
>
> I have the following rule:
>
> *rule* "FG.23C"
>
> *when*
>
> *exists*
>
> Record( $psc : psc == "323",
>
> pa == "7[0-9]*",
>
> sa == "F39040"
>
> |== "F38010"
>
> |== "F38090" )
>
> $count : Integer() *from* *accumulate *(
>
> Record( psc == "323",
>
> pa *matches* "8[0-9]995",
>
> sa *matches* "F390[4-8][2-5]" ),
>
> init ( *int* count = 0; ),
>
> action( count += count; ),
>
> result( *return* *new* Integer(count); )
>
> )
>
> *eval* ($count < 4 )
>
> *then*
>
> System.out.println( "rule FC.23C has failed" );
>
> System.out.println();
>
> *end*
>
> * *
>
> And for some reason I can't compile correctly: I'm getting the 
> following error:
>
> org.drools.rule.InvalidRulePackage: Rule Compilation error This method 
> must return a result of type Integer Syntax error on token "(", ; 
> expected Syntax error on token ")", delete this token
>
> at org.drools.rule.Package.checkValidity(_Package.java:367_)
>
> at 
> org.drools.common.AbstractRuleBase.addPackage(_AbstractRuleBase.java:244_)
>
> at moh.ohfs.rules.RulesTest.readRule(_RulesTest.java:70_)
>
> at moh.ohfs.rules.RulesTest.main(_RulesTest.java:22_)
>
> All brackets seem to be matching This happens on 3.1M build.
>
> Thanks,
>
> Vlad
>
>
>
>___
>rules-users mailing list
>rules-users@lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


[rules-users] what's wrong with this rule?...

2007-03-06 Thread Olenin, Vladimir (MOH)
Hi,

 

I have the following rule:

 

rule "FG.23C"

  when

exists

  Record( $psc  : psc=="323",

pa =="7[0-9]*",

sa =="F39040"

  |=="F38010"

  |=="F38090" )

$count : Integer() from accumulate (

  Record( psc   ==   "323",

  pamatches  "8[0-9]995",

  samatches  "F390[4-8][2-5]" ),

  init  ( int count = 0; ),

  action( count += count; ),

  result( return new Integer(count); )

)

eval ($count < 4 )

  then

System.out.println( "rule FC.23C has failed" ); 

System.out.println(); 

end

 

And for some reason I can't compile correctly: I'm getting the following
error:

 

org.drools.rule.InvalidRulePackage: Rule Compilation error This method must
return a result of type Integer Syntax error on token "(", ; expected Syntax
error on token ")", delete this token

 

  at org.drools.rule.Package.checkValidity(Package.java:367)

  at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:244)

  at moh.ohfs.rules.RulesTest.readRule(RulesTest.java:70)

  at moh.ohfs.rules.RulesTest.main(RulesTest.java:22)

 

All brackets seem to be matching This happens on 3.1M build.

 

Thanks,

 

Vlad

 

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


[rules-users] confused again.... - why it selects all possible combinations? (D ROOLS 3.1M)

2007-03-02 Thread Olenin, Vladimir (MOH)
Hi,

 

I finally got around to get my hands dirty. And I run into some problem. The
results I'm getting are not the ones I expected to get :-).

 

I have a rule:

 

rule "FC.93"

  when

r1: Record( psc == "101", fundType == "1", $pa1: pa ==
"7111010", sa matches "F1202[0-9]" )

r2: Record( psc == "101", fundType == "1", pa == $pa1, sa
matches "F1202[0-9]" )

  then

System.out.println( "rule FC.93 has been activated" ); 

System.out.println( "r1: " + r1 ); 

System.out.println( "r2: " + r2 );

System.out.println(); 

end

 

 

and the following set of facts:

 

1:new Record("101", "0942", "1", "7111010", "F12020")

2:new Record("101", "0942", "1", "7111010", "F12022")

3:new Record("101", "0942", "1", "7111010", "F12024")

4:new Record("101", "0942", "1", "7111020", "F12020")

5:new Record("101", "0942", "1", "7111020", "F12022")

 

 

With the rule above I expected to get only tuples

 

1,2 1,3 2,3

 

Or the printout:

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12020

r2: pa = 7111010, sa = F12022

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12020

r2: pa = 7111010, sa = F12024

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12022

r2: pa = 7111010, sa = F12024

 

 

 

Ie, get only 3 activations of the rule.

 

For some reason I'm getting all possible combinations (or is it
permutations?...):

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12024

r2: pa = 7111010, sa = F12024

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12022

r2: pa = 7111010, sa = F12024

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12024

r2: pa = 7111010, sa = F12022

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12020

r2: pa = 7111010, sa = F12024

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12024

r2: pa = 7111010, sa = F12020

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12022

r2: pa = 7111010, sa = F12022

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12020

r2: pa = 7111010, sa = F12022

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12022

r2: pa = 7111010, sa = F12020

 

rule FC.93 has been activated

r1: pa = 7111010, sa = F12020

r2: pa = 7111010, sa = F12020

 

 

 

I recall Edson mentioned that DROOLS would not select the same two facts in
the tuple, but that what seems to be happening I think I must be doing
smth wrong. How the rule should be modified to achieve the result I expect?

 

Also, for some reason regex "F1202\\d" doesn't return any matches as well,
while, supposedly the same pattern "F1202[0-9]" does...

 

Thanks. Any hints are very appreciated!

 

 

Vlad

 

PS: I'm using DROOLS 3.1M on JDK 1.5.0_11 under the 3.1M Eclipse plugin.

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


RE: [rules-users] talking about new features...

2007-02-22 Thread Olenin, Vladimir (MOH)
This will just check if MyMapSubClass contains the entry (which I think
would not work anyways, since 'entrySet' does not comply to POJO spec).

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Anstis, Michael
(M.)
Sent: 22 February 2007 12:14
To: Rules Users List
Subject: RE: [rules-users] talking about new features...

 

Can this not be achieved by using a Map's entrySet property?

 

$o : MyMapSubClass( entrySet contains 'myName' );

 


  _  


From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Olenin, Vladimir
(MOH)
Sent: 22 February 2007 16:17
To: Rules Users List
Subject: [rules-users] talking about new features...

Hi,

 

Talking about new features to be included in the new release, I think the
most compelling might be the ability to use Maps as facts (ie, from the
point of view of a complete DROOLS newbie). Technically POJO is a Map with
some restricted functionality (can't count properties, check for property
existence, etc). Is it really a big change? The rule formulation will remain
the same from what I understand and the LHS like

 

Map(name == 'myName')

 

Will simply mean any map object which has a key 'name' and value for the key
is 'myName'. The 'type matching' feature would be kind of less useful in
case Map fact is used, but this can probably solved through introducing some
default 'type' key which Map object should have and in a very simplistic
implementation just include 'type' as a constraint.

 

Another alternative (which might probably be more 'backward compatible' with
existing implementation) is to dynamically generate POJOs from Map
definition. 'type' or 'class' key will correspond to a full qualified class
name, all other keys found in the map - POJOs properties. Or 'type' can stay
'anonymous' - might be useful in some cases as well

 

The 'weakly defined' fact objects might be quite useful in some cases, eg
when rules 'cross cut' business domain. Kind of 'dynamic rules' :-).

 

 

Vlad

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


[rules-users] talking about new features...

2007-02-22 Thread Olenin, Vladimir (MOH)
Hi,

 

Talking about new features to be included in the new release, I think the
most compelling might be the ability to use Maps as facts (ie, from the
point of view of a complete DROOLS newbie). Technically POJO is a Map with
some restricted functionality (can't count properties, check for property
existence, etc). Is it really a big change? The rule formulation will remain
the same from what I understand and the LHS like

 

Map(name == 'myName')

 

Will simply mean any map object which has a key 'name' and value for the key
is 'myName'. The 'type matching' feature would be kind of less useful in
case Map fact is used, but this can probably solved through introducing some
default 'type' key which Map object should have and in a very simplistic
implementation just include 'type' as a constraint.

 

Another alternative (which might probably be more 'backward compatible' with
existing implementation) is to dynamically generate POJOs from Map
definition. 'type' or 'class' key will correspond to a full qualified class
name, all other keys found in the map - POJOs properties. Or 'type' can stay
'anonymous' - might be useful in some cases as well

 

The 'weakly defined' fact objects might be quite useful in some cases, eg
when rules 'cross cut' business domain. Kind of 'dynamic rules' :-).

 

 

Vlad

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


RE: [rules-users] accumulate / collect behaviour question - anoth er stupid question

2007-02-22 Thread Olenin, Vladimir (MOH)
> So, you are right: action will be executed 10 times for each id and eval 
> will be executed 1 time for each id.

Hmm... So, the 'action' part of the _rule_ (NOT of the accumulate statement)
will be called 100 times? How should the rule be modified for the action to
be called only 10 times? (once per each unique transaction id). Basically
the idea is to do smth if all debit operations are not balanced with credit
operations within the same transaction id

Or have I misunderstood





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 21 February 2007 17:19
To: Rules Users List
Subject: Re: [rules-users] accumulate / collect behaviour question - another
stupid question

  Vlad,

Inside an accumulate CE, the action code will be executed once for each 
match of the given pattern (TransactionEntry in this case).
Eval CEs are executed once for each tuple that matches all previous 
patterns.
So, you are right: action will be executed 10 times for each id and eval 
will be executed 1 time for each id.

To understand better how forward rule engines work, there are some books 
and articles listed in JBoss Rules project page. I can personally 
recomend "Expert Systems..." by Gary Riley.

And don't worry about asking. Usually people ask a lot in the begining 
and then when they feel confident, they start to answer more than ask. :)

[]s
Edson

Olenin, Vladimir (MOH) wrote:

> Hi,
>
> Edson quoted the following sample rule some time ago:
>
> rule "transaction consistency"
>
> when
>
> Transaction( $id : id )
>
> $credits: Double( )
>
> from accumulate( TransactionEntry( id == $id, operation == "credit", 
> $amount : amount ),
>
> init( double balance = 0 ),
>
> action( balance += $amount ),
>
> result( new Double( balance ) ) );
>
> $debits: Double( )
>
> from accumulate( TransactionEntry( id == $id, operation == "debit", 
> $amount : amount ),
>
> init( double balance = 0 ),
>
> action( balance -= $amount ),
>
> result( new Double( balance ) ) );
>
> eval( ! $credits.equals( $debits ) ) then
>
> // inconsistency for transaction $id
>
> End
>
> If there are 100 transactions overall and only 10 unique transaction 
> ids (eg, id = 1..10), so that we have on average 10 Transaction facts 
> per id,
>
> - how many times will 'eval' be called?
>
> - how many times will the action be called, assuming 'eval' always 
> returns 'true'?
>
> I guess the answer for the above should be '10 times', once per each 
> id? What if I put another eval statement like "eval($id == 1)" after 
> existing 'eval'? Would that be evaluated 100 times (for all 
> Transaction facts) or only 10 times (once per unique id)?
>
> I think I'm missing quite significant piece on how tuples are selected 
> in DROOLS and how 'eval' and new 'from accumulate' features work Any 
> pointers would be greatly appreciated! (would some general literature 
> on rule engines help to clear up this types of questions?...)
>
> Thanks,
>
> Vlad
>
> PS: sorry for posting so many questions and answering so few.
>
>
>
>___
>rules-users mailing list
>rules-users@lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


[rules-users] accumulate / collect behaviour question - another stupid question

2007-02-21 Thread Olenin, Vladimir (MOH)
Hi,

 

Edson quoted the following sample rule some time ago:

 

rule "transaction consistency"

when

Transaction( $id : id )

$credits: Double( )

  from accumulate( TransactionEntry( id == $id, operation ==
"credit", $amount : amount ),

  init( double balance = 0 ),

  action(  balance += $amount ),

  result( new Double( balance ) ) );

$debits: Double( )

  from accumulate( TransactionEntry( id == $id, operation ==
"debit", $amount : amount ),

  init( double balance = 0 ),

  action(  balance -= $amount ),

  result( new Double( balance ) ) );

eval( ! $credits.equals( $debits ) ) then

   // inconsistency for transaction $id

End

 

 

If there are 100 transactions overall and only 10 unique transaction ids
(eg, id = 1..10), so that we have on average 10 Transaction facts per id,

 

- how many times will 'eval' be called?

- how many times will the action be called, assuming 'eval' always returns
'true'?

 

I guess the answer for the above should be '10 times', once per each id?
What if I put another eval statement like "eval($id == 1)" after existing
'eval'? Would that be evaluated 100 times (for all Transaction facts) or
only 10 times (once per unique id)?

 

I think I'm missing quite significant piece on how tuples are selected in
DROOLS and how 'eval' and new 'from accumulate' features work Any
pointers would be greatly appreciated! (would some general literature on
rule engines help to clear up this types of questions?...)

 

Thanks,

 

Vlad

 

PS: sorry for posting so many questions and answering so few.

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


RE: [rules-users] logical 'not' - is there such a construct?

2007-02-21 Thread Olenin, Vladimir (MOH)
Ok, great. Thanks, Edson.

Vlad
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 21 February 2007 12:01
To: Rules Users List
Subject: Re: [rules-users] logical 'not' - is there such a construct?


   Vlad,

   It will result in exactly the same as removing the exists. So, you 
shall get not problem with that.
   In fact, we have a logic optimizer/transformer that does some 
transformations/optimizations and I will add that as a simple optimization.

   []s
   Edson

Olenin, Vladimir (MOH) wrote:

>In effect, is such construct is allowed now in 3.1M?
>
>   not (
>   exists MyObject2(field == 'value')
>   )
>
>I'm just not sure what 'not' element as an 'existential operation' will do
>in case it's passed 'boolean' result as an operand. Would it act as a
>logical negation? I understand that the above construct can be simply
>expressed by removing 'exists' altogether, but the problem is that the
above
>is the result of 'automatic template' generation (ie, there is a sequence
of
>columns with 'exists' and 'not' elements and in case there is only one such
>element the generation might result in the above construct).
>
>Thanks,
>
>Vlad
>
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
>Sent: 20 February 2007 16:30
>To: Rules Users List
>Subject: Re: [rules-users] logical 'not' - is there such a construct?
>
>No, the "not" conditional element is an existential operator, so the 
>meaning is what you expressed in your first example. I thought that was 
>what you were looking for, but apparently it is not.
>I never heard about any construction capable of doing what you are 
>asking for in a rules engine... maybe someone else can throw some light 
>in...
>
>[]s
>Edson
>
>Olenin, Vladimir (MOH) wrote:
>
>  
>
>>So, if used like that, 'not' does not have 'existential' meaning then, but
>>simple 'negation'? I mean, the expression
>>
>>  not MyObject(field == 'value')
>>
>>would still mean 'not exists', correct? Would the expression
>>
>>  not (MyObject(field == 'value'))
>>
>>mean 
>>
>>  MyObject(field != 'value')
>>
>>then. In other worlds, "all objects OTHER then those matching the
>>constraint"?
>>
>>Thanks.
>>
>>Vlad
>>
>>-Original Message-
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
>>Sent: 20 February 2007 14:37
>>To: Rules Users List
>>Subject: Re: [rules-users] logical 'not' - is there such a construct?
>>
>> Vlad,
>>
>>In 3.1M1 you can write:
>>
>>rule X
>>when
>>not (
>>MyObject( aaa == "bbb" ) and
>>MyObject2( bbb == "aaa" )
>>)
>>then
>>// do something
>>end
>>
>>But remember that variables bound inside the "not" block are not avaible 
>>in the consequence for obvious reasons.
>>
>>[]s
>>Edson
>>
>>Olenin, Vladimir (MOH) wrote:
>>
>> 
>>
>>
>>
>>>Hi,
>>>
>>>I wonder if there is logical 'not' operator (in the meaning of "!=" -> 
>>>'not equal') which can be applied to the whole rule? Eg:
>>>
>>>Rule x
>>>
>>>When
>>>
>>>! (
>>>
>>>MyObject(aaa == "bbb")
>>>
>>>MyObject2(bbb == "aaa")
>>>
>>>)
>>>
>>>Then
>>>
>>>// do smth
>>>
>>>End
>>>
>>>Basically I'm looking for an operator to reverse the evaluation result 
>>>of the expression in the brackets. The use case: in my system all 
>>>rules are defined from 'rule passes' prospective, while the 
>>>application should take some action in case the rule is NOT passed 
>>>(ie, 'else' case).
>>>
>>>Any way to do that except reformulating the constraints themselves?
>>>
>>>Thanks,
>>>
>>>Vlad
>>>
>>>
>>>
>>>___
>>>rules-users mailing list
>>>rules-users@lists.jboss.org
>>>https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>>   
>>>
>>>  
>>>
>> 
>>
>>
>>
>
>
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


RE: [rules-users] logical 'not' - is there such a construct?

2007-02-21 Thread Olenin, Vladimir (MOH)
In effect, is such construct is allowed now in 3.1M?

not (
exists MyObject2(field == 'value')
)

I'm just not sure what 'not' element as an 'existential operation' will do
in case it's passed 'boolean' result as an operand. Would it act as a
logical negation? I understand that the above construct can be simply
expressed by removing 'exists' altogether, but the problem is that the above
is the result of 'automatic template' generation (ie, there is a sequence of
columns with 'exists' and 'not' elements and in case there is only one such
element the generation might result in the above construct).

Thanks,

Vlad


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 20 February 2007 16:30
To: Rules Users List
Subject: Re: [rules-users] logical 'not' - is there such a construct?

No, the "not" conditional element is an existential operator, so the 
meaning is what you expressed in your first example. I thought that was 
what you were looking for, but apparently it is not.
I never heard about any construction capable of doing what you are 
asking for in a rules engine... maybe someone else can throw some light 
in...

[]s
Edson

Olenin, Vladimir (MOH) wrote:

>So, if used like that, 'not' does not have 'existential' meaning then, but
>simple 'negation'? I mean, the expression
>
>   not MyObject(field == 'value')
>
>would still mean 'not exists', correct? Would the expression
>
>   not (MyObject(field == 'value'))
>
>mean 
>
>   MyObject(field != 'value')
>
>then. In other worlds, "all objects OTHER then those matching the
>constraint"?
>
>Thanks.
>
>Vlad
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
>Sent: 20 February 2007 14:37
>To: Rules Users List
>Subject: Re: [rules-users] logical 'not' - is there such a construct?
>
>  Vlad,
>
>In 3.1M1 you can write:
>
>rule X
>when
>not (
>MyObject( aaa == "bbb" ) and
>MyObject2( bbb == "aaa" )
>)
>then
>// do something
>end
>
>But remember that variables bound inside the "not" block are not avaible 
>in the consequence for obvious reasons.
>
>[]s
>Edson
>
>Olenin, Vladimir (MOH) wrote:
>
>  
>
>>Hi,
>>
>>I wonder if there is logical 'not' operator (in the meaning of "!=" -> 
>>'not equal') which can be applied to the whole rule? Eg:
>>
>>Rule x
>>
>>When
>>
>>! (
>>
>>MyObject(aaa == "bbb")
>>
>>MyObject2(bbb == "aaa")
>>
>>)
>>
>>Then
>>
>>// do smth
>>
>>End
>>
>>Basically I'm looking for an operator to reverse the evaluation result 
>>of the expression in the brackets. The use case: in my system all 
>>rules are defined from 'rule passes' prospective, while the 
>>application should take some action in case the rule is NOT passed 
>>(ie, 'else' case).
>>
>>Any way to do that except reformulating the constraints themselves?
>>
>>Thanks,
>>
>>Vlad
>>
>>
>>
>>___
>>rules-users mailing list
>>rules-users@lists.jboss.org
>>https://lists.jboss.org/mailman/listinfo/rules-users
>> 
>>
>>
>>
>
>
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


RE: [rules-users] conditional insert of 'exist' or 'not' keywords in decision table s

2007-02-21 Thread Olenin, Vladimir (MOH)
Hi, Steve,

 

---

I can certainly look at adding some extra config options to the listeners to
allow an end row/column to be specified. I'm not sure the other things would
be useful to many people (correct me if I'm wrong). 
---

 

That definitely would be useful. As to the 'data driven template selection',
I don't know if many people ran into such use cases or not. One thing for
sure, the data model in Excel spreadsheet can be simplified to a great
degree for many applications if one can select appropriate rule template for
particular rule (meaning, the columns or combination of columns can mean
slightly different things for each row). It's somewhat similar to the MVC
pattern, where Model - is data in Excel spreadsheet, View - the rule
tempaltes in drl file. The thing that is 'missing' (or not quite missing -
it's not very flexible and does not depend on the data submitted) is the
data driven Controller. Right now the 'Controller' is driven from the
'outside' by 'hardcoded' links between data and template (hardcoded in a
sense that someone has to define which template goes with which model). The
rule template 'data' can not be applied to any rule template, but just to
the template it was supposed to be used with. It seems like it might be good
to maintain this dependency right with the rule data.

 

If you would have time to make the modification (indicate end column/row)
that would help to achieve such functionality (I'll write the preprocessing
module and submit it here when/if I eventually get to it). Yet even more
powerful concept might be to be able to define 'rule template name' within
the same 'rule template' file vs a separate rule template file. The
implementation might be a bit more involved though...

 

 

Thanks!

 

Vlad

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven Williams
Sent: 20 February 2007 22:25
To: Rules Users List
Subject: Re: [rules-users] conditional insert of 'exist' or 'not' keywords
in decision table s

 

Hi Vlad,

I can certainly look at adding some extra config options to the listeners to
allow an end row/column to be specified. I'm not sure the other things would
be useful to many people (correct me if I'm wrong). 

If you do go down the preprocessing option you could use JXL instead of POI
as you will already have a dependency on it for the drools decision table
stuff. I'm not sure why we changed from POI to JXL but I have found it very
easy to use. 

cheers
Steve

On 2/21/07, Olenin, Vladimir (MOH) <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

Hi, Steve.

 

That might help, though will require one 'external' run over the spreadsheet
(ie, open Excel through POI and read some column with rule template names)
or a separate config file which matches rules with appropriate templates.
Regarding the ExternalSheetListener constructor, is there a way to set the
number of records to read? From what I see (the API call), the l1 will
process the same data as l2 does (when the compiler will get to row '30')
and the data for the second template might not be very applicable for the
first template. Basically, the thing is starting from row 30 the data merged
with template 1 might generate invalid rules which is not desirable. Any way
to avoid it?

 

The main reason such functionality is required in the first place (in our
project at least) is that for some use cases the same data can mean slightly
different things and should result in slightly different rules. The number
of such 'groups' is quite large to split the 'rule data' into separate
spreadsheets and the differences between the data interpretation are quite
significant for coming up with some 'generic' data format (which could suit
all rule 'groups'). There is definitely a bunch of workarounds that can be
done, but most of them would require Excel spreadsheet preprocessing.

 

Within the existing API (from the example you attached) Excel preprocessing
might be the easiest thing to do. Unless there is some more low level API
which allows to insert 'interceptor' which would monitor each record that is
being read by compiler and create new listener if appropriate entry is found
in the particular column (eg, one column in the spreadsheet might have
template name entry which remains the same for all records below unless
changed to a new value). Smth along those lines :-) .

 

 

Thanks, Steve.

 

Vlad

 

  _  

From: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
[mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ] On Behalf Of Steven Williams
Sent: 19 February 2007 18:54


To: Rules Users List
Subject: Re: [rules-users] conditional insert of 'exist' or 'not' keywords
in decision table s

 

Hi Vlad,

Ther

RE: [rules-users] logical 'not' - is there such a construct?

2007-02-20 Thread Olenin, Vladimir (MOH)
Well, probably to rephrase it, what is the status / thoughts on 'else'
construct for rules? Basically global 'logical' not for rules would be the
'else' branch of conditional statement (if DROOLS had one), correct? I've
read some postings regarding this shortly after I joined the list (ie,
around a month ago). I wonder if that discussion went anywhere


To clarify, I do need the _logical_ not, NOT exisitential. So that the
constructs with logical 'not' would select an 'inverse' fact tuples, ie,
tuples for facts that did not the condition Kind of simple logical
statement transformation in boolean algebra (DeMorgan law?...):


   MyObject( field == 'value' )  and MyObject2( field == 'value' )   --->
!( MyObject( field != 'value' )   or MyObject2( field != 'value' ) )


If '!' would mean "ALL TUPLES FOR FACTS IN THE RULE" XOR "SELECTED TUPLES",
would the above conditions select the same set of tuples? I assume the
engine should just 'expand' any such 'logical not' operands to move it into
the coluimn constraints?..

I might be confusing smth though On the second thought for my particular
case 'existential' not should work too, so I guess the above is just a
possible extention of functionality. It really has nothing to do with the
rule engine itself (from what I see), but rather transformation of the
logical expressions before they are feeded into the rules engine.

Thanks for the answers, Edson.

Vlad




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 20 February 2007 16:30
To: Rules Users List
Subject: Re: [rules-users] logical 'not' - is there such a construct?

No, the "not" conditional element is an existential operator, so the 
meaning is what you expressed in your first example. I thought that was 
what you were looking for, but apparently it is not.
    I never heard about any construction capable of doing what you are 
asking for in a rules engine... maybe someone else can throw some light 
in...

[]s
Edson

Olenin, Vladimir (MOH) wrote:

>So, if used like that, 'not' does not have 'existential' meaning then, but
>simple 'negation'? I mean, the expression
>
>   not MyObject(field == 'value')
>
>would still mean 'not exists', correct? Would the expression
>
>   not (MyObject(field == 'value'))
>
>mean 
>
>   MyObject(field != 'value')
>
>then. In other worlds, "all objects OTHER then those matching the
>constraint"?
>
>Thanks.
>
>Vlad
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
>Sent: 20 February 2007 14:37
>To: Rules Users List
>Subject: Re: [rules-users] logical 'not' - is there such a construct?
>
>  Vlad,
>
>In 3.1M1 you can write:
>
>rule X
>when
>not (
>MyObject( aaa == "bbb" ) and
>MyObject2( bbb == "aaa" )
>)
>then
>// do something
>end
>
>But remember that variables bound inside the "not" block are not avaible 
>in the consequence for obvious reasons.
>
>[]s
>Edson
>
>Olenin, Vladimir (MOH) wrote:
>
>  
>
>>Hi,
>>
>>I wonder if there is logical 'not' operator (in the meaning of "!=" -> 
>>'not equal') which can be applied to the whole rule? Eg:
>>
>>Rule x
>>
>>When
>>
>>! (
>>
>>MyObject(aaa == "bbb")
>>
>>MyObject2(bbb == "aaa")
>>
>>)
>>
>>Then
>>
>>// do smth
>>
>>End
>>
>>Basically I'm looking for an operator to reverse the evaluation result 
>>of the expression in the brackets. The use case: in my system all 
>>rules are defined from 'rule passes' prospective, while the 
>>application should take some action in case the rule is NOT passed 
>>(ie, 'else' case).
>>
>>Any way to do that except reformulating the constraints themselves?
>>
>>Thanks,
>>
>>Vlad
>>
>>
>>
>>___
>>rules-users mailing list
>>rules-users@lists.jboss.org
>>https://lists.jboss.org/mailman/listinfo/rules-users
>> 
>>
>>
>>
>
>
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


RE: [rules-users] logical 'not' - is there such a construct?

2007-02-20 Thread Olenin, Vladimir (MOH)
So, if used like that, 'not' does not have 'existential' meaning then, but
simple 'negation'? I mean, the expression

   not MyObject(field == 'value')

would still mean 'not exists', correct? Would the expression

   not (MyObject(field == 'value'))

mean 

   MyObject(field != 'value')

then. In other worlds, "all objects OTHER then those matching the
constraint"?

Thanks.

Vlad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 20 February 2007 14:37
To: Rules Users List
Subject: Re: [rules-users] logical 'not' - is there such a construct?

  Vlad,

In 3.1M1 you can write:

rule X
when
not (
MyObject( aaa == "bbb" ) and
MyObject2( bbb == "aaa" )
)
then
// do something
end

But remember that variables bound inside the "not" block are not avaible 
in the consequence for obvious reasons.

[]s
Edson

Olenin, Vladimir (MOH) wrote:

> Hi,
>
> I wonder if there is logical 'not' operator (in the meaning of "!=" -> 
> 'not equal') which can be applied to the whole rule? Eg:
>
> Rule x
>
> When
>
> ! (
>
> MyObject(aaa == "bbb")
>
> MyObject2(bbb == "aaa")
>
> )
>
> Then
>
> // do smth
>
> End
>
> Basically I'm looking for an operator to reverse the evaluation result 
> of the expression in the brackets. The use case: in my system all 
> rules are defined from 'rule passes' prospective, while the 
> application should take some action in case the rule is NOT passed 
> (ie, 'else' case).
>
> Any way to do that except reformulating the constraints themselves?
>
> Thanks,
>
> Vlad
>
>
>
>___
>rules-users mailing list
>rules-users@lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


[rules-users] logical 'not' - is there such a construct?

2007-02-20 Thread Olenin, Vladimir (MOH)
Hi,

 

I wonder if there is logical 'not' operator (in the meaning of "!=" -> 'not
equal') which can be applied to the whole rule? Eg:

 

Rule x

When

! (

MyObject(aaa == "bbb")

MyObject2(bbb == "aaa")

)

Then

// do smth

End

 

 

Basically I'm looking for an operator to reverse the evaluation result of
the expression in the brackets. The use case: in my system all rules are
defined from 'rule passes' prospective, while the application should take
some action in case the rule is NOT passed (ie, 'else' case).

 

Any way to do that except reformulating the constraints themselves?

 

Thanks,

 

Vlad

 

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


RE: [rules-users] exists + normal column constraints - how many t imes a rule is cal led in the end????

2007-02-20 Thread Olenin, Vladimir (MOH)
Thanks, Oana. I think I'm finally starting to get a grip on this thing :-).

 

 

Vlad

 

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of nicolae oana
Sent: 20 February 2007 03:38
To: Rules Users List
Subject: Re: [rules-users] exists + normal column constraints - how many
times a rule is cal led in the end

 

Vlad,

exists Person(role == "parent")  

checks if in workingMemory is at least one Person fact having  attribute
role == "parent", in both your examples.

Your reasoning is correct: the four facts with role =="child" will activate
the rule. So, the result for your second example will be the same as the
first result, for your list of facts, no matter how you switch the columns.

Regards,
         Oana

"Olenin, Vladimir (MOH)" <[EMAIL PROTECTED]> wrote:

Hi,

 

I'm not sure my understanding of 'existential quantifiers' is correct.
Hopefully, someone can clear it up a bit...

 

Providing I have the following fact class:

 

Person(role: parent/child, name)

 

And following facts:

 

1: parent, John

2: parent, Alice

3: parent, Steve

4: parent, Jane

5: child, Eric

6: child, Rob

7: child, May

8: child, April

 

I expect the rule

 

Rule "iterate children if at least one parent is found"

When

exists Person(role == 'parent')

$child: Person(role == 'child')

Then

// do smth for each $child if at least one parent is found

End

 

 

To iterate through all 'child' persons (facts 5 through 8), ie the action
will be called exactly 4 times. Is this correct? What would happen if I swap
the order of the conditions (with 'parent exists' constrain going _after_
'child' constraint):

 

When

$child: Person(role == 'child')

exists Person(role == 'parent')

 

Thanks,

 

Vlad

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

 

  

  _  

Now that's room service! Choose
<http://travel.yahoo.com/hotelsearchpage;_ylc=X3oDMTFtaTIzNXVjBF9TAzk3NDA3NT
g5BF9zAzI3MTk0ODEEcG9zAzIEc2VjA21haWx0YWdsaW5lBHNsawNxMS0wNw--%0d%0a>  from
over 150,000 hotels 
in 45,000 destinations on Yahoo! Travel to find your fit.

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


RE: [rules-users] conditional insert of 'exist' or 'not' keywords in decision table s

2007-02-20 Thread Olenin, Vladimir (MOH)
Hi, Steve.

 

That might help, though will require one 'external' run over the spreadsheet
(ie, open Excel through POI and read some column with rule template names)
or a separate config file which matches rules with appropriate templates.
Regarding the ExternalSheetListener constructor, is there a way to set the
number of records to read? From what I see (the API call), the l1 will
process the same data as l2 does (when the compiler will get to row '30')
and the data for the second template might not be very applicable for the
first template. Basically, the thing is starting from row 30 the data merged
with template 1 might generate invalid rules which is not desirable. Any way
to avoid it?

 

The main reason such functionality is required in the first place (in our
project at least) is that for some use cases the same data can mean slightly
different things and should result in slightly different rules. The number
of such 'groups' is quite large to split the 'rule data' into separate
spreadsheets and the differences between the data interpretation are quite
significant for coming up with some 'generic' data format (which could suit
all rule 'groups'). There is definitely a bunch of workarounds that can be
done, but most of them would require Excel spreadsheet preprocessing.

 

Within the existing API (from the example you attached) Excel preprocessing
might be the easiest thing to do. Unless there is some more low level API
which allows to insert 'interceptor' which would monitor each record that is
being read by compiler and create new listener if appropriate entry is found
in the particular column (eg, one column in the spreadsheet might have
template name entry which remains the same for all records below unless
changed to a new value). Smth along those lines :-).

 

 

Thanks, Steve.

 

Vlad

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven Williams
Sent: 19 February 2007 18:54
To: Rules Users List
Subject: Re: [rules-users] conditional insert of 'exist' or 'not' keywords
in decision table s

 

Hi Vlad,

There is a very basic wiki page on it
(http://wiki.jboss.org/wiki/Wiki.jsp?page=DecisionTableTemplates
<http://wiki.jboss.org/wiki/Wiki.jsp?page=DecisionTableTemplates>  ).

In terms of the functionality you mention you have your data having
knowledge of the rule templates whereas the current implementation is such
that the data has no knowledge of the templates. You can apply multiple rule
templates to the same data however (as in
ExternalSpreadsheetCompilerIntegrationTest): 

final ExternalSpreadsheetCompiler converter = new
ExternalSpreadsheetCompiler();
final List listeners = new ArrayList();
ExternalSheetListener l1 = new ExternalSheetListener(10, 3,
"/templates/test_pricing1.drl"); 
listeners.add(l1);
ExternalSheetListener l2 = new ExternalSheetListener(30, 3,
"/templates/test_pricing2.drl");
listeners.add(l2);
converter.compile("/data/ExamplePolicyPricing.xls", InputType.XLS,
listeners);

This example assumes two sets of data in the one sheet, however they could
both have been applied to the same set (ie. the second listener could also
point to row 10, column 3). Would that accomplish what you need? 

Steve




On 2/20/07, Olenin, Vladimir (MOH) <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  > wrote:

Thanks, Steve. That really seems to do the trick. Are there any wiki pages
on this new functionality? Or for now one should refer to the source code &
unit tests?

 

I also wonder what other functionality the new templating engine has? Is it
possible to define different 'types' of rules in the same 'rule' template
and refer to these types from 'Excel' data fields (eg, have one column per
rule where you can refer 'rule template XXX' from drl file; this value can
override some default value for example). If not, how such situations can be
handled? (ie, when one needs several type of rules driven by the same data?)

 

Thanks,

 

Vlad

  _  

From: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
[mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ] On Behalf Of Steven Williams
Sent: 17 February 2007 04:25
To: Rules Users List
Subject: Re: [rules-users] conditional insert of 'exist' or 'not' keywords
in decision table s

 

Hi Vlad,

With the new decision table handling you could use the following template to
do it:

Given a table as follows:


exists, 21, 25

, comprehensive


not, 64, 100

exists, comprehensive

the following template does what you want:

template header
driver[]
policy[]

package This_is_a_ruleset;
#generated from Decision Table
import example.model.Driver;
import example.model.Policy ;

template "Driver policy"
driver
policy

rule "driver poli

[rules-users] exists + normal column constraints - how many times a rule is cal led in the end????

2007-02-19 Thread Olenin, Vladimir (MOH)
Hi,

 

I'm not sure my understanding of 'existential quantifiers' is correct.
Hopefully, someone can clear it up a bit...

 

Providing I have the following fact class:

 

Person(role: parent/child, name)

 

And following facts:

 

1: parent, John

2: parent, Alice

3: parent, Steve

4: parent, Jane

5: child, Eric

6: child, Rob

7: child, May

8: child, April

 

I expect the rule

 

Rule "iterate children if at least one parent is found"

When

exists Person(role == 'parent')

$child: Person(role == 'child')

Then

// do smth for each $child if at least one parent is found

End

 

 

To iterate through all 'child' persons (facts 5 through 8), ie the action
will be called exactly 4 times. Is this correct? What would happen if I swap
the order of the conditions (with 'parent exists' constrain going _after_
'child' constraint):

 

When

$child: Person(role == 'child')

exists Person(role == 'parent')

 

Thanks,

 

Vlad

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


RE: [rules-users] Convert logic to DRL rules

2007-02-19 Thread Olenin, Vladimir (MOH)
To improve my understanding of DROOLS a bit, just a small follow up
question.

If the modification of the business domain model is correct and will result
in the correct behavior, I wonder what kind of performance implications such
modification will bring (to compare with 'flatten' model)? Would the
performance become worse, better or remain approximately the same (for a
significant number of rules & fact objects)?  Currently I'm at the cross
roads whether to create such artificial 'inverted index' for my application
or not (I didn't know that the connective constraints are available in
3.1M...).

Thanks,

Vlad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 19 February 2007 11:05
To: Rules Users List
Subject: Re: [rules-users] Convert logic to DRL rules


   Vlad,

   I think that for Bill's case, the object structure is flatten already 
(what is good for rules). Creating nested objects will actually make it 
more difficult to write the rules...

   Just my 0.02c

   []s
   Edson

Olenin, Vladimir (MOH) wrote:

>I guess if you modify the business objects a bit (in quite weird way - I
>think it would be rather a shortcut than a solution) you can implement this
>kind of logic: you need to swap property (zipcode, age, etc) and 'property
>ownner' (Person) objects, so that you'll have:
>
>Person (id)
>ZipCode (id, code)
>Age (id, age)
>Etc
>
>In this case you should be able to write:
>
>Rule X
>When
>   $p: Person($id: id)
>   (
>   ZipCode(id == $id, code == "23456")
>  or ZipCode(id == $id, code == "68590")
>   )
>   And
>   (
>   Age(id == $id, age < 25)
>  Or Age(id == $id, age > 34)
>   )
>Then
>   // do smth using $p
>End
>
>
>Or smth along those lines... Would that work?.
>
>
>Vlad
>   
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Bill Zhang
>Sent: 19 February 2007 09:14
>To: Rules Users List
>Subject: Re: [rules-users] Convert logic to DRL rules
>
>Hi Alex,
>
>Thank you for confirming this. Writing such a builder may take us a
>lot of time because our business user is used to free style
>Pascal-like authoring using quite complex logic. For example,
>
>IF
>(
> (
>  (Person.Age > 35 OR Person.Age < 25) AND
>  (Person.ZipCode =23546 or Person.ZipCode = 68590)
> )
> and
> (
>  (Person.LastOrderPrice > 300 OR
>  (Person.TotalOrderNumber > 2)
> )
>)
>OR
>(
> (
>  (Person.LastOrderCategory in ("098", "109") ) AND
>  (Person.ZipCode =74567 or Person.ZipCode = 23765)
> )
> and
> (
>  (Person.LastOrderPrice > 1000 OR
>  (Person.TotalOrderNumber > 1)
> )
>)
>...
>
>THEN Person.Status = "KT";
>
>Before I set out to write the builder, I would like to know whether
>the new syntax can handle the above logic? Also, where can I find
>document for the new syntax?
>
>I am also trying to find some existing open source Java library to
>"flatten out" these complex logic - to break these complex logic to
>atomic ones that can be handled by Drools. Do you have any
>recommendation?
>
>Thanks a lot for your help.
>
>Bill Y.
>
>
>
>
>On 2/19/07, Alexander Varakin <[EMAIL PROTECTED]> wrote:
>  
>
>>We built a Rule Builder which creates drl with all possible
>>combinations. In any case, drl syntax is not exactly business user
>>friendly, so having such builder is not a bad idea.
>>Simple Rule Builder can be implemented as an Excel spreadsheet, which
>>can be easily parsed using POI library and then drl file produced.
>>
>>Steven Williams wrote:
>>
>>
>>>Hi Bill,
>>>
>>>To implement your rules in 3.0.5 you would need to implement a rule
>>>for  each combination of age and zipCode.
>>>
>>>$a : Person(age > 35 zipCode == 23546)
>>>then
>>>$a.setStatus("KT");
>>>
>>>$a : Person(age < 25, zipCode == 23546 )
>>>then
>>>$a.setStatus("KT");
>>>
>>>$a : Person(age > 35, zipCode == 68590)
>>>then
>>>$a.setStatus("KT");
>>>
>>>etc..
>>>
>>>Steve
>>>
>>>On 2/19/07, *Bill Zhang* <[EMAIL PROTECTED]
>>><mailto:[EMAIL PROTECTED]>> wrote:
>>>
>>>So Alex, if I only want to use the old syntax that is in production,
>>>there is no way to implement my seemingly simple logic conditioning?
>>&g

RE: [rules-users] Drools With Spring Framework Problem

2007-02-19 Thread Olenin, Vladimir (MOH)
Check out 'Spring Modules' subproject - it has a DROOLS integration module.
Haven't used it myself yet, so not sure whether it's mature/compatible with
most recent release.

https://springmodules.dev.java.net/docs/reference/0.7/html/jsr94.html#d0e570
9

https://springmodules.dev.java.net/

Vlad
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Niyas
Sent: 19 February 2007 09:49
To: rules-users@lists.jboss.org
Subject: [rules-users] Drools With Spring Framework Problem

Hi all,

I am in need of integrating Drools JBoss Rule Engine with Spring Framework.
I have tried sample rule engine examples in the Drools in the
standalone with the help od drools IDE for eclipse 3.2.
And I also tried some example in the Spring Framework,to know how it
works. I have tried some examples in IOC, MVC and JDBC in the spring
framework.

Now, I want to use both Drools and Spring Framework in such a way that
Spring will have the MVC application and it should validate the rules,
which written in the drools (.drl)

I don't know how to begin with/what are he configuration files needed
to setup. PLease if anyone have the sample coding on Drools with
Spring or any other links willl be very useful.

And also, guide me what are the things need to be know for Spring with
Drools. While I have searched in google, lots of things came up like:

Use JSR94... (which is mentioning to configure RuleServiceProvider,
RuleRuntime, RuleSet..and others..which seeme to be confusing and not
clear)

Whether there are any API for drools with spring that DROOLS is
supporting..like org.drools.spring.metadata.ArgumentMetadataSource. I
don't find these Drools API section
http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3
.0.5/apidocs/index.html
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Convert logic to DRL rules

2007-02-19 Thread Olenin, Vladimir (MOH)
I guess if you modify the business objects a bit (in quite weird way - I
think it would be rather a shortcut than a solution) you can implement this
kind of logic: you need to swap property (zipcode, age, etc) and 'property
ownner' (Person) objects, so that you'll have:

Person (id)
ZipCode (id, code)
Age (id, age)
Etc

In this case you should be able to write:

Rule X
When
$p: Person($id: id)
(
ZipCode(id == $id, code == "23456")
   or ZipCode(id == $id, code == "68590")
)
And
(
Age(id == $id, age < 25)
   Or Age(id == $id, age > 34)
)
Then
// do smth using $p
End


Or smth along those lines... Would that work?.


Vlad


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bill Zhang
Sent: 19 February 2007 09:14
To: Rules Users List
Subject: Re: [rules-users] Convert logic to DRL rules

Hi Alex,

Thank you for confirming this. Writing such a builder may take us a
lot of time because our business user is used to free style
Pascal-like authoring using quite complex logic. For example,

IF
(
 (
  (Person.Age > 35 OR Person.Age < 25) AND
  (Person.ZipCode =23546 or Person.ZipCode = 68590)
 )
 and
 (
  (Person.LastOrderPrice > 300 OR
  (Person.TotalOrderNumber > 2)
 )
)
OR
(
 (
  (Person.LastOrderCategory in ("098", "109") ) AND
  (Person.ZipCode =74567 or Person.ZipCode = 23765)
 )
 and
 (
  (Person.LastOrderPrice > 1000 OR
  (Person.TotalOrderNumber > 1)
 )
)
...

THEN Person.Status = "KT";

Before I set out to write the builder, I would like to know whether
the new syntax can handle the above logic? Also, where can I find
document for the new syntax?

I am also trying to find some existing open source Java library to
"flatten out" these complex logic - to break these complex logic to
atomic ones that can be handled by Drools. Do you have any
recommendation?

Thanks a lot for your help.

Bill Y.




On 2/19/07, Alexander Varakin <[EMAIL PROTECTED]> wrote:
> We built a Rule Builder which creates drl with all possible
> combinations. In any case, drl syntax is not exactly business user
> friendly, so having such builder is not a bad idea.
> Simple Rule Builder can be implemented as an Excel spreadsheet, which
> can be easily parsed using POI library and then drl file produced.
>
> Steven Williams wrote:
> > Hi Bill,
> >
> > To implement your rules in 3.0.5 you would need to implement a rule
> > for  each combination of age and zipCode.
> >
> > $a : Person(age > 35 zipCode == 23546)
> > then
> > $a.setStatus("KT");
> >
> > $a : Person(age < 25, zipCode == 23546 )
> > then
> > $a.setStatus("KT");
> >
> > $a : Person(age > 35, zipCode == 68590)
> > then
> > $a.setStatus("KT");
> >
> > etc..
> >
> > Steve
> >
> > On 2/19/07, *Bill Zhang* <[EMAIL PROTECTED]
> > > wrote:
> >
> > So Alex, if I only want to use the old syntax that is in production,
> > there is no way to implement my seemingly simple logic conditioning?
> >
> > Thanks for your help.
> >
> > On 2/18/07, Alexander Varakin < [EMAIL PROTECTED]
> > > wrote:
> > > As far as I know this syntax is new and is available in SVN
> > only, you
> > > will have to wait till 3.1 is released or take source from SVN
> > and build it.
> > >
> > > Bill Zhang wrote:
> > > > Hi Steven,
> > > >
> > > > Thank you very much for your help. Really appreciate.
> > > >
> > > > I still got the same error, Unexpected token '|'. I did not
> > see "|" in
> > > > the document, only saw "||", which is supposed to be used with
> > > > columns.
> > > >
> > > > Ye
> > > >
> > > > On 2/18/07, Steven Williams < [EMAIL PROTECTED]
> > > wrote:
> > > >> Hi Bill,
> > > >>
> > > >> I think it should be:
> > > >>
> > > >> $a : Person(age > 35 | < 25, zipCode == 23546 | == 68590)
> > > >>
> > > >> Edson, Mark or Michael can probably confirm or correct the
> > above syntax.
> > > >>
> > > >> Make sure you are running of the latest trunk.
> > > >>
> > > >> cheers
> > > >> Steve
> > > >>
> > > >>
> > > >> On 2/18/07, Bill Zhang <[EMAIL PROTECTED]
> > > wrote:
> > > >> >
> > > >> > I tried:
> > > >> >
> > > >> > $a : Person(age > 35 || age < 25, zipCode == 23546 || ==
68590)
> > > >> >
> > > >> > Errors:
> > > >> > org.drools.rule.InvalidRulePackage : unknown:39:30
> > > >> Unexpected token '||'
> > > >> > unknown:39:40 mismatched token:
> > > >> [EMAIL PROTECTED],1040:1041='<=',<47>,39:40];
> > > >> > expecting type '('
> > > >> > unknown:39:92 mismatched token:
> > > >> [EMAIL PROTECTED],1092:1092='<',<46>,39:92];
> > > >> > expecting type '('
> > > >> >
> > > >> > I also tried
> > > >> >
> > > >> > $a : Person(age 

RE: [rules-users] conditional insert of 'exist' or 'not' keywords in decision table s

2007-02-19 Thread Olenin, Vladimir (MOH)
Thanks, Steve. That really seems to do the trick. Are there any wiki pages
on this new functionality? Or for now one should refer to the source code &
unit tests?

 

I also wonder what other functionality the new templating engine has? Is it
possible to define different 'types' of rules in the same 'rule' template
and refer to these types from 'Excel' data fields (eg, have one column per
rule where you can refer 'rule template XXX' from drl file; this value can
override some default value for example). If not, how such situations can be
handled? (ie, when one needs several type of rules driven by the same data?)

 

Thanks,

 

Vlad

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven Williams
Sent: 17 February 2007 04:25
To: Rules Users List
Subject: Re: [rules-users] conditional insert of 'exist' or 'not' keywords
in decision table s

 

Hi Vlad,

With the new decision table handling you could use the following template to
do it:

Given a table as follows:


exists, 21, 25

, comprehensive


not, 64, 100

exists, comprehensive

the following template does what you want:

template header
driver[]
policy[]

package This_is_a_ruleset;
#generated from Decision Table
import example.model.Driver;
import example.model.Policy ;

template "Driver policy"
driver
policy

rule "driver policy $row.rowNumber$"
when
$driver0$
Driver(age >= $driver1$, age <= $driver2$)
$policy0$ 
Policy(type = "$policy1$")
then
//do smth
end
end template

the code to call it was:
public void testColumnKeywords() {
final ExternalSpreadsheetCompiler converter = new
ExternalSpreadsheetCompiler(); 
final String drl = converter.compile( "/data/TestWorkbook.xls",
"/templates/test_keywords.drl",
  InputType.XLS, 1, 1 ); // DT
starts at Row 1, Column 1 
System.out.println(drl);
}

cheers
Steve

On 2/17/07, Olenin, Vladimir (MOH) < <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED]> wrote:

Hi,

 

I wonder if it's possible to pass some Column keywords as parameters from
template values, eg:

 


Condition

Condition


$1 Driver

$1 Policy


age >= $2, age <= $3

type


exists, 21, 25

, comprehensive


not, 64, 100

exists, comprehensive

 

I'd expect the above table would generate two rules like:

 

Rule 1

When

exists Driver (age >= 21, age <= 25)

Policy(type == "comprehensive")

Then

// do smth

End

 

 

Rule 2

When

not Driver (age >= 64, age <= 100)

exists Policy (type == "comprehensive")

then

// do smth

End

 

 

 

The above example is just a mock up derived from one of the examples in the
documentation to demonstrate the point (meaning, the rules themselves might
not make sense from business point of view or can be implemented differently
for this particular case).

 

So, any way to achieve this? Whether in current version (3.0.x) or the
upcoming release (3.2)

 

Thanks,

 

Vlad


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




-- 
Steven Williams

Supervising Consultant

Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501 
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
www.objectconsulting.com.au <http://www.objectconsulting.com.au> 

consulting | development | training | support 
our experience makes the difference 

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


[rules-users] conditional insert of 'exist' or 'not' keywords in decision table s

2007-02-16 Thread Olenin, Vladimir (MOH)
Hi,

 

I wonder if it's possible to pass some Column keywords as parameters from
template values, eg:

 


Condition

Condition


$1 Driver

$1 Policy


age >= $2, age <= $3

type


exists, 21, 25

, comprehensive


not, 64, 100

exists, comprehensive

 

I'd expect the above table would generate two rules like:

 

Rule 1

When

exists Driver (age >= 21, age <= 25)

Policy(type == "comprehensive")

Then

// do smth

End

 

 

Rule 2

When

not Driver (age >= 64, age <= 100)

exists Policy (type == "comprehensive")

then

// do smth

End

 

 

 

The above example is just a mock up derived from one of the examples in the
documentation to demonstrate the point (meaning, the rules themselves might
not make sense from business point of view or can be implemented differently
for this particular case).

 

So, any way to achieve this? Whether in current version (3.0.x) or the
upcoming release (3.2)

 

Thanks,

 

Vlad

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


[rules-users] DROOLS 3.1M new syntax & Decision Tables

2007-02-14 Thread Olenin, Vladimir (MOH)
Hi,

 

I wonder if new syntax (specifically - 'accumulate' keyword) works correctly
with Decision Tables? Can the new keywords be used in 'Condition' and
'Action' parts of the rule?

 

Thanks,

 

Vlad

 

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


RE: [rules-users] calls to 'Helper' classes in LHS - are they all owed?

2007-02-13 Thread Olenin, Vladimir (MOH)
 the checks that need to happen to find a rule match.  Since the engine
can't know that Helper.transform("value") returns a constant value, it has
to re-run that every time and it has to reject for matches to the rule
constraint every time.

I'm sure this would really sink performance, in other words.  You can easily
see the effect -- write the rule this way and time it, and then write it
with the return value of Helper.transform being inlined, and I'm sure
there's a big difference.  It's the same as any other eval(...) situation in
Drools; possible, but not good for performance. 

 

On 2/12/07, Olenin, Vladimir (MOH) <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

Hi,

I was wondering if calls to a Helper class are allowed in LHS of the rule?
Eg:

Rule myRule
When
MyObject(objField == Helper.transform("value"))
Then
   // smth
End 


Thanks,

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

 


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







-- 
Steven Williams

Supervising Consultant

Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
[EMAIL PROTECTED]  <mailto:[EMAIL PROTECTED]> 
www.objectconsulting.com.au <http://www.objectconsulting.com.au> 

consulting | development | training | support
our experience makes the difference 
___
rules-users mailing list
rules-users@lists.jboss.org <mailto:rules-users@lists.jboss.org> 
https://lists.jboss.org/mailman/listinfo/rules-users
<https://lists.jboss.org/mailman/listinfo/rules-users> 





 





  _  



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

 

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


RE: [rules-users] Roll Back Rule / Rule Transactions?

2007-02-13 Thread Olenin, Vladimir (MOH)
NOTE: I'm not a DROOL expert. Keeping this in mind, I'd say


You'd need a separate rule which states:

 - if a cart does NOT contain TV, remove any free VCR from the cart if any

Once you retract the 'TV' fact from WorkingMemory and refire the rules (or
they will automatically refire?), this new rule will be activate and remove
the free VCR from the cart.

Just my 2c...

Vlad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Matt Johnston
Sent: 13 February 2007 11:21
To: rules-users@lists.jboss.org
Subject: [rules-users] Roll Back Rule / Rule Transactions?

I am working on rules for an online shopping cart. Depending on the
products in the cart, the customer may get certain discounts.

If cart contains a TV, add a free VCR.

I can apply these rules, but what about rolling them back? 

So in the example above, the rule automatically added a free VCR because
the cart contained a TV. If the customer removes the TV, I need to roll
back the VCR rule and also remove the VCR from the cart.

Does anyone know how to do this? Is it possible?

Matt Johnston
Manager of Internet Content
Publishing Group of America
p: 615-468-6053
f: 615-468-6153

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


[rules-users] decision table + DSL?

2007-02-13 Thread Olenin, Vladimir (MOH)
Hi,

 

I wonder if it is possible to combine decision tables with your own DSL (eg,
in rule and action definitions, but ideally in data definition too)? Is
there such a way? Is there any keyword that can be set inside the decision
table to point to your DSL implementation?

 

Thanks.

 

Vlad

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


RE: [rules-users] fact tuples selection - what are the principles - a bit confused?

2007-02-13 Thread Olenin, Vladimir (MOH)
No, I'm not concerned with the order in this particular case - just trying
to figure out what I should be taking into account or rely on when doing the
design. Thanks for taking the time to go through (now that I scrolled
through it myself :-) ) this quite lengthy email.

 

Vlad

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael Neale
Sent: 12 February 2007 23:53
To: Rules Users List
Subject: Re: [rules-users] fact tuples selection - what are the principles -
a bit confused?

 

that sounds correct.

No you can't really depend on things happening in a certain order. of course
it will be consistent between executions for the same data, but you can't
count on that. It would mostly be effected by the order in which you assert
facts. 

I guess the question is why are you concerned in what order it does things?

Michael

On 2/13/07, Olenin, Vladimir (MOH) < <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED]> wrote:

Hi,

I was trying to find more detailed explanation on how the fact tuples for 
activations are being selected based on the constraints, but couldn't find
much. So, I guess I just want to assert my understanding of this process is
correct.

Assuming I have the following set of 'Accounts' with the fields: 

ID  | Province   | City| Type| Balance

1  | ON | Toronto | Checking| 1000
2  | BC | Vancouver   | Checking| 100 
3  | ON | Toronto | Visa| 2000
4  | ON | Toronto | Checking|-100
5  | BC | Vancouver   | Checking| 100
6  | BC | Vancouver   | Visa| 150 
7  | AB | Calgary | Checking| 100
7  | AB | Toronto | Checking| 300

I have two rules to process:

1) within each province, the sum of balances on Visa accounts should less 
then 10 times the sum of balances on Checking accounts (within the same
province)
2) within each province, the sum of balances on Checking accounts should be
a positive number
3) within each province and within each city, the number of visa accounts 
should be no more than 2 times the number of checking accounts

If I model my business objects like this:

1) Account  (id, province, city, type, balance)
2) Province (province)
3) City (province, city) 


And WorkingMemory will be initialized (for the data above) with:
- 7 Account instances (ids 1 through 7)
- 3 Province instances (ON, AB, BC)
- 3 City instances (Toronto, Vancouver, Calgary) 


Then the rules containing 'within province' would read like:
-
Rule '1'
When
Province($prov: province)
$a: Account(province == $prov)
Then
// accumulate sums on Checking and Visa accounts as Edson showed in 
previous emails
End
-


The rule containing 'within province, within city' would have then:
-
Rule '3'
When
Province($prov: province)
  City($city: city, province = $prov) 
$a: Account(province = $prov, city = $city)
Then
// accumulate sums on Checking and Visa accounts as Edson showed in
previous emails
-


Is this correct business object model to achieve the goal? Do I understand 
correctly that the LHS statement:


Province($prov: province)
  City($city: city, province = $prov)
$a: Account(province = $prov, city = $city)


Can be read as:

For each province 
For each city within the province
For each account for the given city and province



What 'guides' the order in which fact tuples are selected from the set of 
all facts in the WorkingMemory? Can any particular sequence be guaranteed?

Thanks!

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

 

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


[rules-users] calls to 'Helper' classes in LHS - are they allowed?

2007-02-12 Thread Olenin, Vladimir (MOH)
Hi,

I was wondering if calls to a Helper class are allowed in LHS of the rule?
Eg:

Rule myRule
When
MyObject(objField == Helper.transform("value"))
Then
   // smth  
End


Thanks,

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


[rules-users] fact tuples selection - what are the principles - a bit confused?

2007-02-12 Thread Olenin, Vladimir (MOH)
Hi,

I was trying to find more detailed explanation on how the fact tuples for
activations are being selected based on the constraints, but couldn't find
much. So, I guess I just want to assert my understanding of this process is
correct.

Assuming I have the following set of 'Accounts' with the fields:

ID  | Province   | City| Type| Balance

 1  | ON | Toronto | Checking| 1000
 2  | BC | Vancouver   | Checking| 100
 3  | ON | Toronto | Visa| 2000
 4  | ON | Toronto | Checking|-100
 5  | BC | Vancouver   | Checking| 100
 6  | BC | Vancouver   | Visa| 150
 7  | AB | Calgary | Checking| 100
 7  | AB | Toronto | Checking| 300

I have two rules to process:

1) within each province, the sum of balances on Visa accounts should less
then 10 times the sum of balances on Checking accounts (within the same
province)
2) within each province, the sum of balances on Checking accounts should be
a positive number
3) within each province and within each city, the number of visa accounts
should be no more than 2 times the number of checking accounts

If I model my business objects like this:

1) Account  (id, province, city, type, balance)
2) Province (province)
3) City (province, city)


And WorkingMemory will be initialized (for the data above) with:
- 7 Account instances (ids 1 through 7)
- 3 Province instances (ON, AB, BC)
- 3 City instances (Toronto, Vancouver, Calgary)


Then the rules containing 'within province' would read like:
-
Rule '1'
When 
Province($prov: province)
$a: Account(province == $prov)
Then
// accumulate sums on Checking and Visa accounts as Edson showed in
previous emails
End
-


The rule containing 'within province, within city' would have then:
-
Rule '3'
When
Province($prov: province)
  City($city: city, province = $prov)
$a: Account(province = $prov, city = $city)
Then
// accumulate sums on Checking and Visa accounts as Edson showed in
previous emails
-


Is this correct business object model to achieve the goal? Do I understand
correctly that the LHS statement:


Province($prov: province)
  City($city: city, province = $prov)
$a: Account(province = $prov, city = $city)


Can be read as:

For each province
For each city within the province
For each account for the given city and province



What 'guides' the order in which fact tuples are selected from the set of
all facts in the WorkingMemory? Can any particular sequence be guaranteed?

Thanks!

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


[rules-users] "not exists MyObject" - is it a valid LHS condition?

2007-02-09 Thread Olenin, Vladimir (MOH)
Hi,

 

I wonder if the combination of 'not' and 'exists' keywords is a valid one
and therefore the construct like

 

rule "myrule"

  when 

 not exist MyObject(param matches "somepattern")

  then

 System.out.println("Object for pattern 'somepattern' doesn't exisit");

End

 

Thanks.

 

Vlad

 

PS: basically I need to trigger a rule if some set of facts is NOT found and
I need to trigger it only once.

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


RE: [rules-users] Parse bug in predicate constraints?

2007-02-08 Thread Olenin, Vladimir (MOH)
Also, since everything in rules needs to be an Object, is there any plan to
make the operators deal with said Objects? That is, so I do not always have
to de-reference with my eval or predicate objects with intValue() or
floatValue() or whatever?  



Not a DROOLS expert, but from what I understand this is already possible now
as long as you are using Java 1.5 (which has autoboxing/autounboxing as part
of the language spec).

 

Vlad

 

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Justine Hlista
Sent: 08 February 2007 15:12
To: rules-users@lists.jboss.org
Subject: [rules-users] Parse bug in predicate constraints?

 

Should predicate constraints be sensitive to whitespace?? I have the
following rule with a predicate constraint:
rule "test"
when
valObj : MyValuesObject(a:aVal, b:bVal, c:cVal -> ((a.intValue() <
(1/780) * (b.intValue() + c.intValue()) && (b.intValue() + c.intValue()) >
50)
then
System.out.println("Alert condition met on obj:" + valObj);
end

Inserting whitespace into the predicate results in the following exception:

org.drools.rule.InvalidRulePackage: unknown:155:85 mismatched token:
[EMAIL PROTECTED],5226:5227='\r\n',<4>,155:85]; expecting type ')'
unknown:156:28 mismatched token: [EMAIL PROTECTED],5256:5256='(',<23>,156:28];
expecting type ')'

If instead I use an eval on the LHS, I can insert whitespace without an
exception.

In addition, I would like to know if there are any plans to simplify the
syntax for similar types of rules, as the above is extremely unwieldy for
the non-expert. 
For instance, I would vastly prefer to write the following: 

rule "test"
when
   valObj : MyValuesObject(a:aVal, b:bVal, c:cVal)
   (a < (1/780)*(b+c))
   ((b + c) > 50)
then
System.out.println("Alert condition met on obj:" + valObj); 
end


Also, since everything in rules needs to be an Object, is there any plan to
make the operators deal with said Objects? That is, so I do not always have
to de-reference with my eval or predicate objects with intValue() or
floatValue() or whatever?  

In our application, the user (i.e. not a drools or java expert) will be
writing the rules. The current syntax requirements for encoding the above
simple rule makes me very nervous about our users ever being able to use the
rules effectively. 

Thanks,
Justine






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


[rules-users] 3.2M1 - is it available?

2007-02-08 Thread Olenin, Vladimir (MOH)
Hi,

 

I think I've seen a message some time ago on the list mentioning that the
first milestone 3.2 release has been tagged in the CVS. Is it true? If so,
would this release be available somewhere on the site as a library download
(together with the documentation, at least for the new functionality). I've
just checked one benchmark (http://www.kbsc.com/Performance2006.xls
 ) and it seems like 3.2 version is
~ 3 times faster than 3.0... Very impressive, considering a bulk of new
functionality has been added as well.

 

Thanks.

 

Vlad

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


RE: [rules-users] [Column(f1=='v1', f2=='v2')] vs [Column(f1= ='v1') Column(f2== 'v2')]

2007-02-07 Thread Olenin, Vladimir (MOH)
Hi, Edson.

Thanks for the explanation. Just wanted to clarify one thing. If I have a
set of following Column fact objects and I put then into workspace using the
'identity' mode (below are only field values the facts are initialized with,
one per line, each line is a separate Column fact):

1) f1='v1', f2='v1'
2) f1='v1', f2='v11'
3) f1='v1', f2='v2'
4) f1='v2', f2='v2'
5) f1='v11', f2='v2'
6) f1='v11', f2='v22

then the condition

Column(f1=='v1')
Column(f2=='v2')

will select facts exactly 5 facts: 1, 2, 3, 4, 5, but NOT 6, correct?

Won't the condition above then be the same as:

Column(f1=='v1') or Column(f2=='v2') ?

Thanks.

Vlad

PS: any feedback/hints on some other questions I've sent earlier today would
be very much appreciated as well!


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 07 February 2007 13:15
To: Rules Users List
Subject: Re: [rules-users] [Column(f1=='v1', f2=='v2')] vs [Column(f1=='v1')
Column(f2== 'v2')]


Vlad,

The constructions are semantically different. In 3.0.x as default, 
JBoss Rules will not allow the same fact to match more than one column. 
So if you write:

Column(f1=='v1')

Column(f2=='v2')


Your rule will only match if there are 2 different objects that each 
match one of the constraints. While, if you write:

Column(f1=='v1', f2=='v2')


   It will require a single object that matches both constraints.

   Also, the optimizations (indexing, hashing, etc) are done on a field 
constraint basis.

   So, if you have one rule with :

 Column(f1=='v1', f2=='ONE_VAL')


   And   another rule with:

 Column(f1=='v1', f2=='ANOTHER_VAL')


   The constraint f1=='v1' will be evaluated only once. Although, to 
help optimization, you must keep the constraints that repeat over 
multiple patterns as the first constraints for each collumn, in the same 
order.

   []s
   Edson


Olenin, Vladimir (MOH) wrote:

>Hi,
>
> 
>
>I wonder what is the difference (performance-wise, etc) between these two
>constructs:
>
> 
>
>Column(f1=='v1', f2=='v2')
>
> 
>
>And
>
> 
>
>Column(f1=='v1')
>
>Column(f2=='v2')
>
> 
>
>?
>
> 
>
>Both of them should select the same 'Column' facts (where Column.f1=='v1'
&&
>Column.f2='v2'), correct? Is one construct more preferable then another
one?
>Does JBossRules hash only the evaluation result of the 'full column' OR
>individual field constraints as well? From what I understand, only the full
>'Column' is defined as an (alpha?) node while individual constraints within
>the node can not be further optimized, correct? 
>
> 
>
>Meaning, if I have another condition somewhere like this:
>
> 
>
> Column(f1=='v1', f2=='ANOTHER_VAL')
>
> 
>
>[f1=='v1'] constraint would have to be reevaluated again, while if I define
>constraints through two 'separate' columns and the new constraint as
>
> 
>
> Column(f1=='v1)
>
> Column(f2=='ANOTHER_VAL')
>
> 
>
>only the new constraint would have to be reevaluated. Do I understand it
>right?
>
> 
>
>Thanks!
>
> 
>
>Vlad
>
>___
>rules-users mailing list
>rules-users@lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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


[rules-users] decision table - access to params $1, $2, ... as an 'array' + esc aping ',' in field values?

2007-02-07 Thread Olenin, Vladimir (MOH)
Hi,

 

I wonder if it's possible to access parameters in the decision table
template as an array? In other words, instead of addressing individual
parameters through numbered notation (field1 > $1, field2 > $2) is it
possible to do something like this (
HelperClass.checkAllMyFields($parameters) ), where 'checkAllMyFields' method
accepts an array of objects/strings?

 

Another slightly related question is whether it is possible to use 'comma'
as a character in the field value? In other words, if I have a string
"abcd,efg" and I want it to be interpreted as a single parameter, how do I
escape ',' character?

 

Thanks.

 

Vlad

 

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


[rules-users] [Column(f1=='v1', f2=='v2')] vs [Column(f1=='v1') Column(f2== 'v2')]

2007-02-07 Thread Olenin, Vladimir (MOH)
Hi,

 

I wonder what is the difference (performance-wise, etc) between these two
constructs:

 

Column(f1=='v1', f2=='v2')

 

And

 

Column(f1=='v1')

Column(f2=='v2')

 

?

 

Both of them should select the same 'Column' facts (where Column.f1=='v1' &&
Column.f2='v2'), correct? Is one construct more preferable then another one?
Does JBossRules hash only the evaluation result of the 'full column' OR
individual field constraints as well? From what I understand, only the full
'Column' is defined as an (alpha?) node while individual constraints within
the node can not be further optimized, correct? 

 

Meaning, if I have another condition somewhere like this:

 

 Column(f1=='v1', f2=='ANOTHER_VAL')

 

[f1=='v1'] constraint would have to be reevaluated again, while if I define
constraints through two 'separate' columns and the new constraint as

 

 Column(f1=='v1)

 Column(f2=='ANOTHER_VAL')

 

only the new constraint would have to be reevaluated. Do I understand it
right?

 

Thanks!

 

Vlad

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


[rules-users] predicate vs return value expression - what's the difference?

2007-02-05 Thread Olenin, Vladimir (MOH)
Hi,

 

I'm reading through DROOLS manual and can't understand the difference /
explanations regarding predicate expression (Figure 3.17) and return value
expression (Figure 3.18). The manual gives two examples of the same thing
done two different ways:

 

 

Predicate expression:

 

Person( girlAge : age, sex = "F" )
Person( boyAge : age -> ( girlAge.intValue() == boyAge.intValue() + 2 ), sex
= 'M' )

 

 

Return value expression:

 

Person( girlAge : age, sex == "F" )
Person( age == ( new Integer(girlAge.intValue() + 2) ), sex == 'M' )

 

 

 

While the 'return value' expression is more or less clear, I can't
understand the semantics of 'predicate' ('->') operator. Can anyone decode
this? What's the difference between the two? When each of the ways should be
used and why?

 

Thanks!

 

Vlad

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


RE: [rules-users] advice is needed: rule based processing of inte r connected facts

2007-02-02 Thread Olenin, Vladimir (MOH)
Hi, Edson.

Thanks A LOT for the explanations - that significantly cleared things up.

So, would it be a correct thing to say that DROOLS is a complete equevalent
of SQL? How more/less optimized is it in comparison with relational DB
implementation (eg, in the example of embedded select statement you gave)? I
know it might sound like trying to compare apples & oranges, but providing
that I'd have to run 
  - either 400 similar SQL queries with different combination of field
constraints
  - or process 400 rules in the rule engine (the same constrains would
apply)

how that might compare?

Is there any good book on formulating / optimizing rules that you can
recommend?

Thanks.

Vlad


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 02 February 2007 17:09
To: Rules Users List
Subject: Re: [rules-users] advice is needed: rule based processing ofinter
connected facts


   Vlad,

   That's what the engine does... it's like SQL. Imagine you have an 
"Account" table that has a "number" field. You could write a SQL like:

select * from account a
where (number % 10) < 5
   and number < 9000
   and 0 = (select count(*) from account b where b.number = 
(a.number+1000) )

   I'm writing it from my head, so there may be syntax errors... :) but 
I think you got the idea.
   You don't say write an algorithm saying:

"for each record in account table..."

   The SQL engine iterates the table for you.

   The same happens with Rule Engines. In the case of JBoss Rules, 
instead of tables, you have classes (Account). Instead of columns, you 
have class attributes (number).
   If you write a rule like this:

rule "missing accounts"
when
$a : Account( $number : number -> ( $number % 10 < 5 ), number < 9000  )
not Account( number == ( $number + 1000 ) )
then
   // $a does not have a matching primary account
end

   You are saying the engine to iterate over all Account instances, and 
for each of them bind the variable and apply constraints, and when a 
full match is found, the consequence is executed.

   []s
   Edson

 

Olenin, Vladimir (MOH) wrote:

>Hi, Edson,
>
>I was going through your rule sniplets and I couldn't understand very well
>one thing:
>
>-
>when
>$a : Account( $number : number -> ( number % 10 < 5 ), number < 9000  )
>not Account( number == ( $number + 1000 ) ) then
>-
>
>The 'number' variable refers to the 'fact' in the working memory, correct?
>Basically it means I have only one particular number to compare ALL
accounts
>(from the data sheet) with?
>
>If so, it's not what I actually need to achieve. I need to compare all
>accounts with 'each other', all of them coming from the same data sheet.
So,
>I guess it has to be an iteration through all the facts, comparing each
fact
>with every other one.
>
>Or is the sniplet above does exactly that? Ie, iterating through all the
>facts?
>
>In other words, I'd be initializing working memory ONLY with the facts
>below:
>
>  for (Iterator it = accountsFromDataSheet.iterator(); it.hasNext(); ) {
>Account account = (Account)it.next();
>workingMemory.assertObject(account);
>  }
>
>After which the rules must operate on the facts loaded...
>
>Thanks.
>
>Vlad
>
>
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
>Sent: 02 February 2007 11:13
>To: Rules Users List
>Subject: Re: [rules-users] advice is needed: rule based processing ofinter
>connected facts
>
>   Hi Vlad,
>
>   This is a case where you can apply business rules with good results.
>   In the end, it all depends on how you model your Business Objects, 
>but lets get some examples:
>
>  
>
>>1) for all primary accounts 'zxxy' where y < 5, there should be a matching
>>primary account '(z+1)xxy'
>>- [this one is true for the dataset above]
>>
>>
>
>My understanding is that you are validating your accounting plan, so 
>you may have an Account object in your model. So, if you want to report 
>inconsistencies, you can do something like:
>
>rule "missing accounts"
>when
>$a : Account( $number : number -> ( number % 10 < 5 ), number < 9000  )
>not Account( number == ( $number + 1000 ) )
>then
>   // $a does not have a matching primary account
>end
>
>   Please, note that the "formulas" I used above may not be the best way 
>to do it... they are only a possible representation of what you said.
>
>  
>
>>2) sumOfDebit(primary + matching_primary + secondary_account) -
>>sumOfCredit(primary + matching

RE: [rules-users] advice is needed: rule based processing ofinter connected facts

2007-02-02 Thread Olenin, Vladimir (MOH)
Hi, Edson,

I was going through your rule sniplets and I couldn't understand very well
one thing:

-
when
$a : Account( $number : number -> ( number % 10 < 5 ), number < 9000  )
not Account( number == ( $number + 1000 ) ) then
-

The 'number' variable refers to the 'fact' in the working memory, correct?
Basically it means I have only one particular number to compare ALL accounts
(from the data sheet) with?

If so, it's not what I actually need to achieve. I need to compare all
accounts with 'each other', all of them coming from the same data sheet. So,
I guess it has to be an iteration through all the facts, comparing each fact
with every other one.

Or is the sniplet above does exactly that? Ie, iterating through all the
facts?

In other words, I'd be initializing working memory ONLY with the facts
below:

  for (Iterator it = accountsFromDataSheet.iterator(); it.hasNext(); ) {
Account account = (Account)it.next();
workingMemory.assertObject(account);
  }

After which the rules must operate on the facts loaded...

Thanks.

Vlad


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 02 February 2007 11:13
To: Rules Users List
Subject: Re: [rules-users] advice is needed: rule based processing ofinter
connected facts

   Hi Vlad,

   This is a case where you can apply business rules with good results.
   In the end, it all depends on how you model your Business Objects, 
but lets get some examples:

> 1) for all primary accounts 'zxxy' where y < 5, there should be a matching
> primary account '(z+1)xxy'
> - [this one is true for the dataset above]

My understanding is that you are validating your accounting plan, so 
you may have an Account object in your model. So, if you want to report 
inconsistencies, you can do something like:

rule "missing accounts"
when
$a : Account( $number : number -> ( number % 10 < 5 ), number < 9000  )
not Account( number == ( $number + 1000 ) )
then
   // $a does not have a matching primary account
end

   Please, note that the "formulas" I used above may not be the best way 
to do it... they are only a possible representation of what you said.

> 2) sumOfDebit(primary + matching_primary + secondary_account) -
> sumOfCredit(primary + matching_primary + secondary_account) must be = 0
> - [this one is also true]

   Here, it seems you are refering to a set of transactions, so you 
might have a set of transaction objects to represent the transaction in 
your sample. So, a possible representation would be:

rule "transaction consistency"
when
Transaction( $id : id )
$credits: Double( )
  from accumulate( TransactionEntry( id == $id, operation == 
"credit", $amount : amount ),
  init( double balance = 0 ),
  action(  balance += $amount ),
  result( new Double( balance ) ) );
$debits: Double( )
  from accumulate( TransactionEntry( id == $id, operation == 
"debit", $amount : amount ),
  init( double balance = 0 ),
  action(  balance -= $amount ),
  result( new Double( balance ) ) );
eval( ! $credits.equals( $debits ) )
then
   // inconsistency for transaction $id
end
   
   Again, this is not the only way or the best way... it is just an example.

   Also, for the above examples, I used syntax/features of the jbrules 
3.1 version.

   Hope it helps.

   []s
   Edson
  

Olenin, Vladimir (MOH) wrote:

>Ok, approx data set:
>
>Primary Account | Secondary Account | Operation | Amount | Type | Owner
>
>0001|   | debit | 100| A| M
>1001|   | credit| 80 | A| F
>1001|   | credit| 20 | X| F
>0002| 2002  | debit | 50 | B| M
>2002|   | dedit | 20 | B| M
>1002|   | credit| 70 | C| M
>
>Rules:
>
>1) for all primary accounts 'zxxy' where y < 5, there should be a matching
>primary account '(z+1)xxy'
> - [this one is true for the dataset above]
>2) sumOfDebit(primary + matching_primary + secondary_account) -
>sumOfCredit(primary + matching_primary + secondary_account) must be = 0
> - [this one is also true]
>3) OwnerOf (primary_account, matching_primary, secondary_account) must be
of
>the same gender
> - [this one is 

RE: [rules-users] advice is needed: rule based processing ofinter connected facts

2007-02-02 Thread Olenin, Vladimir (MOH)
Thanks for the tip, Edson.

Looks promising. Can you give some more details on the following:

- JBRules 3.1 is the DROOLS 3.1 (which is currently under dev-t), correct?

- Is there a way to achieve the same functionality using existing release
(unless DROOLS 3.1 would be released within next month or so)?

- The '$' prefixed variables have some special meaning, correct? What
section of the manual can I find more details on what it means? (is it part
of Drools 3.0 or 3.1 only?)

- Performance-wise, would DROOLS (or any other RETE based engine) give any
substantial benefit vs plain 'line-by-line' processing of the rules (eg,
implemented in SQL, providing facts are loaded from the DB)? Ie, putting
aside 'configurability' aspect. And providing there are around 400
'templated' rules, each having ~15 fields/conditions to be analyzed? I can
understand how DROOLS can optimize 'static' network (when facts are
evaluated against static conditions), but not sure if the same would be
valid when facts are evaluated against each other.

Thanks.

Vlad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 02 February 2007 11:13
To: Rules Users List
Subject: Re: [rules-users] advice is needed: rule based processing ofinter
connected facts

   Hi Vlad,

   This is a case where you can apply business rules with good results.
   In the end, it all depends on how you model your Business Objects, 
but lets get some examples:

> 1) for all primary accounts 'zxxy' where y < 5, there should be a matching
> primary account '(z+1)xxy'
> - [this one is true for the dataset above]

My understanding is that you are validating your accounting plan, so 
you may have an Account object in your model. So, if you want to report 
inconsistencies, you can do something like:

rule "missing accounts"
when
$a : Account( $number : number -> ( number % 10 < 5 ), number < 9000  )
not Account( number == ( $number + 1000 ) )
then
   // $a does not have a matching primary account
end

   Please, note that the "formulas" I used above may not be the best way 
to do it... they are only a possible representation of what you said.

> 2) sumOfDebit(primary + matching_primary + secondary_account) -
> sumOfCredit(primary + matching_primary + secondary_account) must be = 0
> - [this one is also true]

   Here, it seems you are refering to a set of transactions, so you 
might have a set of transaction objects to represent the transaction in 
your sample. So, a possible representation would be:

rule "transaction consistency"
when
Transaction( $id : id )
$credits: Double( )
  from accumulate( TransactionEntry( id == $id, operation == 
"credit", $amount : amount ),
  init( double balance = 0 ),
  action(  balance += $amount ),
  result( new Double( balance ) ) );
$debits: Double( )
  from accumulate( TransactionEntry( id == $id, operation == 
"debit", $amount : amount ),
  init( double balance = 0 ),
  action(  balance -= $amount ),
  result( new Double( balance ) ) );
eval( ! $credits.equals( $debits ) )
then
   // inconsistency for transaction $id
end
   
   Again, this is not the only way or the best way... it is just an example.

   Also, for the above examples, I used syntax/features of the jbrules 
3.1 version.

   Hope it helps.

   []s
   Edson
  

Olenin, Vladimir (MOH) wrote:

>Ok, approx data set:
>
>Primary Account | Secondary Account | Operation | Amount | Type | Owner
>
>0001|   | debit | 100| A| M
>1001|   | credit| 80 | A| F
>1001|   | credit| 20 | X| F
>0002| 2002  | debit | 50 | B| M
>2002|   | dedit | 20 | B| M
>1002|   | credit| 70 | C| M
>
>Rules:
>
>1) for all primary accounts 'zxxy' where y < 5, there should be a matching
>primary account '(z+1)xxy'
> - [this one is true for the dataset above]
>2) sumOfDebit(primary + matching_primary + secondary_account) -
>sumOfCredit(primary + matching_primary + secondary_account) must be = 0
> - [this one is also true]
>3) OwnerOf (primary_account, matching_primary, secondary_account) must be
of
>the same gender
> - [this one is false - 0001 owner must be 'F'

RE: [rules-users] advice is needed: rule based processing ofinter connected facts

2007-02-02 Thread Olenin, Vladimir (MOH)

Ok, approx data set:

Primary Account | Secondary Account | Operation | Amount | Type | Owner

0001|   | debit | 100| A| M
1001|   | credit| 80 | A| F
1001|   | credit| 20 | X| F
0002| 2002  | debit | 50 | B| M
2002|   | dedit | 20 | B| M
1002|   | credit| 70 | C| M

Rules:

1) for all primary accounts 'zxxy' where y < 5, there should be a matching
primary account '(z+1)xxy'
 - [this one is true for the dataset above]
2) sumOfDebit(primary + matching_primary + secondary_account) -
sumOfCredit(primary + matching_primary + secondary_account) must be = 0
 - [this one is also true]
3) OwnerOf (primary_account, matching_primary, secondary_account) must be of
the same gender
 - [this one is false - 0001 owner must be 'F']

 The kind of the rules above... The dataset is more complex and the
rules are a bit more involved, but this should give an idea.

Thanks for all suggestions!

Vlad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael Rhoden
Sent: 01 February 2007 17:49
To: 'Rules Users List'
Subject: RE: [rules-users] advice is needed: rule based processing
ofinterconnected facts

Can you post a couple of example conditions with a dataset you want to
check?

-Michael

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Olenin, Vladimir
(MOH)
Sent: Thursday, February 01, 2007 4:04 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] advice is needed: rule based processing
ofinterconnected facts

Hi,

 

I need some pointer as to where to start with the problem below.

 

The system should be able to validate the balancing data based on around 400
different rules. To simplify the task, the data facts are essentially the
debit/credit transactions on different accounts. The rules describe the
correlation between different facts:

-  eg, all debit transactions minus all credit transaction must be
equal 0

-  if one account got credited, there should be another account
(within the same dataset) which was debited

-  if there are accounts starting with some letter combination,
there also should be

-  etc

 

In other words, each rule describes

-  the subset of facts to be analyzed

-  the rules to be checked against this subset

 

It seems basically like each fact is a set of Account Number, Transaction
Type, Transaction Amount information, Secondary Account Number (which
sometimes needs to be validated against some other account number within the
same data set). But I couldn't find a way to relate between multiple data
facts.

 

On one hand rule engine seems to be a good solution in here, but I'm not
sure how to deal with 'dynamic selection' of the subset of facts. Can this
kind of task be reformulated somehow?

 

Any pointers into the DROOLS documentation or hints on a general approach
would be greatly appreciated!

 

Thanks.

 

Vlad

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



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


[rules-users] advice is needed: rule based processing of interconnected facts

2007-02-01 Thread Olenin, Vladimir (MOH)
Hi,

 

I need some pointer as to where to start with the problem below.

 

The system should be able to validate the balancing data based on around 400
different rules. To simplify the task, the data facts are essentially the
debit/credit transactions on different accounts. The rules describe the
correlation between different facts:

-  eg, all debit transactions minus all credit transaction must be
equal 0

-  if one account got credited, there should be another account
(within the same dataset) which was debited

-  if there are accounts starting with some letter combination,
there also should be

-  etc

 

In other words, each rule describes

-  the subset of facts to be analyzed

-  the rules to be checked against this subset

 

It seems basically like each fact is a set of Account Number, Transaction
Type, Transaction Amount information, Secondary Account Number (which
sometimes needs to be validated against some other account number within the
same data set). But I couldn't find a way to relate between multiple data
facts.

 

On one hand rule engine seems to be a good solution in here, but I'm not
sure how to deal with 'dynamic selection' of the subset of facts. Can this
kind of task be reformulated somehow?

 

Any pointers into the DROOLS documentation or hints on a general approach
would be greatly appreciated!

 

Thanks.

 

Vlad

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