[rules-users] unsubscribed from the rules-users mailing list

2014-06-23 Thread Wolfgang Laun
Friends,

this is to let you know that I have done as the subject says.

I'd like to thank all that have contributed for their continuing
efforts. As for myself: I think that this is a good moment to retire,
with my rapidly diminishing capability of understanding what's going
on in Guvnor, Optaplanner and other newfangled extensions. Hitting the
delete button on some incoming email has been the one thing I've
managed to do faithfully, and frequently.

Thanks again, and it's been *very* nice meeting you.

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


Re: [rules-users] Comparing Objects of same class.

2014-06-19 Thread Wolfgang Laun
This is one of the scenarios that can be handled using CEP (Complex
Event Processing) - basically rule logic with some extensions to make
time based reasoning more convenient. In Drools, you have @event
to declare a fact type as an event type, temporal operators to
establish temporal relations between events, windows to select
recently arrived subsets of facts, etc. Much depends on whether you
need to handle this in real time or whether it's going to be handled
over a bulk of historic data.

All my hints on mapping facts to days are useless - you may have to
use floating intervals or an approach that's triggered by the first
smell of a certain crime...

-W



On 18/06/2014, naresh.t nareshthota...@gmail.com wrote:
 Dear Wolfgang, Thanks for your patience and understandings.

 Let me clear our requirement. Actually we are not working any student
 psychology thing. I thought to simplify the problem in terms of Student
 example but it is getting complicated.

 What we are trying to achieve is...
 We have some RAW logs(windows event logs like login success, login failed,
 bad user name and password etc., along with date and time) in our DB.

 We are trying get trend of some particular events like bad user name and
 password. If these type of events are happening in less span of time, then
 we will find those user names and do some activity on them.

 In our existing application, we have achieved this by using java with hard
 coded inputs. Means we are getting those events, if any 5 events occurred
 in
 3 minutes.

 Now we are trying to add some dynamism for these type of requirements. We
 are exploring Drools Rule Engines to check that is it compatible with these
 type of rules. If you have any other Rule Engines in your mind, please
 suggest us.

 Thanks
 Naresh



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Comparing-Objects-of-same-class-tp4030073p4030088.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Noob question: graph searching, query, root node for a given node

2014-06-18 Thread Wolfgang Laun
Terms like root and parent are used with trees. You might call
these nodes nodes with indegree 0.
-W


On 18/06/2014, Borris bor...@chaos.org.uk wrote:
 Good question. I'm supporting a graph rather than a tree, so theoretically
 there could be more than one node that has no parents. But in my particular
 use case I am constraining the data so that there is never more than one
 root node.

 So how to find the root node (singular) from an arbitrary node in the graph
 is my goal.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Noob-question-graph-searching-query-root-node-for-a-given-node-tp4030091p4030096.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Comparing Objects of same class.

2014-06-17 Thread Wolfgang Laun
What have you tried so far?

And, please, clarify what you mean by any 5 in 2 days. For
instance: If A, B, C, D, E, F join on 5/24, is this a match? And if G,
H, J join additionally on 5/25, is this another match?

-W

On 17/06/2014, naresh.t nareshthota...@gmail.com wrote:
 HI Team,

 We came in situation where we need to compare our objects of same class.

 For example, we have a class like SampleData.java. It has fields like 1) No
 2) Student Name 3) DOJ(date of join)

 Now, we want to write a Rule to get the Student Details like

 1)  if any 5 students joined in 2 days of span

 This rule might changed dynamically like for now it is 2 days but in future
 it may be 1 day or 3 days etc.,

 Please provide any suggestions on this...

 Thanks  Regards
  Naresh




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Comparing-Objects-of-same-class-tp4030073.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Comparing Objects of same class.

2014-06-17 Thread Wolfgang Laun
Let S be the (nonempty) set of all students and d the length
of the span of days. There exists a student s0 so that s0.doj
is the minimum over all S. Then accumulate and count students
x over S so that s0.doj = x.doj and x.doj  s0.doj + d. If this
count exceeds the threshold t: display the students. Finally,
remove all students y from S where y.doj = s0.doj.

Repeat until S is empty.

I don't see any particular reason for doing this in Drools,
although it's feasible with just a handful of rules. But it is
a ridiculously simply exercise in Java.

Does this have any practical value? Students' behaviour is
notoriously erratic. Is this for a brand new branch of
behavioural psychology?!

-W




On 17/06/2014, naresh.t nareshthota...@gmail.com wrote:
 Hi,

 more details...

 lets take a rule like If any 5 students joined in 5 days of span...

 NoNameDOJ
 1   A*5/24*
 2   B* 5/25*
 3   C *5/27*
 4   D *5/23*
 5   E 5/30
 6   F 5/20
 7   G 5/15

 If we take, A,B,C and D details, these 4 students are joined in =5 days of
 span(lowest date :-D:5/23 and highest date :-c:5/27 -- diff is 4 days).
 If any other student joined in these =5 days (5/23 to 5/27 ) then we need
 those all 5 students details.

 If we take F, A, B and D, these 4 students also joined in = 5 days...but
 no.of 5 students condition is missing.


 As we said we are able to work on static rules like if student joined
 =5/23
  !=5/30 etc.

 Thanks  Regards
  Naresh






 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Comparing-Objects-of-same-class-tp4030073p4030079.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Drools calculation of a date function

2014-06-16 Thread Wolfgang Laun
Simply write a (static) Java function - it can be easily incorporated
into DRL code so that you can use it in rules.

BTW: This list is not a Programming Service. If you'd like to hire a
consultant: there are people on this list that might help you.

-W

On 16/06/2014, Ravi gravisand...@gmail.com wrote:
 Hi,

 I am new to drools. I want to write a function that accepts two strings
 and returns a date. The two strings are one for the payment frequency and
 the other for the payment day. Following are my requirements:

 1.If the payment frequency is daily, return current date
 2.If the payment frequency is weekly and the payment day is let's say
 Monday, and the current day is Monday, then return current date. If the
 current day is Monday and the payment day is Tuesday, return current date
 + 1. Likewise, if the payment day is Wednesday, return current date + 2.
 3.If the payment frequency is monthly and payment day is 15, retrieve the
 current month and current year and return MM-15-.
 Please help me write a function for this. Thank you so much in advance.


 ___
 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] Erratic behaviour of Drools

2014-06-15 Thread Wolfgang Laun
OK, it's a bug all right. 5.4.0 had some problems. It might be worth
trying a later 5.x version.
-W

On 15/06/2014, Poissy.B poiss...@gmail.com wrote:
 Yes it does fire if I comment either of them, and I get the exact same
 response.

 I am using Drools 5.4.0.Final runtime.

 Actually Products is the name property of an object of type
 DataObjectReference (wich implements ItemAwareElementAdapter). The point of
 providing the output was just to show you that the
 ListItemAwareElementAdapter returned by both getGivenResources() and
 getReceivedResources() is indeed not empty so the exists constraint
 should have been matched.

 Thanks!


 On Sun, Jun 15, 2014 at 2:06 PM, Wolfgang Laun wolfgang.l...@gmail.com
 wrote:

 See inline.

 On 15/06/2014, Poissy.B poiss...@gmail.com wrote:
  Hello,
 
  I am a little bit confused as I don't get what I am doing wrong. Here
  is
 my
  rule:
 
  **
  rule Exchange Pattern
  when
  $p2: ProcessAdapter()
  $mainProcess: ProcessAdapter( isMainProcess(), this!=$p2)
  MessageFlowAdapter ( fromProcess == $mainProcess,
  toProcess==$p2)
  MessageFlowAdapter ( fromProcess == $p2,
  toProcess==$mainProcess)
  exists ItemAwareElementAdapter( ) from
  $mainProcess.getReceivedResources($p2)
  exists ItemAwareElementAdapter( ) from
  $mainProcess.getGivenResources($p2)
  then
  System.out.println(** FOUND EXCHANGE PATTERN betwwen
  +$mainProcess.getParticipant().getName()+ AND
  +$p2.getParticipant().getName());
  System.out.println(Given:
 
 +$mainProcess.getGivenResources($p2)+$mainProcess.getGivenResources($p2).size());
  System.out.println(Received:
 
 +$mainProcess.getReceivedResources($p2)+$mainProcess.getReceivedResources($p2).size());
  System.out.println(Intersection:
 
 +$mainProcess.intersectGivenAndReceivedResourcesWithProcess($p2)+$mainProcess.intersectGivenAndReceivedResourcesWithProcess($p2).size());
  end
  **
 
  This rule is never fired, although I know it should.
 
  When I comment out the ONE OF the two exists constraints, I get this
  output:

 Does the rule fire when you comment out either exists conditional
 element,
 i.e., it doesn't matter which one is removed?

 Which Drools version are you using?

 -W

 
  **
  ** FOUND EXCHANGE PATTERN betwwen Amazon AND Ship.Comp.
  Given: [Products (ID:DataObjectReference_2)]1
  Received: [Products (ID:DataObjectRefeference_GEN7)]1
  Intersection: [Products (ID:DataObject_2)]1
  **

 I can't say that a display of fact type Products is clearly indicating
 the
 presence of an ItemAwareElementAdapter. That said, the rule shouldn't
 fire even with a single exists, so I assume this is an interface
 implemented
 by Products.

 
  From the output you can see that the rule should have been fired with
 the
  two exists constrains as both conditions are met, but it doesn't.
  I am kind of new to Drools so I may be doing an horrible mistake but
 google
  haven't been my friend so far. Any help will be very appreciated!
 
  Thanks.
  Anis
 
 ___
 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] Erratic behaviour of Drools

2014-06-15 Thread Wolfgang Laun
The basic rule is this: If modify is called on a fact it causes
reevaluation of all LHSs where facts of that type are used.

You may omit modify if the change does not have any effect on the
logic, and you may omit it if this particular change should be hidden
from the engine. (There's the use case of collecting facts A in a
Collection property of fact B with a rule combining a (new) A with a
B: clearly, modify of B would cause the rule to fire over and over
again, which might be prevented using no-loop - but other occurrences
of B might be reevaluated, too.)

A more selective reaction to modification is possible using the
property reactive feature - see the docs.

-W



On 15/06/2014, Poissy.B poiss...@gmail.com wrote:
 Thanks Wolfgang. Actually I kind of figured out how to fix it but am not
 sure why it is fixed.

 First to explain the context, this erratic rule belongs to a rule
 flow-group B that is executed right after another group (A).

 There is actually a rule in A that modifies $mainProcess, more
 specifically, it adds the actual ItemAwareElements that should be returned
 by the methods getGivenResources and getReceivedResources. However I did
 not enclose that in a modify statement. My point was that it is useless
 to let the WM know as that modification has no influence on group A rules.
 And I was thinking that it does not even matter for group B rules as I am
 playing with fact's internal properties and not the fact per se.
 (specifically: a HashSet having Set values).

 I guess I was wrong assuming all this. So my question is:
 - Do we need to use the modify statement whenever the state of an object
 from the working memory is changed? (even if the part of the state that
 changed is not relevant to the reasoner)
 - In other words, can we sometimes avoid the modify when manipulating facts
 to prevent the rules from being re-evaluated uselessly?

 Thanks!


 On Sun, Jun 15, 2014 at 3:59 PM, Wolfgang Laun wolfgang.l...@gmail.com
 wrote:

 OK, it's a bug all right. 5.4.0 had some problems. It might be worth
 trying a later 5.x version.
 -W

 On 15/06/2014, Poissy.B poiss...@gmail.com wrote:
  Yes it does fire if I comment either of them, and I get the exact same
  response.
 
  I am using Drools 5.4.0.Final runtime.
 
  Actually Products is the name property of an object of type
  DataObjectReference (wich implements ItemAwareElementAdapter). The
  point
 of
  providing the output was just to show you that the
  ListItemAwareElementAdapter returned by both getGivenResources() and
  getReceivedResources() is indeed not empty so the exists constraint
  should have been matched.
 
  Thanks!
 
 
  On Sun, Jun 15, 2014 at 2:06 PM, Wolfgang Laun
  wolfgang.l...@gmail.com
  wrote:
 
  See inline.
 
  On 15/06/2014, Poissy.B poiss...@gmail.com wrote:
   Hello,
  
   I am a little bit confused as I don't get what I am doing wrong.
   Here
   is
  my
   rule:
  
   **
   rule Exchange Pattern
   when
   $p2: ProcessAdapter()
   $mainProcess: ProcessAdapter( isMainProcess(), this!=$p2)
   MessageFlowAdapter ( fromProcess == $mainProcess,
   toProcess==$p2)
   MessageFlowAdapter ( fromProcess == $p2,
   toProcess==$mainProcess)
   exists ItemAwareElementAdapter( ) from
   $mainProcess.getReceivedResources($p2)
   exists ItemAwareElementAdapter( ) from
   $mainProcess.getGivenResources($p2)
   then
   System.out.println(** FOUND EXCHANGE PATTERN betwwen
   +$mainProcess.getParticipant().getName()+ AND
   +$p2.getParticipant().getName());
   System.out.println(Given:
  
 
 +$mainProcess.getGivenResources($p2)+$mainProcess.getGivenResources($p2).size());
   System.out.println(Received:
  
 
 +$mainProcess.getReceivedResources($p2)+$mainProcess.getReceivedResources($p2).size());
   System.out.println(Intersection:
  
 
 +$mainProcess.intersectGivenAndReceivedResourcesWithProcess($p2)+$mainProcess.intersectGivenAndReceivedResourcesWithProcess($p2).size());
   end
   **
  
   This rule is never fired, although I know it should.
  
   When I comment out the ONE OF the two exists constraints, I get
   this
   output:
 
  Does the rule fire when you comment out either exists conditional
  element,
  i.e., it doesn't matter which one is removed?
 
  Which Drools version are you using?
 
  -W
 
  
   **
   ** FOUND EXCHANGE PATTERN betwwen Amazon AND Ship.Comp.
   Given: [Products (ID:DataObjectReference_2)]1
   Received: [Products (ID:DataObjectRefeference_GEN7)]1
   Intersection: [Products (ID:DataObject_2)]1
   **
 
  I can't say that a display of fact type Products is clearly
  indicating
  the
  presence of an ItemAwareElementAdapter. That said, the rule shouldn't
  fire even with a single exists, so I assume this is an interface
  implemented
  by Products.
 
  
   From the output you can see that the rule should have been fired

Re: [rules-users] Analysing OutOfMemory, too many RightTuple

2014-06-12 Thread Wolfgang Laun
Before I say something, I should know:


* If an EvemetierCalculDHF accompanies an EvemetierData object: is
this a 1:1 relationship or are there several EvemetierData objects
tied to a single EvemetierCalculDHF?

* Is EvemetierCalculDHF.evemetier a Collection? (Probably yes if the
answer to the first question is several.

* Why is the (custom) evaluator sumWithNulls used here? One would
think that DIVIDE can be written so as never to return null.

* The extra CE Object(...) from WRAP_NULL($acc1) looks contrived. A
constraint on $acc1/sumWithNulls can be written within the accumulate.

* Personally, I abhor grappling with null (UN/WRAP_NULL). One should
think that it is possible to design objects in a way that avoids null
being returned by its getters. (Frequently, it is just a matter of a
little extra effort to think up a reasonable default value and write
the object initialisation accordingly.)

I can say one thing right away:

  $obj: EvemetierData() from $evCalcDHF.evemetier
  accumulate (  $src: EvemetierData (
 pere == $obj.niveau,... )

The first CE picks out *some* EvemetierData object (from a Collection
(?) see Q1). The accumulate collects lots of partially equal
EvemetierData objects. Now, if there is more than one EvemetierData in
that collection, a similar thing will happen, very likely, over and
over again, with the same subset of EvemetierData facts.

If a representative is required for matching a set of similar facts
in an accumulate, it is best practice to pick the representative using
a restrictive constraint, e.g., if it has a unique integer id
attribute, pick the one with the smallest id.

-W




On 11/06/2014, bvoisin benoit.voi...@igc-erp.com wrote:
 To help me understand what is happening in the WM, I've just made a analysis
 method (see below), scrutating all the RightTuples from the WM facts and
 showing some stats on the 5 biggest ones :

 I call it every 100 matchFired and it shows me info like:

 Biggest RightTuple types :
  - EvemetierData: RightTuple/NotNode[niveau == $niveau, suffixe == $suffixe]
 x *209346*
  - SuffixeMapDHF: RightTuple/JoinNode[id == $ev.suffixe] x 17610
  - EvemetierData: RightTuple/AccumulateNode[this == $obj.father] x 14145
  - EvemetierData: RightTuple/AccumulateNode[niveau == $obj.niveau,
 affperiode == $obj.affperiode, typeeve_id == $obj.typeeve_id, dteve ==
 $obj.dteve, $suffixeMap.toPhaseTOT != null  ( $suffixeMap.toPhaseTOT !=
 null  suffixe == $suffixeMap.toPhaseTOT.id )] x 14145
  - EvemetierData: RightTuple/NotNode[niveau == $niveau, suffixe == $suffixe,
 sources contains $source3] x 11316

 I clearly found my suspect N°1. Is there any pre-existing and better written
 methods to do this kind of research in drools ?

 Regards,
 Benoît

 Method to be called after each/N match fired or ... It uses Guava for the
 collections :

   private void analyzeWorkingMemoryTuples()
 {
 MultisetString keys = HashMultiset.create();

 for(FactHandle handle:kieSession.getFactHandles())
 {
 DefaultFactHandle factHandle = (DefaultFactHandle)handle;
 String
 factType=factHandle.getObject().getClass().getSimpleName();

 RightTuple rightTuple = factHandle.getFirstRightTuple();
 while(rightTuple!=null)
 {
 String key = factType + : RightTuple;
 BetaNode sink =
 (BetaNode)rightTuple.getRightTupleSink();
 if (sink!=null) {
 key+= / + sink.getClass().getSimpleName();
 key+=Arrays.toString(sink.getConstraints());
 }
 keys.add(key);
 rightTuple = rightTuple.getHandleNext();
 }
 }

 ArrayListMultiset.Entrylt;String entries =
 Lists.newArrayList(keys.entrySet());
 Collections.sort(entries, new
 ComparatorMultiset.Entrylt;String(){
 @Override
 public int compare(EntryString o1, EntryString o2)
 {
 return -Integer.compare(o1.getCount(), o2.getCount());
 }
 });
 String analysis = Joiner.on(\n -
 ).join(Iterables.limit(entries, 5));
 if (!analysis.equals(previousAnalysis))
 {
 logger.info(Biggest RightTuple types :\n -  + analysis);

 previousAnalysis = analysis;
 }
 }




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Analysing-OutOfMemory-too-many-RightTuple-tp4029988p4029993.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.

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

___
rules-users mailing list
rules-users@lists.jboss.org

Re: [rules-users] Analysing OutOfMemory, too many RightTuple

2014-06-12 Thread Wolfgang Laun
On 12/06/2014, bvoisin benoit.voi...@igc-erp.com wrote:

 I did not quite understand your last paragraph on a representative. Do
 you have an example I could study ?

Given a set of facts that match some constraints, and you want to
accumulate them in some way, this approach appears to achieve it:

Foo( $bar: bar == bar-x, ... )
accumulate( Foo( bar == $bar,... ); ...; ... )

But, obviously, there is more than one such Foo where bar == bar-x,
and hence the first CE matches more than once, while the accumulate
may not collect a set that's different each time. Details may vary, of
course, but there's no guarantee that each accumulate will be unique.

In order to have each set of Foo-facts accumulated only once, some
constraint must be exercised on the trigger Foo, e.g., making it
unique among all the candidates:

Foo( $id: id, $bar: bar == bar-x, ... )
not Foo( id  $id, $bar: bar == bar-x, ... )
accumulate( Foo( bar == $bar,... ); ...; ... )

Now, this particular accumulation occurs only once.

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


Re: [rules-users] How can we make the 'over window:time' parameter being configurable?

2014-06-11 Thread Wolfgang Laun
It requires a little work (and the timestamp should be an event attribute) to
write rules to select facts being in a dynamic window, but it can be done.

-W


On 11/06/2014, Matteo Mortari matteo.mort...@gmail.com wrote:
 Hi,
 I'm quite intrigued by this question also myself, I would like to know more
 about what you mean by configurable ?

 For instance you can have the window 'declared'

 declare window SensorReading30s
 SensorReading() over window:time(30s) from entry-point DEFAULT
 end

 and also use this custom window name in the accumulate rule.

 Do you mean by configurable , known at runtime and varying?

 A solution I can think of in that case, a specific rule with the
 housekeeping style; but I'm quite worried about performance issues may
 arise.

 Just my 2c, hope maybe helps?


 On Tue, Jun 10, 2014 at 4:18 AM, moonbeam jplabe...@magenta.ca wrote:

 How can we make the 'over window:time' parameter being configurable?

 Something similar to the following rule (that does not compile at all).
  See
 the $windowTime variable.


 declare TemperatureThreshold
 windowTime : String = 30s
 max : long = 70
 end

 declare SensorReading
 @role( event )
 temperature : String = 40
 end

 rule Sound the alarm in case temperature rises above threshold
 when
TemperatureThreshold( $max : max, $windowTime : windowTime )
Number( doubleValue  $max ) from accumulate(
SensorReading( $temp : temperature ) over window:time( $windowTime ),
average( $temp ) )
 then
// sound the alarm
 end





 --
 View this message in context:
 http://drools.46999.n3.nabble.com/How-can-we-make-the-over-window-time-parameter-being-configurable-tp4029932.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.

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

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


Re: [rules-users] Adding eval on rule cause it to run in infinite loop

2014-06-11 Thread Wolfgang Laun
Wrapping a constraint into eval (for which there's absolutely no need)
hides the visibility of the attribute condIsNUMERIC to the observer that
would avoid the reactivation.

-W

On 11/06/2014, brachi brach...@sapiens.com wrote:
 for this Drools Fact Type:

 /*
 declare DvFacts0
 @propertyReactive
 IsNUMERIC: Double
 condIsNUMERIC: Double
 end*/

 I have this rule:

 /*rule 1
 salience -1
 agenda-group agenda1
 when
   $condIsNUMERIC: DvFacts0(eval(condIsNUMERIC == null ) )
   $conclusion: DvFacts0( )
 then
   modify($conclusion){setIsNUMERIC(1.0)};
 end*/

 the rule hit just one time without the eval clause, adding the eval cause
 this rule to run in infinite loop.
 have an idea?
 put attention that I add  @propertyReactive on the DVFacts0 to avoid this.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Adding eval on rule cause it to run in infinite loop

2014-06-11 Thread Wolfgang Laun
On 11/06/2014, Chidambaran Subramanian chi...@gmail.com wrote:
 What is the issue in using the no-loop directive?

Expert manual, Subsection Fine grained property change listeners

-W


 Regards
 Chiddu


 On Wed, Jun 11, 2014 at 5:09 PM, Davide Sottara dso...@gmail.com wrote:

 Could you please show the conditions for which you need the eval?
 And which version are you using? As far as I know, eval is rewritten and
 removed internally in latest versions, so there shouldn't be a
 difference.


 On 06/11/2014 12:34 PM, brachi wrote:
  I need the eval.
  I have some rules that doesn't hit correctly, just if I put eval around
 the
  condition.
  but eval makes the rules to run in an infinite loop.
 
 
 
 
  --
  View this message in context:
 http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029979.html
  Sent from the Drools: User forum mailing list archive at Nabble.com.
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 

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


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


Re: [rules-users] Adding eval on rule cause it to run in infinite loop

2014-06-11 Thread Wolfgang Laun
On 11/06/2014, brachi brach...@sapiens.com wrote:
 example of rule that doesn't work without eval:

 /*rule 1
 salience -1
 agenda-group agenda1
 when
 $conclusion: supportFT()

Where's the eval?


 then
   if($conclusion.getValue()==null){
   modify($conclusion) { setValue(new ArrayList())};
   }
   $conclusion.getValue().add(supportedValue);
 modify($conclusion) { setValue($conclusion.getValue()) };

You might use a simple update() here.

  end


 rule 2
 salience -2
 agenda-group agenda2
 when
 supportFT(Operators.containsAny(value,new
 String[]{supportedValue,otherValue}))

This can be written using the clearer and cleaner syntax

  supportFT( value in (supportedValue,otherValue) )

   $conclusion: ConclusionFt()

Moreover, this should contain the constraint

   $conclusion: ConclusionFt( value != success )

 then
   modify($conclusion){setValue(success)};

Here, ConclusionFt's attribute value is a simple String, but in that
other rule it is set to an ArrayList.

-W

 end*/

 rule 2 doesn't hit, works only with eval in rule 2.
 in this example I can add eval, because the Fact Types model is different,
 so the rule doesn't reevaluated.
 because I had this case, I decided to add eval for all constraints, but
 unfortunately I had an infinite loop.




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-infinite-loop-tp4029966p4029984.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Analysing OutOfMemory, too many RightTuple

2014-06-11 Thread Wolfgang Laun
Most of the time, a look on a (representative) sample of the rules is
enough for some watchers of this list to drop a few pointers.

There are some Best Practices, but people tend to come up with new
counter-examples ;-)

-W


On 11/06/2014, bvoisin benoit.voi...@igc-erp.com wrote:
 Hi all,

 With my set of rules and data, I get OutOfMemory issues. It works fine with
 smaller sets of Data.

 Looking with a HeapDump analyzer, I found that there was thousands of
 RightTuples. In a previous run, before some rules fixes, I also add tons of
 JoinNodeLeftTuple's.
 They seem to come from poorly written rules; unfortunately, I find it quite
 difficult to find and correct the conditions/rules causing these tons of
 RightTuple.

 Is there any analysis option/tool that can give information on the Left Hand
 Side (tuples and sinks), or is there any BestPractices on how to correct the
 rules to limit this behavior?

 I use Drools 6.1.0.Beta4, with Phreak enabled, but had similary issues with
 6.0.0 or 6.0.1

 Regards,
 Benoît



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Analysing-OutOfMemory-too-many-RightTuple-tp4029988.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.

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

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


[rules-users] Are there second-rate fact types?

2014-06-10 Thread Wolfgang Laun
Consider:

   class Foo { /*...*/ }

   rule checkFoo
   when
  Foo( noSuchField  0 )
   then ... end

DRL compilation reports an error (Error: unable to resolve method ...)
and identifies rule, line and column, which is fine.

Now let's look at:

   import java.util.ArrayList;
   rule checkArrayList
   when
  ArrayList( noSuchField  0 )
   then ... end

The same DRL compiler (checked with 5.5.0 and 6.0.0) accepts this, and
there is a nasty exception thrown at runtime. This is inconvenient,
since the exception can be thrown by any code inserting an ArrayList
object, and the faulty rule isn't identified.

Why are certain classes second-rate?

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


Re: [rules-users] Are there second-rate fact types?

2014-06-10 Thread Wolfgang Laun
On 10/06/2014, Davide Sottara dso...@gmail.com wrote:
 java.util.Collections (and descendants) are not @typesafe by default,
 I'll check the reason for that.

OK.

 More generally, if a fact is declared as not @typesafe, the runtime
 failure should be more graceful.

But (according to you)  java.util.Collections is *not* @typesafe, and
this runtime failure cannot be called graceful.

Can a java.util.X be declared as @typesafe? If so, how? Is any of this
documented anywhere?

-W

 Davide

 On 06/10/2014 01:26 PM, Wolfgang Laun wrote:
 Consider:

class Foo { /*...*/ }

rule checkFoo
when
   Foo( noSuchField  0 )
then ... end

 DRL compilation reports an error (Error: unable to resolve method ...)
 and identifies rule, line and column, which is fine.

 Now let's look at:

import java.util.ArrayList;
rule checkArrayList
when
   ArrayList( noSuchField  0 )
then ... end

 The same DRL compiler (checked with 5.5.0 and 6.0.0) accepts this, and
 there is a nasty exception thrown at runtime. This is inconvenient,
 since the exception can be thrown by any code inserting an ArrayList
 object, and the faulty rule isn't identified.

 Why are certain classes second-rate?

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


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

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


Re: [rules-users] Are there second-rate fact types?

2014-06-10 Thread Wolfgang Laun
The primary concern is not so much type safety but the absence of
the check of the name being defined as a getter or class member.

Also, (if I understand the poster correctly) in 5.0.0 the DRL compiler
was able to flag a non-existent member in ArrayList. Three cheers to
not breaking backwards compatability.

Note that even when you abstain from inserting collections as
first-order facts, you'll still need them, e.g., for a from collect.

-W

On 10/06/2014, Mark Proctor mproc...@codehaus.org wrote:
 The feature was more important when we didn't allow casting,  but people
 still wanted to work with Maps and Lists.
 Map( this[key].age  30)

 Collections where defaulted to typefalse(false)

 Now that we support inline casts, it can be argued that things should always
 be type safe:
 Map( this[key]#Person.age  30 )

 It's hard to change this now, without breaking backwards compatability.

 The docs don't say that it's defaulted to false for collections, only that
 it's useful for Collections. Someone want to submit a pull request fix for
 this?

 4.7.2.1.2. @typesafe( boolean )

 By default all type declarations are compiled with type safety enabled;
 @typesafe( false ) provides a means to override this behaviour by permitting
 a fall-back, to type unsafe evaluation where all constraints are generated
 as MVEL constraints and executed dynamically. This can be important when
 dealing with collections that do not have any generics or mixed type
 collections.

 4.7.5. Non Typesafe Classes

 @typesafe( boolean) has been added to type declarations. By default all
 type declarations are compiled with type safety enabled; @typesafe( false )
 provides a means to override this behaviour by permitting a fall-back, to
 type unsafe evaluation where all constraints are generated as MVEL
 constraints and executed dynamically. This can be important when dealing
 with collections that do not have any generics or mixed type collections.


 Mark


 On 10 Jun 2014, at 13:45, Davide Sottara dso...@gmail.com wrote:

 java.util.Collections (and descendants) are not @typesafe by default,
 I'll check the reason for that.
 More generally, if a fact is declared as not @typesafe, the runtime
 failure should be more graceful.
 Davide

 On 06/10/2014 01:26 PM, Wolfgang Laun wrote:
 Consider:

   class Foo { /*...*/ }

   rule checkFoo
   when
  Foo( noSuchField  0 )
   then ... end

 DRL compilation reports an error (Error: unable to resolve method ...)
 and identifies rule, line and column, which is fine.

 Now let's look at:

   import java.util.ArrayList;
   rule checkArrayList
   when
  ArrayList( noSuchField  0 )
   then ... end

 The same DRL compiler (checked with 5.5.0 and 6.0.0) accepts this, and
 there is a nasty exception thrown at runtime. This is inconvenient,
 since the exception can be thrown by any code inserting an ArrayList
 object, and the faulty rule isn't identified.

 Why are certain classes second-rate?

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


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


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


Re: [rules-users] Are there second-rate fact types?

2014-06-10 Thread Wolfgang Laun
But you can do

   declare ArrayList
   @typesafe( true )
   end

which fixes the problem, if not by default :-)

Note that the subsection 4.7.2.1.2 explains things from an
implementer's point of view, which is pretty much useless, and the
wording is rather obscure.

-W



On 10/06/2014, Wolfgang Laun wolfgang.l...@gmail.com wrote:
 The primary concern is not so much type safety but the absence of
 the check of the name being defined as a getter or class member.

 Also, (if I understand the poster correctly) in 5.0.0 the DRL compiler
 was able to flag a non-existent member in ArrayList. Three cheers to
 not breaking backwards compatability.

 Note that even when you abstain from inserting collections as
 first-order facts, you'll still need them, e.g., for a from collect.

 -W

 On 10/06/2014, Mark Proctor mproc...@codehaus.org wrote:
 The feature was more important when we didn't allow casting,  but people
 still wanted to work with Maps and Lists.
 Map( this[key].age  30)

 Collections where defaulted to typefalse(false)

 Now that we support inline casts, it can be argued that things should
 always
 be type safe:
 Map( this[key]#Person.age  30 )

 It's hard to change this now, without breaking backwards compatability.

 The docs don't say that it's defaulted to false for collections, only
 that
 it's useful for Collections. Someone want to submit a pull request fix
 for
 this?

 4.7.2.1.2. @typesafe( boolean )

 By default all type declarations are compiled with type safety enabled;
 @typesafe( false ) provides a means to override this behaviour by
 permitting
 a fall-back, to type unsafe evaluation where all constraints are
 generated
 as MVEL constraints and executed dynamically. This can be important when
 dealing with collections that do not have any generics or mixed type
 collections.

 4.7.5. Non Typesafe Classes

 @typesafe( boolean) has been added to type declarations. By default all
 type declarations are compiled with type safety enabled; @typesafe( false
 )
 provides a means to override this behaviour by permitting a fall-back, to
 type unsafe evaluation where all constraints are generated as MVEL
 constraints and executed dynamically. This can be important when dealing
 with collections that do not have any generics or mixed type collections.


 Mark


 On 10 Jun 2014, at 13:45, Davide Sottara dso...@gmail.com wrote:

 java.util.Collections (and descendants) are not @typesafe by default,
 I'll check the reason for that.
 More generally, if a fact is declared as not @typesafe, the runtime
 failure should be more graceful.
 Davide

 On 06/10/2014 01:26 PM, Wolfgang Laun wrote:
 Consider:

   class Foo { /*...*/ }

   rule checkFoo
   when
  Foo( noSuchField  0 )
   then ... end

 DRL compilation reports an error (Error: unable to resolve method ...)
 and identifies rule, line and column, which is fine.

 Now let's look at:

   import java.util.ArrayList;
   rule checkArrayList
   when
  ArrayList( noSuchField  0 )
   then ... end

 The same DRL compiler (checked with 5.5.0 and 6.0.0) accepts this, and
 there is a nasty exception thrown at runtime. This is inconvenient,
 since the exception can be thrown by any code inserting an ArrayList
 object, and the faulty rule isn't identified.

 Why are certain classes second-rate?

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


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



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


Re: [rules-users] Grouping of rule and range check

2014-06-06 Thread Wolfgang Laun
Are these seven (or eight) different objects of class Person?
-W

On 06/06/2014, Chaturvedi Dewashish dewash...@nirvana-sol.com wrote:
 Hi,

 I have a requirement which is as
 1. There are three rules lets say rule1, rule2 and rule3
 2. rule1 says there is a person
   Age  40
   Age = 20
   Then do something
 3. rule2 says there is a person
   Age  60
   Age = 40
   Then do something else
 4. rule3 says there is a person
   Age = 60
   Then do something new

 Now I am feeding person object as whole as event based from other
 application.
 So the requirement in form of test cases is
 1. Age = 22 - do something
 2. Age = 25 - Nothing as rule1 is already triggered and do something done
 3. Age = 42 - do something else
 4. Age = 45 - Nothing as rule1 is already triggered and do something else
 done
 4. Age = 65 - do something new
 5. Age = 68 - nothing
 6. Age = 25 - do something
 7. Age = 45 - do something else

 Is there any way to do this using the guvnor UI?


 Thanks and regards,
 Chaturvedi Dewashish
 Nirvana Solutions

 ___
 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] Monitoring applications using Drools

2014-06-05 Thread Wolfgang Laun
Running Drools for event processing can be done in several ways, but some
of them will not produce the expected results.

One good way is to use a real time clock, call fireUntilHalt() in one thread and
insert facts (as they arrive) via another thread.

Another one, good for tests, is to use a pseudo clock, which should be
advanced according to the progress of time, e.g. before inserts. With this
approach, it is necessary to fireAllRules() after each insert. Failure to do so
will keep activations resulting from an earlier (pseudo-)time and fire it
unless facts have changed. But a change of the time window in the rule
(and the set of facts it had selected at some earlier pseudo-time) does not
result in the activation being discarded.

Change your code like this:

for (int i = 0; i  tempMetrics.size(); i++) {
System.out.println(Clock's Time: +clock.getCurrentTime());
System.out.println(temp reading:  +
tempMetrics.get(i).getTemperature() );
factHandleList.add(temperatureStream.insert(tempMetrics.get(i)));
ksession.fireAllRules();
clock.advanceTime(1, TimeUnit.MINUTES);
}

-W


On 05/06/2014, Sushant Goyal sushantgoya...@yahoo.co.in wrote:
 Folks,

 I have tried changing my Drools version to 5.5.0.Final and 6.0.1.Final,
 but there is no change in the rule behavior. So, I assume we can rule out
 the
 possibility of version issue.


 On Thursday, 5 June 2014 4:04 PM, Sushant Goyal sushantgoya...@yahoo.co.in
 wrote:



 Thanks for  your quick
 response.
 I am using 5.3.0 Final version of Drools. Attached are the
 necessary files (DRL, fact, test class) required to reproduce the effect.
 Please let me know if any further details are required.

 Thanks!


 On Thursday, 5 June 2014 2:23 PM, Wolfgang Laun wolfgang.l...@gmail.com
 wrote:



 On first reading, both observations could be bugs. But it is difficult to
 assess such situation without knowing the Drools version, without
 having a complete (but minimal) set of Java and DRL code reproducing
 the effect.

 -W


 On 05/06/2014, Sushant Goyal sushantgoya...@yahoo.co.in wrote:
 Thanks again for your response Wolfgang.

 I found one of the explanations on how
  Sliding Windows
 operate in Drools while searching for an answer:
 Events are expired
 from the time window when the clock advances

 So, in my case if I am inserting events on T0 (insert 1st event), T1
 (insert
 2nd event), T2 (insert 3rd event) and
 advancing the clock to T3, T4 and T5; 1st event inserted at T0 is
 expired from the window. And the rule calculates the average of the last
 two
 events (2nd event  3rd event) falling in the time
 window. And the output average calculated by the from accumulate function
 comes
 to be (26 +28 / 2 == 27) satisfying the contract of average temperature to
 be above
 the threshold value of 25.

 Now let's say I do the below (advancing the clock by 5
 minutes after the 3rd insert):

 T0 (insert 1st event)
 T1 (insert 2st event)
 T2 (insert 3st event)
 T3
 T4
 T5
 T6
 T7
 Fire all rules

 The average calculated by the rule is zero (0) since the
 three inserted events fall outside the time window of 5 minutes (as
 expected).
 But, my rule fires regardless of the fact I have the contract of average
 temperature
 to be greater than threshold in my rule :

 $averageTemp : Number(intValue
 25)
 from
 accumulate(SensorReading($temp : temperature)
 over
 window:time(5m) from
 entry-point Temperature Reading, average($temp))

 As per the drools-fusion documentation, over window : time(X) is used to
 consider events that happened in
 the last X units. So, is there something that needs to be changed in my
 rule
 implementation?

 One more question here, does over window : time(X) really considers events
 occurred in the last
 X units. I tried going further by doing the below:

 T0 (insert 1st event - Sensor reading is 24)
 T1 (insert 2st event - Sensor reading is 26)
 T2 (insert 3st event - Sensor reading is 28)
 T3
 T4
 T5
 T6
 T7
 (insert event - Sensor reading is 30)
 Fire All rules

 With the above test setup, my rule gets invoked twice printing
 the average of
  temperatures as (30) and (30). But using over window:time(5m)
 shouldn't result in rule being triggered once ?

 Thanks in advance!



 On Thursday, 5 June 2014 12:31 PM, Wolfgang Laun wolfgang.l...@gmail.com
 wrote:



 Computations involving intervals where events arrive in real time
 should not depend on differences of one unit of the smalles
  unit of
 time for specifying durations (here: milliseconds).

 -W




 On 04/06/2014, Sushant Goyal sushantgoya...@yahoo.co.in wrote:
 Thanks for your response.
 I was under the assumption that the window time frame begins, the moment
 first event is inserted into the working memory. Or I am still missing
 out
 something here (when you say that the first event is
  exactly at the
 beginning of the window)?  If I

Re: [rules-users] Drools slowness in first calls

2014-06-05 Thread Wolfgang Laun
Google: JIT Java

-W

On 05/06/2014, Gael gael.weil-jour...@prestataire.april.com wrote:
 Hi,

 We are using Drools for a heavy process and we notice some slowness during
 the first calls to kbases (containing about 1500 rules each) using
 StatefulKnowledgeSession.
 Even if the kbase is loaded, we need to make some fictive calls (fire
 the rules with some facts) until it begins to respond within a reasonable
 time. It's like we need to warm it up..

 Any idea about what Drools does during this time?
 Is there a way to programmatically launch these processing without the need
 to have facts ?

 Thanks in advance and sorry for my english.

 NB : we use Drools 5.5.

 Regards,
 Gael



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-slowness-in-first-calls-tp4029887.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Help write rule drools

2014-06-04 Thread Wolfgang Laun
How do you want the result? Printed lines on standard output? One for
each pair of connected nodes, as you have shown it below result? Or
collected in another fact?

-W

On 4 June 2014 10:09, nill nill...@hotmail.com wrote:
 My structure is composed of 2 classes (Node, Link)
 class Node {
 List Link out;
 List Link in;
 }
 class Link {
 Source node;
 Target node;
 }

 they are inserted as facts in working memory.

 I have to write a rule that will unite for each node joins the links that
 have the same destination, and if there is then the inverse must also join
 the latter.

 eg.
 A - link1 - B
 A - link2 - B
 A - link3 - C
 C - link4 - D
 B - link5 - A

 result
 A - link1 + link2 +link5 - B
 A - link3 - C
 C - link4 - D

 Can anyone help me?



 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/Help-write-rule-drools-tp4029841.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Fusion, Insert Events with timestamp in the past.

2014-06-04 Thread Wolfgang Laun
On 4 June 2014 11:32, SebastianStehle mail2ste...@gmail.com wrote:
 I have forgotten to mention that the drools version is 5.5.0.Final, the test
 is running in stream mode with a realtime clock.

That's just the point. In real time, the past is past. For re-living the past
with a different set of rules, you should consider using a pseudo-clock.
Now time is under the control of the program, and you can replay the
past and then slip into second-hand real-time mode.

-W






 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/Fusion-Insert-Events-with-timestamp-in-the-past-tp4029843p4029844.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Help write rule drools

2014-06-04 Thread Wolfgang Laun
On 04/06/2014, nill nill...@hotmail.com wrote:
 One for each pair of connected nodes.

One what? Where? With what content?
-W





 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Help-write-rule-drools-tp4029841p4029848.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Fusion, Insert Events with timestamp in the past.

2014-06-04 Thread Wolfgang Laun
On 04/06/2014, SebastianStehle mail2ste...@gmail.com wrote:
 I see that the update process is not optimal, but can you tell me if my
 simple example should work or not?

 We get measurements from sensors. Because of network delay and other
 intermediate processes the timestamp of the measurements can be some
 seconds
 behind the time of the insert.

How can this be? t(measurement)  t(insert), which is before.

As long as network delay is uniform for all sources, it doesn't
matter. If there are different sensor positions with data being
relayed over different links, delays may depend on the source. But in
this case, you are up the creek anyway.

-W

 In this case the rules with after would not
 work correctly as well.

 I am new to drools, so there is a high chance that I make some mistakes.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Fusion-Insert-Events-with-timestamp-in-the-past-tp4029843p4029847.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Fusion, Insert Events with timestamp in the past.

2014-06-04 Thread Wolfgang Laun
On 04/06/2014, SebastianStehle mail2ste...@gmail.com wrote:
 We made another test with the pseudclock where we advanced the time after
 each measurement.

 Lets say we have the two measurements, the first at 10am and the second at
 11am. Based on the rule before, you would expect that the rule fires at
 10:10am because no other event is inserted. But what happens was that the
 rule is activated at 11am, because the clock has not been advanced in the
 meantime. This makes totally sense for me, so I thought you might need
 another thread or so.

Absolutely.


 If you implement it like this (pseudo-code), it works fine:

 session.insert(first);
 clock.advanceTime(first.getTime());

 while (time  second.getTime()) {
 clock.advanceTime(100);
 time.add(100ms);
 }

 session.insert(second);
 clock.advanceTime(second.getTime());

Right, this should take care of the timers.


 What makes our scenario very complicated is that we mix realtime and
 pseudo-time a little bit. For example we have timers that trigger at
 midnight or so (in realtime) and we have measurmenets with a delay of some
 seconds, where we need a pseudoclock. I have no real idea how this can be
 realized, but I still wonder, what @timestamp is for, if it cannot combined
 with the normal clock.

The time of measurements is one progress of time, and when you need a
midnight event, you should ask one of the measurement providers.  If
midnight is a more or less arbitrary point in that progress of time,
you can use your local clock.

There is an European norm that deals with the reliability of networks.
If you have to expect delays, you may have to detect them, and decide
what counter-action to employ.

IIRC, at the start if this thread there was the issue of updating
rules. There is the option of changing the rules on the fly, without
creating a new session. And there may be a different approach,
deriving state from a sequence of events, rather than trying to
keep the sequence with its timestamps - but this depends on what the
events signify.

-W










 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Fusion-Insert-Events-with-timestamp-in-the-past-tp4029843p4029858.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Fusion, Insert Events with timestamp in the past.

2014-06-04 Thread Wolfgang Laun
A @timestamp is just an increasing sequence of values - it has no
other implications. Cloud vs. stream mode determines how these
values should be ordered on insertion.

-W

On 04/06/2014, SebastianStehle mail2ste...@gmail.com wrote:
 Yes, t(measurment)  t(insert). The sensors communicate with the server
 with
 3g, which might be slow in some situations.

 I simplify my question: Can I use @timestamp with realtime-clocks?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Fusion-Insert-Events-with-timestamp-in-the-past-tp4029843p4029860.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Monitoring applications using Drools

2014-06-04 Thread Wolfgang Laun
Your code does:
  insert 1st event
  delay 1 minute
  insert 2nd event
  delay 1 minute
  insert 3rd event
  delay 1 minute
  delay (1 or) 2 minutes
  fire all rules

In the second case, 5 minutes have elapsed since the 1st insert. I
don't think that this means that [the 1st insert] falls well within
the specified time range - it is exactly at the beginning of the
window, and I'd expect the window to be an interval open at one end -
otherwise events smack on the point in time separating two intervals
would be in both windows.

-W


On 04/06/2014, Sushant Goyal sushantgoya...@yahoo.co.in wrote:
 Hi,

 I am
 trying to understand how Drools can be used to monitor events over a period
 of
 time using Sliding Time Windows. I have created a rule to sound an alarm
 when
 average temperature read from a sensor is above 25 degrees (threshold) over
 a
 time period of 5 minutes. The rule makes of use of the Stream processing
 mode so
 that continuous stream of events could be processed.

 Below
 is how my rule looks like:

 //declare any global
 variables here
 globaljava.lang.StringBuilder alertMessage

 // add declaration to
 change the Fact into an Event
 declareSensorReading
@role(event)
 end

 /* Alert when average
 temperature is above 25
over a time period of 5 minutes */
 ruleTemperatureAlarm1

 when
 //conditions
 $averageTemp : Number(doubleValue 
 25.00)
fromaccumulate(SensorReading($temp
 : temperature)
   over
 window:time(5m) fromentry-point Temperature Reading, average($temp))
 then
 //actions
 System.out.println(Fired rule:
 +
 kcontext.getRule().getName());
 alertMessage.append(Threshold
 temperature breached!!+
\nTurn on the
 Air Conditioner+
\nAverage
 temperature over 5 minutes is above 25 (+ $averageTemp.intValue() + )\n);

 end

 And below
 is the snapshot of the fact (SensorReading) which is inserted as an event in
 the working memory:

 publicclassSensorReading {

privatedoubletemperature;

publicSensorReading(){}

publicSensorReading(doubletemp){
   this.temperature= temp;
}

// getters and setters
 }


 In
 order to test the rule, I am using Pseudo Clock with Stream processing
 turned
 on. I am inserting three SensorReading objects in the working memory with
 temperature
 values as (24, 26, 28) after every minute, so that the average of the
 temperatures is above threshold and the rule is invoked. After the objects
 are
 inserted in the working memory, I am deliberately advancing the Pseudo clock
 by
 another 1 minute, so that the total time elapsed is 4 minutes. The rule
 works
 as expected with the above test setup and prints the average value as 26 on
 the
 console.

 However,
 if I advance the clock by 2 minutes instead of 1 minute after three sensor
 reading objects have been inserted in the working memory (after every 1
 minute
 interval), the rule gets invoked but the average value gets changed to 27
 (26 +
 28 / 2 == 27). Looks like the first temperature reading is getting ignored
 by
 the rule despite the fact that it falls well within the specified time range
 of
 5 minutes. Below is the snapshot of my test class:

 publicclassTemperatureAlarmTest
 {

staticKnowledgeBase kbase;
staticStatefulKnowledgeSession ksession;
staticKnowledgeRuntimeLogger logger;
staticSessionPseudoClock clock;

@BeforeClass
publicstaticvoidsetupKsession() {
   try{
  // load up the
 knowledge base
  kbase= readKnowledgeBase();
  ksession= readKnowldedeSession(kbase);
  clock= ksession.getSessionClock();

  logger=
 KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, log/Errors,
 500);

   } catch(Throwable t) {
  t.printStackTrace();
   }
}

/**
 *
 Create a new Stateful knowledge Session with a pseudo clock from the
 *
 knowledge base
 *
 * @paramkbase
 * @return
 * @throwsException
 */
privatestaticStatefulKnowledgeSession readKnowldedeSession(
  KnowledgeBase kbase) throwsException {

   // Knowledge Session Configuration
   KnowledgeSessionConfiguration
 config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
   config.setOption(ClockTypeOption.get(pseudo));
   returnkbase.newStatefulKnowledgeSession(config, null);

}

@AfterClass
publicstaticvoidcloseKsession() {
   try{
  // load up the
 knowledge base
  logger.close();
  ksession.dispose();

   } catch(Throwable t) {
  

Re: [rules-users] Help write rule drools

2014-06-04 Thread Wolfgang Laun
To remove all redundant Link objects and assuming that class Link is declared as
   class Link {
 Node source;
 Node target;
   }
(and not as given in the original post), the rule:

rule kill redundant links
when
$l1: Link( $s: source, $t: target )
$l2: Link( this != $l1,
   source == $s  target == $t
   ||
   source == $t  target == $s )
$n1: Node( out contains $l2 )
$n2: Node( in contains $l2 )
then
retract( $l2 );
modify( $n1 ){ getOut().remove( $l2 ) }
modify( $n2 ){ getIn().remove( $l2 ) }
end

removes all redundant Link facts and updates the out and in fields of
the Nodes at either end of these links.

-W


On 04/06/2014, nill nill...@hotmail.com wrote:
 I try to explain. I have a graph where each node can have only one
 connection
 to the other.
 If I check the presence of n links between two nodes then delete n-1
 connections.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Help-write-rule-drools-tp4029841p4029869.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Abstraction between rules and data model?

2014-06-02 Thread Wolfgang Laun
. ;)

  Is there any plan for the public release of Trait property binding to a
 nested path? We would definitely need something like that in our
 environment. Or do you see any way we could hook into the property
 look-up
 mechanism? Based on what I know, I don't see any official extension point
 for that.

  My only idea would be using some Java proxy voodoo-magic to wrap objects
 before they are inserted to the session, but my gut feeling is that it
 would be a way to debug hell...

  What do you think?

  Cheers,
 Peter



 2014-05-27 19:42 GMT+02:00 Davide Sottara dso...@gmail.com:

  Consider that a trait is an interface applied to some class. In the
 context of the pair:
 A hard field is a property (get/set) exposed by the interface AND the
 underlying class
 A soft (or virtual) field is a property exposed by the interface BUT
 NOT by the underlying class
 A hidden field is a field of the underlying class NOT exposed by the
 interface

 Hard and Soft fields can be accessed using the interface, hidden fields
 are accessible using the map-like
 construct fields[ fieldName ].

 This said,
 the mapping is by default done using the property name and (then) the
 property type.
 However, this mapping can be decoupled using the annotation @Alias() on
 either the class OR the trait.
 E.g.
 declare Core
   name : String @Alias( any-Id-or-even-an-IRI-here )
 end

 declare trait SomeTrait
 label : String @Alias( ... )  // if two aliases match, this will
 be considered a hard field
 end

 The accessor, i.e. the ability to bind a trait property to a (possibly
 deeply) nested path is what I'm working
 on these days, I have the same requirement from another urgent use case

 For the time being, you can probably create a shortcut accessor pair
 in
 your implementation class,
 to execute the complex expression, and @Alias it to the trait field.

 Please let me know if you find any issue/bugs and any feature request
 you
 may have!
 Best
 Davide



 On 05/27/2014 07:57 AM, Horváth Péter Gergely wrote:

 Hi Davide,

  Drools trait functionality is one of the powerful concepts which makes
 Drools a good candidate for the project. So keep up the good work! :)
 However I'm not sure if its current level of flexibility would be
 sufficient for our use case. I've checked the documentation, but haven't
 really found the term virtual field -- could you please elaborate on
 this?

  Do you think we could somehow hook into the evaluation of the aliases
 or the fields Map? Sometimes you would need slightly more than merely
 aliasing fields to something else; e.g. calculating values for the
 purpose
 of rule processing or extracting a value from a more complex object tree
 etc. Citing the example -- GoldenCustomer( fields[ age ]  18 ) --
 being
 able to get a reference to the target object and the field map
 expression
 age would be quite close to what I imagined. Our custom code could
 then
 perform the appropriate translation and return the requested value,
 hiding
 the fact whether age is an actual field in the Customer object
 itself/retrieved from an encapsulated complex object e.g. replacing
 expression customer.personalInformation.birthData.age/calculated on
 the
 flight.

  What do you think?

  Cheers,
 Peter



 2014-05-26 17:58 GMT+02:00 Davide Sottara dso...@gmail.com:

 We are working on the trait framework for cases like this. Essentially,
 it allows to use
 interfaces when writing rules AND to inject the interfaces dynamically
 at runtime,
 at the instance level. It relies on transparent proxies which wrap the
 data classes
 and implement the required interfaces. A simple field aliasing
 mechanism
 is provided
 (work in progress). For more complex transformations, virtual fields
 can be added.
 See section 7.7.8 of the manual for more details and let me know if it
 can help
 with your use case.
 Best,
 Davide

 On 05/26/2014 09:55 AM, Wolfgang Laun wrote:
  Even a relatively sophisticated transformation would be easier to
 implement
  and most certainly safer from changes in the unstable Drools API than
 some
  hook-and-intercept mechanism built into Drools.
 
  Notice that violent structural departure of the model the BUs see
  from
 what
  you call persistence model might make it impossible for the BUs to
 come
  up with rules that can be transformed to match the other model at
  all;
  if it is possible, rules might still incur a heavy performance
  penalty.
 
  It is (IMHO) a myth that Rules is a foolproof way of establishing
  business logic
  independent from the data model and application environment with
  which
  this logic should be able to cooperate. As long as everything is kept
 in the
  abstract (i.e., formulated in terms of mathematics) it will look
  good, but
  any implementation may throw a spanner in the works, or worse.
 
  -W
 
  On 26/05/2014, Péter Gergely, Horváth h.pe...@mailbox.hu wrote:
  Hi Wolfgang,
 
  Thank you for your input. You are right that some of the cases could
 simply
  be covered

Re: [rules-users] Question about Fusion pseudoclock

2014-06-01 Thread Wolfgang Laun
This is code that can be used to manipulate the pseudo-clock which is
just a pretty face without any works:

SessionPseudoClock clock;

private void advance( Date eventDate ){
long currentTime = clock.getCurrentTime();
long eventTime = eventDate.getTime();
clock.advanceTime( eventTime - currentTime, TimeUnit.MILLISECONDS );
}

Of course, you can use other ways to determine a number of
milliseconds for moving the hands of the pseudo-clock. If you use the
number of peas in a pot, it'll work just as well, although the data
might be closer to 1970.

-W




On 31/05/2014, Natalia Iglesias de Amunategui
natalia.igles...@casadearriba.net wrote:
 Hello,



 I am implementing temporal rules using drools fusión 6.0.1 and the new KIE
 services api. I insert facts into the kie session that include some DATE
 fields which I later use in the rules. I also insert events using the
 pseudoclock, so I guess that means that the timestamp is kept  in long
 format.

 The consequence is that my temporal rules do not fire at all! I have no
 @timestamp annotation in the declare of the event, so Drools internal clock
 should be used as timestamp.



 I have displayed  the value of the pseudoclock getCurrentTime method, and
 the output shows a date of 1970:







 I need to understand why the clock.getTime returns dates of 1970, maybe
 when
 this is solved the rules will fire with the internal event timestamp.



 (After that I have tried every possible combination: creating a date or
 long
 field in the event fact representing the timestamp, converting long to date
 and viceversa, but nothing seems to work..).



 I enclose here the initialization that I do of the kieContainer and
 session:





 public static void main(final String[] args) {

  try {



 // load up the knowledge base

 KieServices ks = KieServices.Factory.get();

 KieContainer kContainer =
 ks.getKieClasspathContainer();


 System.out.println(kContainer.verify().getMessages().toString());





 // set stream mode as opposite to cloud mode

 KieBaseConfiguration kbconf =
 KieServices.Factory.get().newKieBaseConfiguration();

 kbconf.setOption(EventProcessingOption.STREAM );



 // set clock to pseudo clock to be able to advance it
 manually

 KieSessionConfiguration ksconf =
 KieServices.Factory.get().newKieSessionConfiguration();

 ksconf.setOption(ClockTypeOption.get(pseudo));





 // returns ksession from kiecontainer as defined in the
 kmodule.xml file

 KieSession kSession =
 kContainer.newKieSession(VAPSession, ksconf);





 // Insert test patients and related classes, dates are
 in long format to match pseudoclock

 final Patient p1 = new Patient( MrJones, 45, 1,
 true,false,false,35.0,

   5000,None,Localized
 Infiltrates,Yes,None,S.Aureus,245,false, false, 0,

   true,new
 SimpleDateFormat(-MM-dd).parse(2014-05-31).getTime(),,

   new
 SimpleDateFormat(-MM-dd).parse(2014-05-31).getTime(),false,false,fal
 se,false);

 kSession.insert( p1 );





 // Insert test patients and related classes, dates are
 long format



 final Patient p2 = new Patient( MissDaisy, 90, 1,
 true,false,true,37.0,

   5000,Purulent,Diffuse or Patchy
 Infiltrates,None,Heavy,S.Aureus,235,false, false, 0,

   true,new
 SimpleDateFormat(-MM-dd).parse(2014-05-31).getTime(),,

   new
 SimpleDateFormat(-MM-dd).parse(2014-05-31).getTime(),false,false,tru
 e,false);



 kSession.insert( p2 );



 // define and get a reference to the entry point

 EntryPoint nursingStream = kSession.getEntryPoint(
 NursingStream );



 // define session clock

 SessionPseudoClock clock = kSession.getSessionClock();



 // insert events

 // then, while inserting events, advance the clock as
 necessary:



 clock.advanceTime(24, TimeUnit.HOURS);

 CPIScore cpiScore1 = new CPIScore(
 p1,diagnosis,7,ToDate(clock.getCurrentTime()) );

 nursingStream.insert( cpiScore1 );

 System.out.println(cpiScore1.getcpiScoreDate());



 // day 2

 clock.advanceTime( 24, TimeUnit.HOURS );

 cpiScore1 = new CPIScore(
 p1,follow-up,5,ToDate(clock.getCurrentTime()) );

 nursingStream.insert( cpiScore1 );

 System.out.println(cpiScore1.getcpiScoreDate());



 // day 3

  

Re: [rules-users] Syntax Question on an or condition

2014-05-28 Thread Wolfgang Laun
On 28/05/2014, Chidambaran Subramanian chi...@gmail.com wrote:
 rule Test
   dialect mvel
   when
 ( Customer( age == 50 ) or Deal( amount == 30 ) )
   then
 Customer.setAge( 40 );
 update( Customer );
 Customer.setPlace( Test );
 update( Customer );

 end

The rule uses invalid syntax: Customer is a class name, and you cannot
update a class. Check the Expert manual on how to write rules.

Besides, the logic doesn't make sense, because you'd not even need a
Customer for the condition to be true, and then you can't do anything
with a Customer object.


 How to do I tag both Customer and Deal on the 1st condition , to enable me
 to


What?

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


Re: [rules-users] Excel Syntax in Decision Tables

2014-05-27 Thread Wolfgang Laun
Oops, sorry: The constraint goes into the leftmost pair of parentheses.
Simply exchance to order of the patterns: Classification(); $f: FATCA();

-W

On 26/05/2014, crosbis2 drpatrick.co...@gmail.com wrote:
 It's guvnor-5.5.0.Final-jboss-as-7.0

 Yes i copied your syntax

 http://drools.46999.n3.nabble.com/file/n4029693/FATCA3.png

 and got this

 http://drools.46999.n3.nabble.com/file/n4029693/FATCA5.png




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029693.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Slf4j Log4j logger not working with Drools drl while using as a global variable.

2014-05-27 Thread Wolfgang Laun
@Geoffrey: did you see the java.lang.ArrayIndexOutOfBoundsException?
Doesn't look like a null pointer causing an exception. The upstairs
exception might add the basic exceptions's message to its message.

@Soumya: Which Drools version are you using? Basically, this situation
is handled correctly by 5.4 and 5.5.

-W

On 27/05/2014, Geoffrey De Smet ge0ffrey.s...@gmail.com wrote:
 Check if the logger isn't null (by adding a System.out in the then part
 of the rule).

 If that's the case, then that error message is pretty poor (or even
 incorrect):
 java.lang.RuntimeException: cannot invoke method: info
 It should clearly talk about a NullPointer instead.
 So, if that's the case, create a jira issue.
https://issues.jboss.org/browse/DROOLS


 On 27-05-14 07:09, Soumya.plavaga wrote:
 I am using global slf4j log4j logger as a global variable within our drl
 and
 inserting that global logger value at runtime into kiesession. While we
 are
 trying to do logger.info with multiple arguments then it's giving the
 following exception stack trace -

 Exception executing consequence for rule Test Logger 2 in
 test.rules.system: java.lang.RuntimeException: cannot invoke method: info
  at
 org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
  at
 org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1027)
  at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:129)
  at
 org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:71)
  at
 org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:935)
  at
 org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1200)
  at
 org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:952)
  at
 org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:926)
  at
 org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:232)
  at
 test.platform.rules.executor.service.impl.RuleExecutorServiceImplTest.testExecuteRule(RuleExecutorServiceImplTest.java:230)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at
 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  at
 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at
 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  at
 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at
 org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
  at
 org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
  at
 org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
  at
 org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
  at
 org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  at
 org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  at
 org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  at
 org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
  at
 org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  at
 org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at
 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
  at
 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
  at
 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
  at
 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
 Caused by: java.lang.RuntimeException: cannot invoke method: info
  at
 

Re: [rules-users] Nested Collect probably

2014-05-26 Thread Wolfgang Laun
Due to imprecise wording, this may or may not be what you want. The rule fires,
if there are 5 or more Employees, each of them with the property that
   - the employee has visited CCNA in year X
   - the employee has visited CCNP in year X
   - the employee has visited CCIE or J5SE in 2000 OR
 has visited J4WS in 2001 or 2002 or 2003 (OR both)

(There is no relation between the years X of different employees.)

rule findCombi
when
accumulate(
Certificate( course == CCNA, $e: employee, $y: year )
and
Certificate( course == CCNP, employee == $e, year == $y )
and
Certificate( employee == $e,
 ((course == CCIE || == J5SE )  year == 2000 )
  ||
  course == J4WS  year == 2001 || == 2002 || == 2003 );
$es: collectSet( $e ); $es.size() = 5 )
then
System.out.println( more than 5 );
end



On 26/05/2014, Chris B sunnyca...@gmail.com wrote:
 I have a class

 Employee
 (name)

 Certificates
 (course, year, employee)

 If the employees have CCNA  CCNP from the same year and then if they took
 CCIE or J5SE in 2000  or J4WS in 2001 or 2002, or 2003
 The Action should be taken if there are more than 5 such employees.

 The connection between Employee and Certificates is through
 Certificates.employee, but I can change it to a list of certificates in
 Employee also if needed.

 I start with
 $e: Employee()
 Certificate (employee == $e, course == CCNA, $ccnaYear : year)
 Certificate (employee == $e, course == CCNP, $ccnpYear : year)
 //this will get the years for one employee..
 //now we need to get all other employees from same year..
 //but we still need to make sure all certificates are from the same
 employee.
 ArrayList( size = 2 ) from collect(Certificate (
 ((course == CCNA, year == $ccnaYear, $e_this:employee)  (course ==
 CCNP, year == $ccnpYear, employee == $e_this))
 
 (
 ((course == CCIE, year == 2000, employee == $e_this) || (course == J5SE,
 year == 2000, employee == $e_this))
 ||
 ((course == J4WS, year == 2001, employee == $e_this) || (course == J4WS,
 year == 2002, employee == $e_this) || (course == J4WS, year == 2003,
 employee == $e_this))
 )
 )

 This is going crazy at this stage.
 First problem, - I start with one employee, and try to get his years of CCNA
 and CCNP
 Next I am collecting Certificates instead of Employees which I should be
 collecting and checking the length of the employees.

 I think something like this will help me
 http://blog.athico.com/2007/06/chained-from-accumulate-collect.html
 But I am unable to convert it into my usecase.

 Please help.
 Thanks




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Nested-Collect-probably-tp4029681.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.

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


Re: [rules-users] Abstraction between rules and data model?

2014-05-26 Thread Wolfgang Laun
What you describe can be done with /bin/sed.

Notice that the DSL processor doesn't require you to translate entire
patterns; there is a mechanism for translating keywords, which is
just arbitrary tokens to whatever replacement text.

If a bar must be translated to a barList in the context of a class
Foo but not in any other context, a more sophisticated translation
is required in any case (with /bin/sed still being sufficient if
patterns aren't split across lines).

Some say that good design makes use of Interfaces, which leaves room
for actual implementations being changed as long as the interfaces are
implemented. Here, note that rules can be written against interface
types.

-W


On 26/05/2014, Péter Gergely, Horváth h.pe...@mailbox.hu wrote:
 Hi All,

 We are evaluating Drools 6 for our use case, and face challenges where we
 would need some ideas from more experienced users of Drools.

 We have an application with a massive code base and a large number of model
 (entity) classes. We are in the process of moving away from inherited
 legacy technologies and refactoring the old code base. As a part of this
 work we would like extract some of the hard-coded business logic to
 external rules, that is why we are looking at Drools as a potential
 solution.

 What we would like to have is some kind of abstraction or mapping between
 actual entities and rules the business users can define so that they do not
 have to know the _exact_ details of the data model (field names, precise
 relations etc). This would be important for us so that we can refactor the
 old model classes without affecting business rules; also it would make life
 easier for the business users. While IDE support might make refactoring
 easier, we definitely want to have a separation between rules and entities.

 Given our situation, writing and maintaining stable wrapper/adapter
 classes for the sole purpose of rule processing is out of question. I have
 checked the documentation of Drools DSL support and for me it seems to be
 overkill for our use case: we do not really need a custom language, but
 simply an abstraction between rules and the data model classes.

 What I could imagine is a piece of code, (a custom property resolver? - no
 sure how it is called) which maps property expressions to actual properties
 based on a custom annotation on the entity class or something like that, so
 that a rule containing Foo.bars expression does not have to change even
 if we decide to rename Foo.bars to Foo.barList in the model classes.
 (This was just a simple example of a potential use cases)

 Could you please share your thoughts on this topic and point me into the
 right direction?

 Thanks,
 Peter


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


Re: [rules-users] Abstraction between rules and data model?

2014-05-26 Thread Wolfgang Laun
Even a relatively sophisticated transformation would be easier to implement
and most certainly safer from changes in the unstable Drools API than some
hook-and-intercept mechanism built into Drools.

Notice that violent structural departure of the model the BUs see from what
you call persistence model might make it impossible for the BUs to come
up with rules that can be transformed to match the other model at all;
if it is possible, rules might still incur a heavy performance penalty.

It is (IMHO) a myth that Rules is a foolproof way of establishing
business logic
independent from the data model and application environment with which
this logic should be able to cooperate. As long as everything is kept in the
abstract (i.e., formulated in terms of mathematics) it will look  good, but
any implementation may throw a spanner in the works, or worse.

-W

On 26/05/2014, Péter Gergely, Horváth h.pe...@mailbox.hu wrote:
 Hi Wolfgang,

 Thank you for your input. You are right that some of the cases could simply
 be covered by regexp-replace, but I'm afraid, not all of them. Interfaces
 could also help, but we have a requirement that the business rules should
 not be tightly coupled to the underlying persistence model. (I understand
 that some might say this is not ideal, but that is our current situation)

 I am wondering whether it is possible to hook into Drools engine and
 intercept field value reference expression evaluations in run time (e.g if
 foo.bars is used in an expression, we could return foo.barList) ? By
 injecting some custom code, we could make the necessary decisions and
 extract the proper value from an object. Unfortunately these parts of
 Drools are pretty much undocumented.

 Regards,
 Peter



 2014-05-26 13:57 GMT+02:00 Wolfgang Laun wolfgang.l...@gmail.com:

 What you describe can be done with /bin/sed.

 Notice that the DSL processor doesn't require you to translate entire
 patterns; there is a mechanism for translating keywords, which is
 just arbitrary tokens to whatever replacement text.

 If a bar must be translated to a barList in the context of a class
 Foo but not in any other context, a more sophisticated translation
 is required in any case (with /bin/sed still being sufficient if
 patterns aren't split across lines).

 Some say that good design makes use of Interfaces, which leaves room
 for actual implementations being changed as long as the interfaces are
 implemented. Here, note that rules can be written against interface
 types.

 -W


 On 26/05/2014, Péter Gergely, Horváth h.pe...@mailbox.hu wrote:
  Hi All,
 
  We are evaluating Drools 6 for our use case, and face challenges where
  we
  would need some ideas from more experienced users of Drools.
 
  We have an application with a massive code base and a large number of
 model
  (entity) classes. We are in the process of moving away from inherited
  legacy technologies and refactoring the old code base. As a part of
  this
  work we would like extract some of the hard-coded business logic to
  external rules, that is why we are looking at Drools as a potential
  solution.
 
  What we would like to have is some kind of abstraction or mapping
  between
  actual entities and rules the business users can define so that they do
 not
  have to know the _exact_ details of the data model (field names,
  precise
  relations etc). This would be important for us so that we can refactor
 the
  old model classes without affecting business rules; also it would make
 life
  easier for the business users. While IDE support might make refactoring
  easier, we definitely want to have a separation between rules and
 entities.
 
  Given our situation, writing and maintaining stable wrapper/adapter
  classes for the sole purpose of rule processing is out of question. I
 have
  checked the documentation of Drools DSL support and for me it seems to
  be
  overkill for our use case: we do not really need a custom language, but
  simply an abstraction between rules and the data model classes.
 
  What I could imagine is a piece of code, (a custom property resolver? -
 no
  sure how it is called) which maps property expressions to actual
 properties
  based on a custom annotation on the entity class or something like
  that,
 so
  that a rule containing Foo.bars expression does not have to change
  even
  if we decide to rename Foo.bars to Foo.barList in the model
  classes.
  (This was just a simple example of a potential use cases)
 
  Could you please share your thoughts on this topic and point me into
  the
  right direction?
 
  Thanks,
  Peter
 

 ___
 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] Excel Syntax in Decision Tables

2014-05-26 Thread Wolfgang Laun
Which Drools version are you using?

The upper case 'T' in Type == 3 is *very* unlikely.

And did you copy this exactly as I posted? Especially the final () is
essential in the second row.

-W

On 26/05/2014, crosbis2 drpatrick.co...@gmail.com wrote:
 Hi Laune,

 I tried what you prescribed but get the following in the source code when i
 upload it.

  fatca: FATCA(Type == 3); Classification()


 ?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029690.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Nested Collect probably

2014-05-26 Thread Wolfgang Laun
It's not possible to use the conditional element or inside an
accumulate. (Reading up on the or CE should give you an idea why.)
And that's why I
used a boolean expression as a constraint within the third pattern.

-W

On 26/05/2014, Chris B sunnyca...@gmail.com wrote:
 Actually it is a event from an application usecaseThanks for your reply and
 I
 think I am very close with your help.This rule is giving error Line 99:5
 mismatched input 'or' in rule usecase-test]rule usecase-testwhen
 $e0 : Event ()ParsedValue(event == $e0, ruleId == 0, varName ==
 V0_1, $e0_V0_1_varStringValue : varStringValue)ParsedValue(event ==
 $e0, ruleId == 0, varName == V0_2, $e0_V0_2_varStringValue :
 varStringValue)accumulate( ParsedValue( ruleId == 0, varName ==
 V0_1,  varStringValue == $e0_V0_1_varStringValue, $e : event ) and

 ParsedValue( event == $e, ruleId == 0, varName == V0_2, varStringValue
 == $e0_V0_2_varStringValue ) and ((   
 ParsedValue( event ==
 $e, ruleId == 1, varName == V1_1, varStringValue == X1_1)   
 and
   
 ParsedValue( event == $e, ruleId == 1, varName == V1_2, varStringValue
 == X1_2))   or *[  (   ParsedValue( 
 event == $e, ruleId ==
 2, varName == V2_1, varStringValue == X2_1) and
   ParsedValue(
 event == $e, ruleId == 2, varName == V2_2, varStringValue == X2_2)

 ));$es: collectSet( $e ); $es.size() = 5 )   then
 System.out.println( usecase-test + $es.size());endThe Event comes from
 application and is parsed for values.The event from same application will
 have the same values for ruleId=0, varName-V0_1 and V0_2So any event with
 same values for V0_1 and V0_2 is coming from same application.The rule says
 if from same applicationyou have values which has this combinationruleId ==
 1, varName == V1_1, varStringValue == X1_1ruleId == 1, varName ==
 V1_2, varStringValue == X1_2or this combinationruleId == 2, varName
 ==
 V2_1, varStringValue == X2_1ruleId == 2, varName == V2_2,
 varStringValue == X2_2or this combination sayruleId == 3, varName ==
 V3_1, varStringValue == X3_1ruleId == 3, varName == V3_2,
 varStringValue == X3_2ruleId == 3, varName == V3_3, varStringValue ==
 X3_3In pure english it isFirst I have to identify if I am dealing with
 events from same applicationThis is by comparing (2) parsed values V0_1 and
 V0_2. If they are same across events .. then it having same source.Next
 lets
 check for other conditions..From Rule 1.. I want to check values of V1_1
 and
 V1_2, if there is a issueFrom Rule 2.. I want to check values of V2_1 and
 V2_2, if there is a issueNow I do not want to raise exception as soon as
 condition is met.. since the problem can occur and can be ignored. But if
 it
 happens more than 5 times from the same source, then I want to raise an
 alert.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Nested-Collect-probably-tp4029681p4029703.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Suspicious behaviour when using a bound variable as a constraint in a pattern bound to the same var

2014-05-22 Thread Wolfgang Laun
Please don't write any more posts like this.

You aren't asking a question, as far as I can see - so why do you post?

You write, darkly,  about suspicions of wrong or unexpected results
(which, to be sure, isn't the same thing). This is a big help.

-W


On 22/05/2014, dec roni.frant...@gmail.com wrote:
 Due to a bug we came up with the following rule:

 /*
 Rule intriguing
 when
$foo: Foo( $foo.getBar() == null )
 then
...
 */

 Our original intention was to actually generate the rule like so:

 /*
 Rule intended
 when
$foo: Foo( bar == null )
 then
...
 */

 In most cases the intriguing rule actually seem to behave much like the
 intended.
 We are unsure way.
 Moreover, we suspect that sometime we get wrong, or rather unexpected
 results when firing up this rule.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Suspicious-behaviour-when-using-a-bound-variable-as-a-constraint-in-a-pattern-bound-to-the-same-var-tp4029647.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Suspicious behaviour when using a bound variable as a constraint in a pattern bound to the same var

2014-05-22 Thread Wolfgang Laun
1. The constraints are equivalent. $foo is bound to the Foo object, and
the getter does what the getter is supposed to do, and it's (probably)
visible - so why shouldn't it compile. Version 5.3 or maybe even 5.2 has
introduced general boolean expressions - are you using an older version?

I don't know what you mean by being conditioned upon - do you
understand the concept of binding?

2. Randomness should not matter.

3. Not seeing code that reproduces the issue, discussion is rather fruitless.

-W


On 22 May 2014 17:07, dec roni.frant...@gmail.com wrote:
 Apologies,
 I had wanted to know:
 1. Is it expected that this two rules would behave the same given the same
 input?
 Not sure I understand how would it even compile and how would the var be
 conditioned upon before  being assigned .

 2. The input was just some random string.

 3. The results are unexpected as we are getting a hit on this row even
 though the field is populated with some string. BUT what is suspicious is
 that it would seem we very rarely get this sort of behaviour. We also
 suspect if it has something to do with concurrency or multiple sessions
 concurrently executing.

 Most importantly, I would like to understand 1) - how is this even possible
 to come up with such a pattern and is it expected to behave like the
 intended rule



 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/Suspicious-behaviour-when-using-a-bound-variable-as-a-constraint-in-a-pattern-bound-to-the-same-var-tp4029647p4029654.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools and GPU

2014-05-19 Thread Wolfgang Laun
Graphics Processing Unit???
Gosudarstvennoe Politicheskoe Upravlenie??

So as not to appear too derogative, let me ask how this resource
hunger exhibits itself. Very frequently, some misconception w.r.t.
rule structure and/or
data model results in an inadequate resource consumptation that might
easily have avoided.

-W

On 19/05/2014, Anton Hughes kurren...@gmail.com wrote:
 Hi all

 We have finding drools to be very resource hungry - and we are looking at
 having to have very many servers just to satisfy our drools requirements.
 So I am wondering, has anyone experimented with running drools on a GPU
 server?

 Thanks and regards
 Anton

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


Re: [rules-users] Drools and GPU

2014-05-19 Thread Wolfgang Laun
There is neither a golden rule nor a silver bullet. Understanding
what a rule does on the assembly of your facts is crucial. You may get
by, happily, with an occasional deviation from some normal form, and
you may be bitten, severely, by constantly  neglecting it.
-W



On 19/05/2014, jonathan MERCIER jmerc...@genoscope.cns.fr wrote:
 About rule structure and / or, i thought that builded graph was in
 conjunctive normal form to avoid this problem!?
 Should we use conjunctive normal form as is recommended into tho old
 CLIPS ?



 Le lundi 19 mai 2014 à 19:31 +0200, Wolfgang Laun a écrit :
 Graphics Processing Unit???
 Gosudarstvennoe Politicheskoe Upravlenie??

 So as not to appear too derogative, let me ask how this resource
 hunger exhibits itself. Very frequently, some misconception w.r.t.
 rule structure and/or
 data model results in an inadequate resource consumptation that might
 easily have avoided.

 -W

 On 19/05/2014, Anton Hughes kurren...@gmail.com wrote:
  Hi all
 
  We have finding drools to be very resource hungry - and we are looking
  at
  having to have very many servers just to satisfy our drools
  requirements.
  So I am wondering, has anyone experimented with running drools on a GPU
  server?
 
  Thanks and regards
  Anton
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


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

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


Re: [rules-users] MapString, String and modify() can't be together

2014-05-17 Thread Wolfgang Laun
This also works:
 MapString,String a = new HashMap();

More ways to run into an error
 MapString,String a;
 a = new HashMapString,String();
etc.

Using 6.0.0-Final
-W

On 17/05/2014, rjh raojing...@gmail.com wrote:
 Hi,

 I got a weird problem. A Java List/Map with generics can be used together
 with modify() in the same rule. For example, a simple rule like the
 following:

 package com.sample

 import java.util.Map;
 import java.util.HashMap;

 declare TestFact
 @propertyReactive
 data : String
 end

 rule init
 when
 not TestFact()
 then
 insert (new TestFact());
 end

 rule Test Rule
 when
 $fact : TestFact()
 then
 System.out.println( Hello );
 MapString,String a = new HashMapString,String();
 modify ($fact) {setData(0)}
 end

 I got the following error message:

 java.lang.RuntimeException: Error while creating KieBase[Message [id=1,
 level=ERROR, path=rules/Sample.drl, line=18, column=0
text=Unable to resolve type MapString,String:
 Unable to find class 'MapString,String']]
   at
 org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:260)
   at
 org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:400)
   at
 org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:375)
   at com.sample.DroolsTest.main(DroolsTest.java:17)

 However, if I remove String,String from MapString,String, or remove
 the modify line, the code is correct then.

 Thank you!

 Jinghai




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Map-String-String-and-modify-can-t-be-together-tp4029591.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Newbie: is my data model suitable for drools ?

2014-05-17 Thread Wolfgang Laun
In order to judge the quality of a data model for Drools you should
have a fairly conclusive idea about the rules you are going to write.
(This isn't different from other applications: Storing the data in
some organisation may work fine, but fitness for access is a different
matter.)

The Lists may stand investigation. Is the order in the List important?
Is the List just a hidden set? Is an m:n relationship better expressed
by an entity of its own?

The relational data model of DBs is a good approach for being prepared
for a variety of requests and, therefore, rules.

-W


On 16/05/2014, lindenb plindenb...@yahoo.fr wrote:
 Hi all,

 I'm working in the field of bioinformatics where I study more a large
 number
 of variations (N 10E6) along the human genome  among individuals affected
 by a genetic disease. ( * )

 my data looks like this (much simplified !)

 #CHROMOSOME  POSITION  GENE PROPERTIES  SAMPLE1  SAMPLE2
 SAMPLE3
 chr1 987   GENE1,GENE3  score=1 null A/A  A/G
 chr1 988   GENE3score=4;id=989  A/G  null A/A
 chr1 1988  null score=4;id=989  C/G  null C/A


 People in my lab have to filter those variation using different strategy,
 they then extract the overlapping genes and then filter those genes to find
 one or more gene that could explain the disease.

 Currently they use knime.org to run those filters.
 (http://www.myexperiment.org/workflows/2320.html )

 But I've got the feeling that drools could be used to filter those
 variations.
 Users would 'just' have to write some rules, run the engine and get the
 result.
 Rules would be removed/switched to get the result for another strategy.

 Question:
 1)  is drools a good choice here ?
 2) how should I model my data ?

 If I use this java model:

 class Gene {
 ListVariation getVariations();
 }

 class Variation {
 String getChromosome();
 int getPosition();
 ListGene getGenes();
 ListGenotype getGenotypes();
 }

 class Genotype{
 Variation getVariation();
 Sample getSample();
 String getDNA();
 }

 it will create a large graph, can drools support it ?

 3) Where in the documentation can I find how to easily set the state my
 objects in order to filter them. E.g:

 variations -[filters1]- [filter2]-[fiilter5] - result
   `[filter3]-[filter4]--/

 Thank you,

 Pierre

 (*)
 http://www.1000genomes.org/wiki/Analysis/Variant%20Call%20Format/vcf-variant-call-format-version-41



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Newbie-is-my-data-model-suitable-for-drools-tp4029590.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Wildcard or list directory in changeset?

2014-05-13 Thread Wolfgang Laun
Expert manual, search for change-set, there you'd find:

It is also possible to specify a directory, to add the contents of
that directory. It is expected that all the files are of the specified
type, since type is not yet inferred from the file name extensions.

...and even an example!

-W


On 12/05/2014, Cwen c...@regenstrief.org wrote:
 We set up a webdav to host all the pkg(s). We would like to dynamically
 adding pkg(s) into the directory. Is there a way to set up change-set.xml
 use wildcard to include all *.pkg under certain directory?
 We are on 5.5.0.Final.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Wildcard-or-list-directory-in-changeset-tp4029536.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Excel Syntax in Decision Tables

2014-05-13 Thread Wolfgang Laun
That's weird, and it looks like a bug in the build process to me: Java
literals are the same for byte, short and int. (CC-ing dev for
possible follow-up: You may be asked to furnish a minimal test case.)

As a workaround, use this in the Action column:
   ...; TaskTemplate1.setId( (short)$param );...

(Note 1: Using short is pretty pointless unless you need to store a
large number in an array. Note 2: Follow Java conventions for names
for class fields and variables.)

-W

On 13/05/2014, crosbis2 drpatrick.co...@gmail.com wrote:
 Hey,

 Not over the finish line yet,

 I tried to build the package, after the rule validated correctly, but got
 the below error relating to the setId method. Have i defined the variable
 correctly i tried $1 and $param.

 The view source code generated here looks the same as that of a previous
 rule i generated in guvnor that works.

 Any Ideas?

 http://drools.46999.n3.nabble.com/file/n4029558/Capture2.png


 http://drools.46999.n3.nabble.com/file/n4029558/Capture3.png







 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029558.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Rules don't execute using MVEL syntax in RHS - Possible Bug

2014-05-12 Thread Wolfgang Laun
Repeated executions show varying results: sometimes it's OK, sometimes it isn't.

I don't think it's a race condition in your code (although proper
syncing on the map would be the clean way to go).

I think that salience doesn't work properly )(6.0.0, OP used 6.0.1.),
if a fact is matched unconditionally by a high salience rule and the
same fact is matched using constraints in rules with lesser priority.

(Wasn't this recognized before as a bug in 6.0.x?)

-W




On 12/05/2014, jlprat jlp...@gmail.com wrote:
 Hi,
 I updated my test code to use your way of creating the Knowledge Base
 (using
 KieBase) and I have the exact same results. Does anyone have an idea why
 this is still failing?

 Furthermore, I think the way I was initializing my rules is also supported
 by Drools 6, because it's almost copied line by line from the Official
 Drools API page:
 https://docs.jboss.org/drools/release/6.0.1.Final/kie-api-javadoc/

 /
 A Typical example to load a rule resource.

 KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
 kbuilder.add( ResourceFactory.newUrlResource( url ),
   ResourceType.DRL );
 if ( kbuilder.hasErrors() ) {
 System.err.println( builder.getErrors().toString() );
 }

 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
 kbase.addKnowledgePackages( builder.getKnowledgePackages() );

 StatefulKnowledgeSession ksession =
 knowledgeBase.newStatefulKnowledgeSession();
 ksession.insert( new Fibonacci( 10 ) );
 ksession.fireAllRules();

 ksession.dispose();/

 Best,
 Josep



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Rules-don-t-execute-using-MVEL-syntax-in-LHS-Possible-Bug-tp4029494p4029517.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Rules don't execute using MVEL syntax in RHS - Possible Bug

2014-05-12 Thread Wolfgang Laun
On 12/05/2014, jlprat jlp...@gmail.com wrote:
 Hi,
 I also thing there is something buggy with salience and the planner.
 However, what puzzles me is that this behavior is changed when using the
 getter instead of the direct access to the property.

 Do you know if there is already a reported bug like this? If there is none,
 I will create one.

 BTW, when you say, /proper syncing on the map/, what do you mean exactly?
 I don't have any map.

You have MapString, Integer ruleCalls, which is updated from the
event handler from the thread running fireUntilHalt() and checked in
the thread inserting the events. The sleeps should be long enough, but
it's not comme-il-faut.

-W


 Best,
 Josep



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Rules-don-t-execute-using-MVEL-syntax-in-LHS-Possible-Bug-tp4029494p4029521.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Excel Syntax in Decision Tables

2014-05-12 Thread Wolfgang Laun
Concerning line 7: You can prefix the empty pattern to another pattern:
taskTemplates : TaskTemplates( )  RuleSet( r... )

Lines 9, 10, 11: You can't write this using the pattern/constraint
approach, it's Java statements. See the documentation.

-W

On 12/05/2014, crosbis2 drpatrick.co...@gmail.com wrote:
 Hi,

 I have a rule i created in Guvnor which works fine (see below)
 But i can not create and import the same rule from a decision table. I can
 not get the syntax to match when i upload the xls and view source.
 Everything below when i have as a Condition
 Everything below then is an Action

 Line 7: will not import. How do you create empty brackets in excel?
 Line 9: how do i write this using the  pattern / constraint approach in
 excel? same with
 Line 11 and 12?

 Any help would be greatly appreciated.

 1.|   rule DecisionA_OptionsAndFutures
 2.|   salience 0
 3.|   dialect mvel
 4.|   when
 5.|   SCOProduct( productBookingPointId == 1 , productTypeId 
 in ( 4,
 5, 20 ) )
 6.|   RuleSet( ruleSetName == SCODecisionPointA )
 7.|   taskTemplates : TaskTemplates( )
 8.|   then
 9.|   TaskTemplate TaskTemplate1 = new TaskTemplate();
 10.   |   TaskTemplate1.setId( 12038 );
 11.   |   insert( TaskTemplate1 );
 12.   |   taskTemplates.addTaskTemplateIfNew( TaskTemplate1 );
 13.   |   end






 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Excel Syntax in Decision Tables

2014-05-12 Thread Wolfgang Laun
On 12/05/2014, crosbis2 drpatrick.co...@gmail.com wrote:
 http://drools.46999.n3.nabble.com/file/n4029529/Capture.png

 i'm still quite new to this i'm afriad.
  I've been able to get every line except 7 and 9 to import and look the
 exact same in view source.

 I don't understand prefix the empty pattern to another pattern:? Say i
 only have one ruleset?

In this case you can use a more elaborate workaround
TaskTemplates(/*$param*/)
and use an 'X' in all the rows ;-) But are you sure you need a
decision table for a table without a decision?


 So it looks like if i don't enter a value in the variable cells the
 condition doesn't appear after import.

That's the whole point. - Are you sure you are using the right rule
authoring mehtod?

 if i write TaskTemplates : TaskTemplates in the constraint cell and say 0
 is
 the variable cell it imports correctly except for the unwanted 0. i.e.:

 TaskTemplates : TaskTemplates(0)

 if i don't enter a value in the variable cells the condition doesn't
 appear after import.

 TaskTemplates : TaskTemplates()

 same story applies with:
 TaskTemplate TaskTemplate1 = new TaskTemplate();

Note that you can combine several Java statements into a single cell.
Typically, there should be at least one value to be inserted into this
code snippet and so you have something to put into the cells below.

-W






 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029529.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Excel Syntax in Decision Tables

2014-05-12 Thread Wolfgang Laun
On 12/05/2014, crosbis2 drpatrick.co...@gmail.com wrote:
 Thanks for the quick replies!!

 So am i naive in thinking if i get the source code of my imported decision
 table to match that of a predefined rule that the excel based rule will
 work?

 Thats what i have now:
 Example 1 is a validated working rule.
 Example 2 is a rule i imported into drools, they are the exact same in my
 eyes except separate statements are on the same line.

 the Validation image below is the error i received, how can this not
 validate if they are the same code?

Nice try, but they are not the same code. An 's' is not equal to '1'.
-W





 http://drools.46999.n3.nabble.com/file/n4029532/example1.png

 http://drools.46999.n3.nabble.com/file/n4029532/example2.png

 http://drools.46999.n3.nabble.com/file/n4029532/error.png



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029532.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Rules don't execute using MVEL syntax in RHS - Possible Bug

2014-05-09 Thread Wolfgang Laun
MVEL has nothing to do with the possibility of using abcXyz in a
constraint instead of the more cumbersome getAbcXyz(). Actually,
abcXyz is the native way of accessing a fact's attribute from within
DRL patterns.

So, if getAbcXyz() works, but abcXyz does not, I suspect that
something else is amiss, perhaps in the code of AnEvent.java, which
hasn't been posted.

-W


On 09/05/2014, jlprat jlp...@gmail.com wrote:
 Hi all,

 I'm developing an application with Drools 6.0.1.Final and I'm encountering
 a
 really strange problem I can't understand, and which I think it's due to a
 bug in MVEL.

 I'm running some rules using fireUntilHalt and if I use the MVEL syntax
 withing the RHS to access some bean properties, some rules don't get
 executed when they should. However if I replace the bean property syntax
 sugar for the real getter method, everything works as it should.

 I've created a little gist to illustrate this problem, it contains 2 drools
 versions (one using MVEL another without) and a test to check the behavior.
 You can check it  Rule is not fired
 https://gist.github.com/jlprat/f20e6dbe976cff163d2c

 Does anybody have an idea why this is happening?


 Thank you in advance.
 Josep Prat



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Rules-don-t-execute-using-MVEL-syntax-in-RHS-Possible-Bug-tp4029494.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Rules don't execute using MVEL syntax in RHS - Possible Bug

2014-05-09 Thread Wolfgang Laun
You are using a class called KnowledgeBuilder. With Drools 6,
it is KieBuilder. Here is some simple code, good for testing (as I used it),
although more sophisticated build procedures are recommended
using maven and what not. - Both DRL versions (getAbxDef and abcDef) appear to
work with 6.0.0 Final.

KieServices kieServices = KieServices.Factory.get();
KieFileSystem kfs = kieServices.newKieFileSystem();
FileInputStream fis = new FileInputStream( lostrule/lostrule.drl );
kfs.write( src/main/resources/lostrule.drl,
kieServices.getResources().newInputStreamResource( fis ) );
KieBuilder kieBuilder = kieServices.newKieBuilder( kfs ).buildAll();
Results results = kieBuilder.getResults();
if( results.hasMessages( Message.Level.ERROR ) ){
System.out.println( results.getMessages() );
throw new IllegalStateException( ### errors ### );
}

KieContainer kieContainer =
kieServices.newKieContainer(
kieServices.getRepository().getDefaultReleaseId() );

KieBaseConfiguration config = kieServices.newKieBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
KieBase kieBase = kieContainer.newKieBase( config );
kieSession = kieContainer.newKieSession();


On 09/05/2014, jlprat jlp...@gmail.com wrote:
 Hi,
 I added the AnEvent class in the gist. You can check it out now:
 https://gist.github.com/jlprat/f20e6dbe976cff163d2c

 Best,
 Josep



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Rules-don-t-execute-using-MVEL-syntax-in-LHS-Possible-Bug-tp4029494p4029496.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Restrict size/resource usage of drools session

2014-05-08 Thread Wolfgang Laun
There are options to restrict the size of the JVM memory allocation pool.

Loops can go over two or more rules, so take care. Catching such loops
is possible, up to a limit.

-W

On 08/05/2014, kurrent93 kurren...@gmail.com wrote:
 Hi

 We have an application where users write their own rules via a UI, and
 these
 are then translated into drl, and run in a dedicated drools session. Each
 user can have one or more sessions.

 However, there are times when something goes wrong - say a rule starts
 looping - and it consumes all the resources - the server is running at 100%
 cpu, and it then effects all users.

 I realize we can optimize the the generated rules to prevent such issues,
 and we are working on this - however am interested to know if there are any
 ways - such as somehow sandboxing / restricting the resources that a drools
 session can use, so that should a rule cause problems, it will not effect
 the other running drools sessions.

 Thanks for any advice on this problem.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Restrict-size-resource-usage-of-drools-session-tp4029486.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Restrict size/resource usage of drools session

2014-05-08 Thread Wolfgang Laun
If you can set a limit for activations following one insert, an
AgendaEventListener registering Before/AfterMatchFired is the natural
choice. You might also limit secondary insertions
(WorkingMemoryEventListener: ObjectInsertedEvent) or fact updates
(ObjectUpdatedEvent).

All of this is highly dependent on the scenarios enacted by the rule set.

-W


On 08/05/2014, kurrent93 kurren...@gmail.com wrote:
 I was thinking of having a master session that can listen to activation
 events of the child sessions, and then can take action should a threshold
 be
 breached.

 Can you recommend what eventlisteners would be useful in this scenario?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Restrict-size-resource-usage-of-drools-session-tp4029486p4029488.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Question about length windows

2014-05-01 Thread Wolfgang Laun
A window:length is filled depending on the constraints but independent
of how old the participating facts are.

What you want to achieve can be done without windows:

   t2_1 : Tick( value  102.352 )
   t1_1 : Tick( this before t2_1 , value = 102.352 )
   not Tick( this before t2_1  after t1_1 )

The last pattern ascertains that the preceding pair of facts is
adjacent. (The three timestamps should be different.)

You can also use rules based on an auxiliary fact maintaining state:
While value  102.352, state is set to below; as soon as a
fact with value = 102.352 matches state == below, the
threshold is passed and state is set to above...

-W


On 02/05/2014, Demian Calcaprina calcacue...@gmail.com wrote:
 Hi Guys, I have one question about how lenght windows will work.

 I have a rule like this. Basically, it is a crosses function, where the
 value of my object crosses a value.

 rule mytest
 dialect mvel
 when
 t2_1 : Tick( value  102.352 ) over window:length (1)
 t1_1 : Tick( this before t2_1 , value = 102.352 ) over window:length (2)
 then
 //DO SOMETHING
 end

 23:51:32,150 INFO  [org.drools.core.audit.WorkingMemoryConsoleLogger]
 (Camel (camel-1) thread #2 - JmsConsumer[]) ACTIVATION FIRED rule:mytest
 activationId:berarrr_1 [0, 27, 26] declarations: t2_1=Tick [value=102.351,
 tickTime=Fri May 02 05:51:31 ART 2014](27); t1_1=Tick [value=102.352,
 tickTime=Fri May 02 05:51:12 ART 2014](26)

 23:53:30,560 INFO  [org.drools.core.audit.WorkingMemoryConsoleLogger]
 (Camel (camel-1) thread #2 - JmsConsumer[]) ACTIVATION CREATED rule:mytest
 activationId:berarrr_1 [0, 146, 26] declarations: t2_1=Tick [value=102.349,
 tickTime=Fri May 02 05:53:30 ART 2014](146); t1_1=Tick [value=102.352,
 tickTime=Fri May 02 05:51:12 ART 2014](26)

 If you see, the first activation, the
 window:length(1), matched the object 27
 window:length(2), matched the object 26

 Then, after 2 minutes and some Ticks insertes in the WM
 window:length(1), matched the object 146
 but window:length(2), still matched the object 26

 I would expect, that, as object 26 was the first one to be inserted, then
 it is outside the window:length(2).

 Is my understanding correct? Am I making something wrong? I am using Drools
 6.

 Thanks!

 Demian

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


Re: [rules-users] Is there a better way to write this rule?

2014-04-23 Thread Wolfgang Laun
On 23/04/2014, Bharadwaj N bharadwaj2...@gmail.com wrote:
 rule Discount Egypt
 salience 0
 when
 $T : TripRequest ( destination == Egypt )
 $dest: DiscountResult()

This is wrong: the rule will not fire unless there is a DiscountResult
fact in working memory.

 then
 $dest=$T.getResult();

This isn't correct either: you cannot assign to a bound variable.

$dest.setDiscount(5);
 end



 On Wed, Apr 23, 2014 at 2:07 PM, Leonard93
 leonardlinde...@hotmail.comwrote:

 When I have the following rule:

 rule Discount Egypt
 salience 0
 when
 $T : TripRequest ( destination == Egypt )
 then
 ((DiscountResult) $T.getResult()).setDiscount(5);
 end


 Is there a better way to do the 'then' part of the rule (when it comes to
 formatting, but still executes the same thing)?
 My request object has a result object that has a method called
 setDiscount
 that needs to be called.

 The setDiscount cannot be in the request object because there are
 multiple
 kinds of Result Objects, thus the casting to its type.

 This rule works fine, I was just wondering if there are any easier ways
 to
 do it. I already found out you can do 'destination' instead of
 'getDestination()' which helps make the rules more readable.





 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Is-there-a-better-way-to-write-this-rule-tp4029327.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


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


Re: [rules-users] Drools Fusion Dropping Actions to Events?

2014-04-22 Thread Wolfgang Laun
On 22/04/2014, Chandra Sekhar Divi chandu_d...@hotmail.com wrote:
 Thanks a lot for the information.
 Adding 'Thread.sleep(1);' after every insert reduces the problem intensity,
 but sometimes even this solution also does not perform all the expected
 actions (May be some events are dropped due to race condition).
 Is there a way I can wait for KIE session to digest the event  before I can
 insert another event?

Not unless you consider inserting and firing all rules in a
synchronous (single-threaded) application. The feasibility depends on
the frequency of arriving events, but if you receive one temperature
reading per minute from each city or town in India (less than 1,700),
you won't have any problems.

FWIW, the race condition does not occur with Drools versions 5.3.0 and
5.5.0; so it should not be in 5.6 either.

-W


 Thanks,
 Chandra.




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-Fusion-Dropping-Actions-to-Events-tp4029314p4029316.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Collect all occurrences of resulting data.

2014-04-21 Thread Wolfgang Laun
This is one of the (rare) cases where I'd advocate salience.

rule Collect results when complete
salience -99
when
$all : List from collect(Result())
then
...do something with $all...
end

-W


On 21/04/2014, Ephemeris Lappis ephemeris.lap...@gmail.com wrote:
 Hello.

 I'm looking for the better way to write a rule that collects data only when
 they have been all processed.

 For example, two input objects classes as facts : *Data* and *Category*.

 I declare a local type to memorize the result of the evaluation for each
 pair of fact.



 Some rule evaluates the Cartesian product of all *Data* by all *Category* :



 Now I want to collect all the results, but only when the previous rule has
 been fired for all the data.
 Something like :



 Any advice ?

 Thanks in advance for your help.

 Regards.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Collect-all-occurrences-of-resulting-data-tp4029296.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Collect all occurrences of resulting data.

2014-04-21 Thread Wolfgang Laun
I recommend at most 3 levels of salience, and only if you have a
very limited scenario of insert / fire.

Alternatively, you can use agenda groups.

If I understand you correctly, you have some rules that execute
Before and others that should execute After. In your .drl,

activation-group Before
rule ... when ... then ... end ... rule ... when ... then ... end
activation-group After
rule ... when ... then ... end ... rule ... when ... then ... end

You can set (the group Before before you insert facts, call
fireAllRules, set After and fire again; then start over again. - See
the Expert manual for some more about activation groups.

Setting the agenda group from Java takes a little digging in the API doc:
   session.getAgenda().getAgendaGroup( Before ).setFocus();

-W



On 21/04/2014, Ephemeris Lappis ephemeris.lap...@gmail.com wrote:
 Hello.

 Thanks for this advice.

 I've tried it with a small test case, and it actually works fine : the
 collecting rule seems to be fired at the end.

 Nonetheless, I'm not confident at all with salience, since in my real
 use case I have many rules before and after that, and I worry that
 salience might move the problem elsewhere, and values must be set to all
 of them to ensure they're all executed according to the expected order.

 At this moment, the rules before the collecting rule also produce facts
 that are expected by the rules that follow it, and, I suppose, it's for
 that reason that all the ending part of the job is executed after the
 correct collection of the intermediary results.

 Another alternative ?

 Thanks again.

 Regards



 Ephemeris Lappis

 Le 21/04/2014 13:11, laune [via Drools] a écrit :
 This is one of the (rare) cases where I'd advocate salience.

 rule Collect results when complete
 salience -99
 when
 $all : List from collect(Result())
 then
 ...do something with $all...
 end

 -W


 On 21/04/2014, Ephemeris Lappis [hidden email]
 /user/SendEmail.jtp?type=nodenode=4029298i=0 wrote:

  Hello.
 
  I'm looking for the better way to write a rule that collects data
 only when
  they have been all processed.
 
  For example, two input objects classes as facts : *Data* and
 *Category*.
 
  I declare a local type to memorize the result of the evaluation for
 each
  pair of fact.
 
 
 
  Some rule evaluates the Cartesian product of all *Data* by all
 *Category* :
 
 
 
  Now I want to collect all the results, but only when the previous
 rule has
  been fired for all the data.
  Something like :
 
 
 
  Any advice ?
 
  Thanks in advance for your help.
 
  Regards.
 
 
 
  --
  View this message in context:
 
 http://drools.46999.n3.nabble.com/Collect-all-occurrences-of-resulting-data-tp4029296.html
  Sent from the Drools: User forum mailing list archive at Nabble.com.
  ___
  rules-users mailing list
  [hidden email] /user/SendEmail.jtp?type=nodenode=4029298i=1
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 ___
 rules-users mailing list
 [hidden email] /user/SendEmail.jtp?type=nodenode=4029298i=2
 https://lists.jboss.org/mailman/listinfo/rules-users


 
 If you reply to this email, your message will be added to the
 discussion below:
 http://drools.46999.n3.nabble.com/Collect-all-occurrences-of-resulting-data-tp4029296p4029298.html


 To unsubscribe from Collect all occurrences of resulting data., click
 here
 http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4029296code=ZXBoZW1lcmlzLmxhcHBpc0BnbWFpbC5jb218NDAyOTI5Nnw0OTQyMjM2NDI=.
 NAML
 http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml







 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Collect-all-occurrences-of-resulting-data-tp4029296p4029300.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.

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


Re: [rules-users] Unit testing a Single rule from a large set of DRL and DSL files.

2014-04-21 Thread Wolfgang Laun
Implement the interface org.kie.api.runtime.rule.AgendaFilter
and pass it in with fireAllRules.
-W


On 21/04/2014, alanvarghese avargh...@verisk.com wrote:
 Hi There,

 I want to unit test a single rule from a set of multiple rules within
 multiple DRL files.
 Is there a way to do that?
 I am using

 Drools 6.0.0.Final
 and
 StatelessKieSession


 Thanks
 Alan



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Unit-testing-a-Single-rule-from-a-large-set-of-DRL-and-DSL-files-tp4029305.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Collect all occurrences of resulting data.

2014-04-21 Thread Wolfgang Laun
Just an additional hint: it's possible to switch between agenda groups
(sorry for using the wrong term, but I didn't confuse you, did I?) from
within rules as well.

-W

On 21/04/2014, Ephemeris Lappis ephemeris.lap...@gmail.com wrote:
 Hello again.

 It seems clear that too many salience levels would make it all worse !

 My ruleset executes over a simple list of initial facts, and proceeds
 more or less as you say in three phases :

 1) Analise initial facts using several deduced facts to make
 intermediary conclusions implemented as locally declared types.

 2) Consolidate the scattered produced facts to build seven main business
 rules : here is where I need to gather all the facts into a unique
 collection. Depending on each of the seven rules, the result may use a
 simple input fact, or, at the opposite, different collections of
 temporary facts...

 3) At the end, for each input fact, generate a global decision using the
 seven rules, and output it into a global map.

 For that, I think that it may be rather reasonable [:)] setting 3
 salience levels representing the three main steps of the rule system.

 I have had a look to the activation groups, but I don't think it could
 match this current need. Moreover this would be more intrusive since
 such a way the Java code should knows the layered structure of the
 rules. At this time the application code just puts the initial facts and
 extract the resulting map to produce a JSON like object to be written
 into a Mongo base...

 Thanks a lot for your help. Any new advice is welcome !

 Best regards.

 Ephemeris Lappis

 Le 21/04/2014 17:48, laune [via Drools] a écrit :
 I recommend at most 3 levels of salience, and only if you have a
 very limited scenario of insert / fire.

 Alternatively, you can use agenda groups.

 If I understand you correctly, you have some rules that execute
 Before and others that should execute After. In your .drl,

 activation-group Before
 rule ... when ... then ... end ... rule ... when ... then ... end
 activation-group After
 rule ... when ... then ... end ... rule ... when ... then ... end

 You can set (the group Before before you insert facts, call
 fireAllRules, set After and fire again; then start over again. - See
 the Expert manual for some more about activation groups.

 Setting the agenda group from Java takes a little digging in the API doc:
session.getAgenda().getAgendaGroup( Before ).setFocus();

 -W



 On 21/04/2014, Ephemeris Lappis [hidden email]
 /user/SendEmail.jtp?type=nodenode=4029304i=0 wrote:

  Hello.
 
  Thanks for this advice.
 
  I've tried it with a small test case, and it actually works fine : the
  collecting rule seems to be fired at the end.
 
  Nonetheless, I'm not confident at all with salience, since in my real
  use case I have many rules before and after that, and I worry that
  salience might move the problem elsewhere, and values must be set to
 all
  of them to ensure they're all executed according to the expected order.
 
  At this moment, the rules before the collecting rule also produce facts
  that are expected by the rules that follow it, and, I suppose, it's for
  that reason that all the ending part of the job is executed after the
  correct collection of the intermediary results.
 
  Another alternative ?
 
  Thanks again.
 
  Regards
 
 
 
  Ephemeris Lappis
 
  Le 21/04/2014 13:11, laune [via Drools] a écrit :
  This is one of the (rare) cases where I'd advocate salience.
 
  rule Collect results when complete
  salience -99
  when
  $all : List from collect(Result())
  then
  ...do something with $all...
  end
 
  -W
 
 
  On 21/04/2014, Ephemeris Lappis [hidden email]
  /user/SendEmail.jtp?type=nodenode=4029298i=0 wrote:
 
   Hello.
  
   I'm looking for the better way to write a rule that collects data
  only when
   they have been all processed.
  
   For example, two input objects classes as facts : *Data* and
  *Category*.
  
   I declare a local type to memorize the result of the evaluation for
  each
   pair of fact.
  
  
  
   Some rule evaluates the Cartesian product of all *Data* by all
  *Category* :
  
  
  
   Now I want to collect all the results, but only when the previous
  rule has
   been fired for all the data.
   Something like :
  
  
  
   Any advice ?
  
   Thanks in advance for your help.
  
   Regards.
  
  
  
   --
   View this message in context:
  
 
 http://drools.46999.n3.nabble.com/Collect-all-occurrences-of-resulting-data-tp4029296.html
   Sent from the Drools: User forum mailing list archive at Nabble.com.
   ___
   rules-users mailing list
   [hidden email] /user/SendEmail.jtp?type=nodenode=4029298i=1
   https://lists.jboss.org/mailman/listinfo/rules-users
  
  ___
  rules-users mailing list
  [hidden email] /user/SendEmail.jtp?type=nodenode=4029298i=2
  https://lists.jboss.org/mailman/listinfo/rules-users
 

Re: [rules-users] Unit testing a Single rule from a large set of DRL and DSL files.

2014-04-21 Thread Wolfgang Laun
You don't lose anything when you use a stateful session, most
certainly not for unit-testing a rule.

-W

On 21/04/2014, alanvarghese avargh...@verisk.com wrote:
 Thank you that was a big help.
 But I see that I cannot use a StatelessKieSession to do that.

 I have to use a Stateful Session.
 Is there anyway I can use a StatelessKieSession to unit test a single rule?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Unit-testing-a-Single-rule-from-a-large-set-of-DRL-and-DSL-files-tp4029305p4029310.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Unit testing a Single rule from a large set of DRL and DSL files.

2014-04-21 Thread Wolfgang Laun
If you do that, you won't be unit-testing the rule as it
operates in cahoots with all other rules :-)

You could put that rule on a DRL file of its own and compile,
create the KB and run the session.

There should be a way to manipulate a Knowledge Package,
handle rules one by one. But that's not a stable API and
I wouldn't recommend that either.

-W


On 21/04/2014, alanvarghese avargh...@verisk.com wrote:
 OK Agreed. I can definitely work with that.
 Thanks Again.

 But my main problem is that the LHS for all the rules in my dslr files
 fires
 as soon as I execute.
 kieSession.insert(output);

 I want only the LHS for the rule that I am unit testing to fire.

 Is there any way to do that?





 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Unit-testing-a-Single-rule-from-a-large-set-of-DRL-and-DSL-files-tp4029305p4029312.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Drools causes switch(enum e) to break?

2014-04-14 Thread Wolfgang Laun
RuleType*s* or RuleType?

Also, you are posting Java code. How is this related to Drools?

Above all, post error messages in full, stating when and due to which
command they are emitted.

-W


On 14/04/2014, Leonard93 leonardlinde...@hotmail.com wrote:
 So I have a really weird problem and I think it could be relate-able to
 Drools, or maybe not but maybe some people here have seen it before.

 I have a simple enum called 'RuleTypes' which is defined in its own file.
 I have somewhere in my class a switch statement where I use the enum like
 this:

 (The method is not finished, but its enough to show the problem)

   public IResult EvaluateRule(Object obj, RuleType type)
   {
   //TODO
   switch(type)
   {
   case Discount :
   TripRequest lr = (TripRequest) obj;
   _Session.execute(lr);
   return lr.getResult();
   case Content:
   break;
   case None:
   break;
   default:
   break;
   }
   
   return null;
   }

 But I get an error saying 'Cannot switch on a value of type RuleType. Only
 convertible int values or enum variables are permitted'. While RuleType an
 enum is 100% sure.

 Yet if I make a new project (with no drools libraries), make the same
 RuleType enum in its own file and have an empty class doing:

   public Test(RuleType type)
   {
   switch(type)
   {
   case Discount :
   break;
   case Content:
   break;
   case None:
   break;
   default:
   break;
   }
   }

 There are no compiler errors. Anyone know here what could possibly happen?
 The only thing I could find was a possible Eclipse bug but that one had a
 fix that does not work for me (
 https://bugs.eclipse.org/bugs/show_bug.cgi?id=413368 ).





 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-causes-switch-enum-e-to-break-tp4029233.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Drools causes switch(enum e) to break?

2014-04-14 Thread Wolfgang Laun
This would mean that setting a project as Drools project has an
impact on the compilation of plain old Java code? That would be
an evil bug in some Drools plugin. Posting all the details might
interest the Drools developer group.
-W


On 14/04/2014, Leonard93 leonardlinde...@hotmail.com wrote:
 The enum is called RuleType, sorry. I am posting this here because this
 error
 only happens within Drools projects, in normal java projects this error
 does
 not happen.

 The error is /Cannot switch on a value of type RuleType. Only convertible
 int values or enum variables are permitted/ no more, no less. It happens
 on
 the   *switch(type)*. I don't really know how it can happen but maybe
 someone
 here could give some pointers.

 Once again, the same switch and enum in a bland java project gives no
 problems.




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-causes-switch-enum-e-to-break-tp4029233p4029235.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Problem with Collection

2014-04-12 Thread Wolfgang Laun
On 12 April 2014 12:57, mohanm mohanm@gmail.com wrote:

 Hi laune,

 Number of facts inserted into the working memory will be high at times.
 Events are facts for us. After first fact matching condition in the working
 memory, we want to wait for few seconds  to collect similar facts and do an
 action on that.


I still don't see a good reason for waiting and doing a collect.
-W



 when we changed any attribute on the facts in the
 collection, the collection got refreshed.

 I tried copying the Collection to another Arraylist in java code, it didnt
 work properly. I will try as per your suggestion to do in the RHS of the
 rule.

 Is there a way to change the attributes of the facts in the collection and
 then update all the facts belonging to particular class.


 Thanks for your reply and suggestion.

 Mohan



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219p4029222.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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

Re: [rules-users] Problem with Collection

2014-04-12 Thread Wolfgang Laun
Making the rules more complicated in order to achieve control over sending
messages to some other application does not strike me as the best option.

As an alternative, processed facts could be collected on the interface
between
Drools and your application A.

-W



On 13 April 2014 05:26, mohanm mohanm@gmail.com wrote:

 Hi Laune,

 Drools is integrated to an application A which is communicating to another
 application B through webservice. Based on the facts in the working memory
 we are going to do send an request to Application B to do some action
 either
 create,update or delete existing events. All the calls to the Application B
 is synchronous. If we have more and more requests going to Application B
 through synchronous calls, Application B is taking time to process those
 requests. we need to limit these calls as low as possible, Any faults at
 device can generate more than 100 events which in turn converted in to
 facts
 and inserted into working memory. For each facts, I don't want to create
 100
 requests to Application B. I need to send only one request to Application B
 for all the facts together, So we are using collection to control this.

 While using collection we were facing the problem as mentioned below.

 Hope I made you understand





 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219p4029227.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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

Re: [rules-users] Problem with Collection

2014-04-11 Thread Wolfgang Laun
If there is no cogent reason for collecting a List and acting on it you
should match a
single Alarm and update it on the rule's right hand side:

rule Rule [Alarm Collection]
when
$alarm: Alarm ( justInserted == true )
then
modify( $alarm ){ setJustInserted( false ) }
end

Note that you still can store a reference to this Alarm in some global or
call Java
code for additional processing.

If you do need a collected List, you'll have to copy it on the rule's right
hand side
before you call your Java code.

ArrayList copy = new ArrayList( $alarmColl );

 The update() call is causing instant reorganisation and the collect result
is some
sort of cache.




On 12 April 2014 05:56, mohanm mohanm@gmail.com wrote:

 Hi,

 I am using Drools 5.5.0 Final Expert to do Alarm Co-relation. I was trying
 to collect the facts in to the ArrayList collection. My drl file will look
 like below. From the Rule I calling an Java method to access the collected
 facts.

 /rule Rule [Alarm Collection]
 no-loop
when
 $alarmColl : ArrayList() from collect(Alarm
  (
 JustInserted == true;
  ))

 then
 // act on $alarmColl
 end/

 while in my Java code I am loop through the collection to set an attribute
 of the Alarm Object. But while I am trying to set this attribute in the
 collection, the collection is getting updated and indexes are changed. Due
 to which all the objects are not updated. Even I tried using the iterator
 to
 access the ArrayList collection. Still the same issue.

 /
 while(index  alarmColl.size()){
 Alarm alarmObj=alarmColl.get(index)

 if(alarmObj.isJustInserted()) {
 alarmObj.setJustInserted(false);
 theScenario.getSession().update(alarmObj);
 }
 index++;
 }/


 How can I update the objects in collection without changing the index or
 any
 other way to achieve this.




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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

Re: [rules-users] Identical Facts over rules, results being cached?

2014-04-09 Thread Wolfgang Laun
OMG, if it would do *that*, its memory consumption would be
enormous, and it wouldn't be much faster, given all the overhead
this would create, and with more GC effort, and the bugs it would
introduce (evil me ;-) )
-W

On 09/04/2014, Leonard93 leonardlinde...@hotmail.com wrote:
 Let's say I have 10 rules and I fire the same object over it multiple
 times.

 This means the result that I would get back is the same every time, since
 it
 is the same object over the same rules (In a stateless environment).
 Does Drools cache the result internally for such cases? Knowing that when
 the same object comes over the same rules it can give the result back right
 away instead of going over the rules first.

 Just something I want to know and couldn't really find in the documentation
 easily.




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Identical-Facts-over-rules-results-being-cached-tp4029169.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Identical Facts over rules, results being cached?

2014-04-09 Thread Wolfgang Laun
If it's general enough, it is not something to be shrugged off as not
that hard.

You'll have to keep the fact and memorize all rules it fires, and
create a mechanism that'll let you call right hand sides when the
duplicate fact
arrives and with all variables bound to the same values. Huh!

-W

On 09/04/2014, Esteban Aliverti esteban.alive...@gmail.com wrote:
 The question here is: what is the result of fireAllRules()? Caching the
 result of this method is trivial: it's just a number! I think that what you
 need to build is your own ad-hoc cache that knows how to extract a 'result'
 out of the session an keep it handy. Implementing this mechanism shouldn't
 be that hard (at least for simple - no nested- Facts) and once you have it
 you can validate the benefits.

 Regards,


 

 Esteban Aliverti
 - Blog @ http://ilesteban.wordpress.com


 On Wed, Apr 9, 2014 at 11:02 AM, Leonard93
 leonardlinde...@hotmail.comwrote:

 Wouldn't that depend on how long the data is being kept and how often
 identical rules are being fired?

 Or would you say the rule engine is faster than all the actions in
 between
 that it wouldnt matter?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Identical-Facts-over-rules-results-being-cached-tp4029169p4029172.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


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


Re: [rules-users] processing a database with many to many Relationships

2014-04-08 Thread Wolfgang Laun
It depends on the rules you're going to have.

Usually the relational (normalized) form lends itself well to writing
rules. OTOH, Drools provides from for unravelling List attributes,
and you can use collect to create a Collection from separate facts.
But, before refactoring the data you have, see how writing rules
against the status quo works out.

-W



On 8 April 2014 20:55, Dave Potts dave.po...@pinan.co.uk wrote:

 Most of the drools examples that I seen, will for have an example that
 process address, look for address with a given post/zip code etc on a data
 source that is already loaded in the knowledge session, but it include no
 description of how the data was loaded in the knowledge session.

 I have a reference database of trading containers , the database describes
 the source, destination, contents etc, relationships between for example a
 container may have have many sources and many destinations.  Destinations
 and sources may be shared between different containers.

 The database is normalised to keep source/destination information as a
 single place table, with link tables to define the relationship between the
 different containers and places

 Q. What is the best way of loading my information in to a knowledge session?

 Expand all the many to many relationship in to a  single pojo objects with
 multiple references to other pojos or is there a better way?

  source
 destination
 eg Container foo  England,
 England
  England
 France
  England
 Scotland
  France
 England
   bar  England
 Germany
  England
 France

 regards


 Dave.



 ___
 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] KIE API for Decision Tables Templates

2014-04-07 Thread Wolfgang Laun
You'll find the classes for dsecision table parsing and DRL building in
and below org/drools/decisiontable/... Sources are in the jar
drools-decisiontables-6.X.X.Final-sources.jar

-W


On 07/04/2014, Andrei Ermicioi aermic...@casenetllc.com wrote:
 Hi there!

 I was looking on web to find if KIE provide any API for reading the Decision
 Tables from XLS/CSV and I was not able to find :(
 Can somebody point me where I can find that or just to tell me if such API
 exist or not.

 Thank you.



 --
 Andrei Ermicioi aka erani,
 Software Engineer at CaseNet

 Phone: +420 776 424 143
 Skype: aermicioi_casenet


 

 CONFIDENTIALITY NOTICE: This e-mail and the information transmitted within
 including any attachments is only for the recipient(s) to which it is
 intended and may contain confidential and/or privileged material. Any
 review, retransmission, dissemination or other use of; or taking of any
 action in reliance upon this information by persons or entities other than
 the intended recipient is prohibited. If you received this in error, please
 send the e-mail back by replying to the sender and permanently delete the
 entire message and its attachments from all computers and network systems
 involved in its receipt.

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


Re: [rules-users] Random rule fire

2014-04-03 Thread Wolfgang Laun
You can insert a fact containing the random number and add a pattern with
the constraint. Where is the problem?


On 2 April 2014 23:45, vvicky72 vvick...@hotmail.com wrote:

 We have a unique situation. Using guided decision tables, we want a
 particular rule to fire randomly even when all the conditions on the when
 clause are satisfied.

 So...
 We want to assign a positive integer to every rule (say n). We want that
 rule to fire only when
 new Random().nextInt(n)+1 = n is true (along with other conditions in the
 rule)

 Any suggestions?

 Thanks,
 Vikas.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Random-rule-fire-tp4029103.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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

Re: [rules-users] Random rule fire

2014-04-03 Thread Wolfgang Laun
Second thoughts: it might be easier to add code to the right hand side to
achieve this random firing.


On 3 April 2014 09:04, Wolfgang Laun wolfgang.l...@gmail.com wrote:

 You can insert a fact containing the random number and add a pattern with
 the constraint. Where is the problem?


 On 2 April 2014 23:45, vvicky72 vvick...@hotmail.com wrote:

 We have a unique situation. Using guided decision tables, we want a
 particular rule to fire randomly even when all the conditions on the
 when
 clause are satisfied.

 So...
 We want to assign a positive integer to every rule (say n). We want that
 rule to fire only when
 new Random().nextInt(n)+1 = n is true (along with other conditions in
 the
 rule)

 Any suggestions?

 Thanks,
 Vikas.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Random-rule-fire-tp4029103.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



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

Re: [rules-users] Activation-group and salience

2014-03-29 Thread Wolfgang Laun
The full reason why the second one fires, although it is in the same
activation group:

. insert Transaction with amount  100
. there are activations for both rules
. rule 1 fires, cancelling the actication for rule 2 (due to AG Group1
. rule 1 updates the matched transaction, causing another activation
of rule 2 (no-loop prohibits this for rule 1)

Advice:
  * Do not rely on salience, no-loop, activation groups. This is
obfuscating your mind, distracting you from the basics, i.e., logic.
  * Add constraints, clearly outlining the case when 1 and when 2 should fire.

rule 1:
  $tx:Transaction(amount  100, ! status)

rule 2:
   $tx:Transaction(amount = 100 )

-W

On 28/03/2014, Nicolas Héron nicolas.heron.j...@gmail.com wrote:
 Hi
 why should rule2 be ignored ?
 when$tx:Transaction();
 So it is true whatever is in transaction.
 Cheers
 Nicolas


 2014-03-28 16:37 GMT+01:00 007reader [via Drools] 
 ml-node+s46999n4029009...@n3.nabble.com:

 I have a group of rules marked with activation-group where I want only
 one rule to fire and ignore the rest. I also want to evaluate rules in
 particular order, so I use salience to prioritize the rules within the
 group. Here are my rules:

 rule rule1
 no-loop
 salience 100
 activation-group Group1
 when
 $tx:Transaction(amount  100);
 then
 $tx.setStatus(true);
 update($tx);
 end

 rule rule2
 salience -50
 activation-group Group1
 when
 $tx:Transaction();
 then
 System.out.println(catch all: +$tx.toString());
 end

 I expect that if Transaction amount100, then rule1 will fire, and rule2
 ignored. However both rules get executed. What am I doing wrong?

 Thx

 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://drools.46999.n3.nabble.com/Activation-group-and-salience-tp4029009.html
  To start a new topic under Drools: User forum, email
 ml-node+s46999n47000...@n3.nabble.com
 To unsubscribe from Drools, click
 herehttp://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=46999code=bmljb2xhcy5oZXJvbi5qYXZhQGdtYWlsLmNvbXw0Njk5OXwxMzk3MTU0MDQw
 .
 NAMLhttp://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml





 -
 Nicolas Héron
 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Activation-group-and-salience-tp4029009p4029012.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.

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


Re: [rules-users] How to do word match in drools?

2014-03-27 Thread Wolfgang Laun
You can use == to compare strings.

For a more comprehensive answer, ask a more detailed question.

-W

On 26/03/2014, Yuan, Stacy [DBA] sta...@telenav.com wrote:
 For example,  word sushi
 I do not want sushie show up and shsushi show up when we do drools match.

 Thanks
 Stacy

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


Re: [rules-users] How to do word match in drools?

2014-03-27 Thread Wolfgang Laun
See inline.


On 27 March 2014 16:59, Yuan, Stacy [DBA] sta...@telenav.com wrote:

 Hi,

 I am new to this area. Thank you very much for your reply!

 This is current script

 brandName matches
 (?i)(.*cyber.*|.*internet.*|.*pizza.*|.*restaurant.*|.*sushi.*)

 So this  matches every string containing sushi.

 Joa Sushie Café
 Java Sushi
 Sushi Blvd
 Japanese Sushi Bar


This is to be expected: each of these 4 lines contains sushi.




 But I only want to match the word sushi. This means  Joa Sushie Café
 will not be included.

 Actually I am looking for word match. What is the best way to include
 above words?


All regular expressions I know have a way for expressing the concept word
boundary.
This is a zero-length assumption (or anchor), that matches a transition
from a word character
to a non-word character. (Note that the definition of word character may
not *always*
meet your expectations, but it should in this case.)



 brandName ==
 (?i)(.*cyber.*|.*internet.*|.*pizza.*|.*restaurant.*|.*sushi.*)???


(The == is bad: you want to do a pattern match.) OK, to restrict the
sushi to the
real thing (assuming the final ??? aren't relevant):

brandName matches (?i)(...|... ...|\\bsushi\\b)

\b is the word boundary anchor, and you have to duplicate the backslash,
as in Java.
 If the same borderline case should hold for pizza and others, you could use

brandName matches
(?i).*\\b(cyber|internet|pizza|restaurant|sushi)\\b.*

All of this is untested, but it shouldn't be very far off the mark.
-W



 Best

 Stacy

 -Original Message-
 From: rules-users-boun...@lists.jboss.org [mailto:
 rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun
 Sent: Thursday, March 27, 2014 12:26 AM
 To: Rules Users List
 Subject: Re: [rules-users] How to do word match in drools?

 You can use == to compare strings.

 For a more comprehensive answer, ask a more detailed question.

 -W

 On 26/03/2014, Yuan, Stacy [DBA] sta...@telenav.com wrote:
  For example,  word sushi
  I do not want sushie show up and shsushi show up when we do drools match.
 
  Thanks
  Stacy
 
 ___
 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] 5.6.0 Final - Weird bug with double multiplication

2014-03-26 Thread Wolfgang Laun
See this:
  http://stackoverflow.com/questions/22610325/double-value-getting-set-to-0

Looks very much like a nasty bug, x*y resulting in 0 when x!=0  y!=0.

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


Re: [rules-users] Drools Fusion inconsistencies at increasing event throughputs

2014-03-25 Thread Wolfgang Laun
A rule with timer will only continue firing if its first true state
remains constant. This means that you can't do what you want to do
this way. (You might set up a rule with a repeating or cron timer that
inserts a Trigger fact that triggers the accumulate and is retracted,
or do some similar haque.)

The session.execute(command) is a rather roundabout way for inserting
facts. If you want to be fast,  use session.insert(.).

Don't use rules for keeping track what's going on, or the Heisenberg
effect will spoil your efforts. It's better to set up insert/retract
listeners, e.g. for maintaining counters of facts per class. This
might give you a better idea of what goes on and wrong. (We'd all be
interested to hear more about the effect you've described!)

Cheers
-W



On 25/03/2014, Vieri vieri.emili...@gmail.com wrote:
 Dear Drools Experts,


 *Short version*


1. Cron-based rules triggers (more than once) for a full second, rather
than once every defined period;
2. After some time, event creation from the drl seems to hang. The time
to hang decreases as we increase the throughput of incoming events;
3. The two issues seem to be somehow related (well, maybe).

 *Full version*


  We are testing Drools Fusion to implement CEP functionalities in our
 platform. We are performing these tests using Drools 6.0.1.Final.

 As a basic test case, we set up a synthetic stream of events, and defined a
 couple of rules to implement a simple throughput metric. Here's the
 complete drl:


 *package* it.intext.unity.test



 *import* it.intext.unity.test.SynthEvent;

 *import* java.util.Date;



 *global* org.slf4j.Logger logger;



 *declare* SynthEvent

 @role( event )

 @timestamp( timestamp )

 *end*



 *declare* EventCounter

   @role( event )

   @timestamp( timestamp )

   id  : *long*

   key : String

   timestamp   : Date

 *end*





 // Business rules

 *rule* Create counter

 *when*

 $e : SynthEvent() *from* entry-point synth

 *then*

 entryPoints[counters].*insert*(*new* EventCounter( $e.getId(), event,
 $e.getTimestamp() ) );

 *end*



 // Metrics

 *rule* Count epm

   // Emit count every 10s, accumulate over 1m

 timer ( cron: 0/10 * * * * ? )

   *when*

 Number( $count : intValue ) *from* *accumulate*(

   EventCounter( key == event ) over window:time( 60s
 )*from*entry-point
 counters, count(1) )

   *then*

 logger.debug(epm = {}, $count );

 *end*


 The SynthEvent class is very basic:


 *public* *class* SynthEvent {



   *long* id;

   Date timestamp;

   ListString meta;

   ... // Getters/Setters and constructors omitted

 }


 Now, the test is performed running the session in one thread (code below)


   *private* *void* process(*final* KieSession session) {

 *new* Thread(){

   *public* *void* run() {

 session.fireUntilHalt();

   };

 }.start();

   }



 while feeding the events on a second thread (code below)


   *private* *void* feed(*final* KieSession session) {

 *new* Thread(){

   @SuppressWarnings(unchecked)

   *public* *void* run() {

 *try* {

  *int* counter = 0;

  *while*(*true*) {

counter++;

session.execute(CommandFactory.
 *newInsert*(createEvent(), *null*, *false*, synth));

Thread.*sleep*(getSleepRate());

*if* ((counter % 1000) == 0) {

  *logger*.debug(Total events: {},
 counter);

}

  }

 } *catch* (InterruptedException e) {

  *logger*.warn({}, e);

 }

   };

 }.start();

   }

 I expected the cron rule count epm to trigger once every 10 seconds. But
 here's an extract from the log (running at 5 events per second +/- 20%):

 [DEBUG] 2014-03-25 04:56:10.008
 (Rule_Count_epm442808096.java:defaultConsequence:14) epm = 1
 [DEBUG] 2014-03-25 04:56:10.075
 (Rule_Count_epm442808096.java:defaultConsequence:14) epm = 2
 [DEBUG] 2014-03-25 04:56:10.262
 (Rule_Count_epm442808096.java:defaultConsequence:14) epm = 3
 [DEBUG] 2014-03-25 04:56:10.507
 (Rule_Count_epm442808096.java:defaultConsequence:14) epm = 4
 [DEBUG] 2014-03-25 04:56:10.678
 (Rule_Count_epm442808096.java:defaultConsequence:14) epm = 5
 [DEBUG] 2014-03-25 04:56:10.871
 (Rule_Count_epm442808096.java:defaultConsequence:14) epm = 6
 [DEBUG] 2014-03-25 04:56:20.001
 (Rule_Count_epm442808096.java:defaultConsequence:14) epm = 50
 [DEBUG] 2014-03-25 04:56:20.042
 (Rule_Count_epm442808096.java:defaultConsequence:14) epm = 51
 [DEBUG] 

Re: [rules-users] Performance of rules in Drools

2014-03-23 Thread Wolfgang Laun
Once the KB+WM is in place, using either approach, it is merely the
insertion time of facts to be matched that counts. A fact's attributes
need to be compared to these parameter sets, given either explicit in
rules or as data in parameter facts.

Comparing a fact f to a set of another facts S requires the comparison
of each attribute of f with all corresponding parameter attributes in
S. Indexing should make this more efficient than it sounds.

With parameters explicit in rules, the rule compiler has the
possibility of combining constraints with identical value into a
single node, thereby reducing the number of necessary comparisons.

In both scenarios, the order of the comparisons should matter: it's
best if the first attribute reduces the number of potential matches
maximally.

That said, the only way to gain some confidence is to run a few
benchmarks, and you'll have to roll your own - only you know the
relevant details. I've exercised the two scenarions outlined before,
and the answer was that one is slower by 40% than the other, with ~ 10
sec for 100 facts, comparing 2 string and 2 int attributes for
equality. So, it doesn't seem to matter much, which way you choose.
But this test is fairly naive - I don't want to be quoted saying that
this is faster than that.

I do think that using parameter facts has some handling advantages.

Cheers
-W


On 23/03/2014, Seb Geek geek...@gmail.com wrote:
 More efficient w.r;t runtime !

 Actually, we generate (automatically by a batch) one rule for each demand
 (set of parameters), even if the demand use the same template than an
 other previous demand with other parameters, so code in rules seams to be
 very duplicated code at the exeption of parameters values ...

 For efficiency at runtime (in term of response time), we want to know if
 code only one rule (with the parameter as a fact in when clause) and
 *not *generate
 different rules for different parameters will be more efficient or not ?

 Regards
 Sébastien




 2014-03-21 18:08 GMT+01:00 Wolfgang Laun wolfgang.l...@gmail.com:

 More efficient w.r.t. runtime, maintenance, development effort,...?

 Writing individual rules is quick, bad for maintenance, and probably
 best, if a session has only a few inputs as it starts fast from a
 precompiled rule base.

 Parameter facts take a little time for development, are very good for
 maintenance (see below) and have a tolerable overhead if they are not
 too numerous and/or the session runs long.

 What should be considered is that a set of parameter facts can be
 maintained by non-technical personnel, e.g., in a spreadsheet or in
 some other data preparation tool. This could be a boon for long-ter
 maintenance.

 -W


 On 21/03/2014, Seb Geek geek...@gmail.com wrote:
  Hello,
 
  I have a list of very similar rules executed in Drools and some
 performance
  problems appear ... I want some advices to choose between two
  direction
  in order to correct them ...
 
  First the context :
  I have to execute always the same check but with different level or
  parameters.
  For example,
  - in the first demand (rule for our client) i have to count and
  retrieve
  the list all Article that have a family code equals to 'A', 'B' or 'C'
 and
  execute the then clause only if there is 3 elements in the filtered
  list.
  - in the second demand (rule for our client) i have to count and
  retrieve
  the list all Article that have a family code equals to 'B' or 'C' and
  execute the then clause only if there is 4 elements in the filtered
  list
  and so on ...
 
  The number of different group of parameter values and the values of
 theses
  parameters will change over time ...
 
  The question is : is it more efficient to implement a lot of different
  rules, each with their parameter in the code OR is it more efficient to
  implement only one rule with an additional object as a drools fact
  containing different parameter's values ?
 
  Thanks for your help
  Sébastien
 

 ___
 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] How to allow non-programmers/non-Drools programmers to define rules

2014-03-21 Thread Wolfgang Laun
Here is a demo for a DSL development: Chapter 5 in
http://members.inode.at/w.laun/drools/DomainSpecificLanguages/DomainSpecificLanguages.pdf

-W




On 21/03/2014, Stephen Masters stephen.mast...@me.com wrote:
 DSL is essentially just templates which map phrases (which may look a bit
 like natural language) to DRL.

 DSLR is the actual rules and looks a bit like normal DRL, except that inside
 the 'when' and 'then' sections you tend to find phrases based on the DSL.
 This is the bit which could possibly be written by a fairly technical
 business user. However it's worth pointing out that it's pretty easy to make
 a mess of it.

 To help avoid problems, if you have Guvnor/Workbench, then the guided editor
 supports building rules based on DSL phrases. This means that users are
 forced to pick valid phrases and use text boxes and (assuming you set them
 up properly) drop-down menus to populate many of the variables. I have had
 operations and legal teams using this quite comfortably, given a little bit
 of training and some decent documentation.

 As an alternative, Paul King has done a number of presentations on using
 Groovy DSLs to build business rules. By using Groovy DSLs and an IDE, you
 get context sensitive help to generate the rules. It makes it easier to
 build up business-readable rules, although it's probably not a solution for
 business users to write the rules themselves. You could take a look at his
 slides here: http://www.slideshare.net/paulk_asert/groovy-rules

 But as Rich mentions, if you can express the rules in a table structure,
 then spreadsheets and (in Guvnor/Workbench) web decision tables are the way
 to go where possible.

 Steve


 On 21 Mar 2014, at 10:11, ankit3j anki...@gmail.com wrote:

 I am a newbie to Drools and have been looking for a way to allow
 non-programmers, mostly administrative guys, to define rules using a
 simple
 language format and minimum coding terms/effort. I came across the
 concept
 of DSL and DSLR and found it useful.

 However, it seems that to use DSL one needs to have a knowledge of
 domain(Java) objects defined. Not only does it defeat the purpose it also
 exposes my Java objects to users. DSLR seems to be a better alternative
 which can be modified by user. But it seems that DSLR is derived from DSL.


 Which one of these 2 should actually be defined/written by user and
 uploaded
 in the system so that backend can create rules based on it?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/How-to-allow-non-programmers-non-Drools-programmers-to-define-rules-tp4028875.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


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


Re: [rules-users] Not able to detect how to correct ERR 102

2014-03-21 Thread Wolfgang Laun
The corrected version of dsl and dslr works fine.
---
[condition][]There is a Customer with first name {name}=
 $customer : Customer(firstName == {name})
[consequence][]Greet Customer=
   System.out.println(Hello  + $customer.getFirstName());
---
package dsltest;
rule hello rule
when
There is a Customer with first name David
then
Greet Customer
end


You don't have to write the DSL all in one line. (I fixed that some time ago.)

The error message suggests that translation fails.
1) Make sure the DSLR is *exactly* as above. (The package could be
different, and there is tolerance w.r.t. spacing between words.)
2) ALWAYS print builder errors (see below).
3) Make sure you pass resources correctly to the builder. This is how
it is done for 5.x:

KnowledgeBaseConfiguration kBaseConfig =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
KnowledgeBuilderConfiguration kbConfig =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder( kbConfig );

Resource dsl  = ResourceFactory.newFileResource( dslPath );
Resource dslr = ResourceFactory.newFileResource( dslrPath );
long t0 = System.currentTimeMillis();
kBuilder.add( dsl,  ResourceType.DSL );
kBuilder.add( dslr, ResourceType.DSLR );
if( kBuilder.hasErrors() ){
System.err.println(  compilation errors  );
KnowledgeBuilderErrors errors = kBuilder.getErrors();
for( KnowledgeBuilderError err: errors ){
System.err.println( err.getMessage() );
}
System.err.println(  compilation errors  );
throw new IllegalStateException( compile errors );
}
kBase = KnowledgeBaseFactory.newKnowledgeBase( kBaseConfig );
kBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
kSession = kBase.newStatefulKnowledgeSession();

-W



On 21/03/2014, Michael Anstis michael.ans...@gmail.com wrote:
 Out of interest what JVM do you use?

 We have this recorded:
 https://bugzilla.redhat.com/show_bug.cgi?id=1078839(but it's on IBM's
 JVM).


 On 21 March 2014 14:17, ankit3j anki...@gmail.com wrote:

 Yes Maxime. They both are in same folder.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Not-able-to-detect-how-to-correct-ERR-102-tp4028884p4028900.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


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


Re: [rules-users] Performance of rules in Drools

2014-03-21 Thread Wolfgang Laun
More efficient w.r.t. runtime, maintenance, development effort,...?

Writing individual rules is quick, bad for maintenance, and probably
best, if a session has only a few inputs as it starts fast from a
precompiled rule base.

Parameter facts take a little time for development, are very good for
maintenance (see below) and have a tolerable overhead if they are not
too numerous and/or the session runs long.

What should be considered is that a set of parameter facts can be
maintained by non-technical personnel, e.g., in a spreadsheet or in
some other data preparation tool. This could be a boon for long-ter
maintenance.

-W


On 21/03/2014, Seb Geek geek...@gmail.com wrote:
 Hello,

 I have a list of very similar rules executed in Drools and some performance
 problems appear ... I want some advices to choose between two direction
 in order to correct them ...

 First the context :
 I have to execute always the same check but with different level or
 parameters.
 For example,
 - in the first demand (rule for our client) i have to count and retrieve
 the list all Article that have a family code equals to 'A', 'B' or 'C' and
 execute the then clause only if there is 3 elements in the filtered list.
 - in the second demand (rule for our client) i have to count and retrieve
 the list all Article that have a family code equals to 'B' or 'C' and
 execute the then clause only if there is 4 elements in the filtered list
 and so on ...

 The number of different group of parameter values and the values of theses
 parameters will change over time ...

 The question is : is it more efficient to implement a lot of different
 rules, each with their parameter in the code OR is it more efficient to
 implement only one rule with an additional object as a drools fact
 containing different parameter's values ?

 Thanks for your help
 Sébastien


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


Re: [rules-users] Confirm the usage of agenda-groups

2014-03-20 Thread Wolfgang Laun
Seems OK to me.
-W

On 19/03/2014, djb dbrownel...@hotmail.com wrote:
 Hi all,

 Sorry if it seems like this is an old question, but it's hard finding a
 simple unambiguous example.  It's a stack, right?  So I push them on
 'backwards'.

 I've got 5 groups of rules, and I want the groups to fire in the order I've
 described the groups as, below.

 I also don't want them to start firing as soon as a fact is inserted, which
 is what seems to happen, according to my activation listener.

 So, would I do this:
 --
 getAgendaGroup( last group to fire ).setFocus();
 getAgendaGroup( second last group to fire ).setFocus();
 getAgendaGroup( middle group to fire ).setFocus();
 getAgendaGroup( second group to fire ).setFocus();
 getAgendaGroup( first group to fire ).setFocus();

 insert(facts)

 fireAllRules()
 --
 ?



 Thanks



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Confirm-the-usage-of-agenda-groups-tp4028813.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Sliding window full length question

2014-03-20 Thread Wolfgang Laun
I'd start a one-shot timer on the arrival of the first Event, to fire
after 60 seconds and insert an auxiliary fact OneMinute and make
those rules depend on the presence of this fact. (Hint: Use extends)

-W

On 20/03/2014, GrantWang grant.w...@intrado.com wrote:
 Hi, I found the following statements in Drools document:

 Sliding windows start to match immediately and defining a sliding window
 does not imply that the rule has to wait for the sliding window to be
 full
 in order to match. For instance, a rule that calculates the average of an
 event property on a window:length(10) will start calculating the average
 immediately, and it will start at 0 (zero) for no-events, and will update
 the average as events arrive one by one.

 Would someone please let me know how I can wait for the sliding windows to
 be full to match? Our requirement is always use the average reading over at
 least 60 seconds.

 Thanks!
 Grant



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Sliding-window-full-length-question-tp4028829.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Needs advice to help Drools on a big problem (and avoid GC overhead)

2014-03-20 Thread Wolfgang Laun
I may fail to understand the fundamentals of this problem, but it seems
to me that it doesn't have the dynamic requirements that would
warrant a full blow up of all Resources and Operations at the same time.

We have the 300 rules, and I'm assuming that the pattern is the one
shown in OP's mail: a Resource subset times an Operation subset. So,
if you insert just one Resource (or Operation) fact together with
all Operation (or Resource) facts and fire all rules, you'll get all Forbids
for the one Resource with all Operations (or vice versa). Then, you
retract the singleton and insert the next one, fire all rules, and so on.

-W


On 20/03/2014, Raphael Jolivet raphael.joli...@gmail.com wrote:
 Thanks for you quick answer.

 Not yet,

 For that I will need to switch to fact insertion instead of Java Set.
 Do you think to will make a difference in the way the RETE Tree will be
 built ?




 2014-03-20 20:27 GMT+01:00 Mark Proctor mproc...@codehaus.org:

 Did you try using the engine in equality mode? It will only ever allow
 one
 equal object to be inserted, others are just ignored.

 Mark
 On 20 Mar 2014, at 18:54, Raphael raphael.joli...@gmail.com wrote:

  Hi,
 
  In our project, we use Drools to compute forbidden allocations as input
 for
  an allocation problem  (for which we do not use Drools BTW).
 
  The constraint of the problem (forbidden operation for given resources)
 are
  expressed as drools rules.
 
  We have about
  -200 resources
  -700 operations
 
  Those are the Drools facts.
  We have about 200 Drools rules describing the forbidden allocations
 
  The problem here is that many rules produce duplicates forbids.
  For instance :
  Rule 1 may forbid Op1 on Res1  Res3
  Rule 2 may forbid Op1 on Res2  res3
 
  Currently the RHS of rules just insert forbids into a pure Java Set (no
 fact
  insertion).
  The Set takes care of avoiding duplicates, but still, we feel we could
 help
  Drools by giving him a hint that
  all rules are actually producing pairs of Resource, Allocation and
 that he
  should not try to produce them more than once.
 
  Currently the structure of each rule looks like that :
 
  when
  $resource : Resource(someconditions)
  $operation : Operation(someconditions)
  then
   globalSet.add(Pairresrouce, operation)
  end
 
  With the size of the problem, we often end up with outOfMem/ GC limit.
  When analyzing memory dump, we see about
  300.000 drools left tuple object.
 
  I am not sure if we could help drools to reduce the Rete tree here.
  I mean, the allocation matrix is already : 200*700 = 140.000 cells.
  Drools only uses 2 nodes for each possible forbids, which seems already
 well
  optimized.
 
  We had several idea to improve that though, but we are not enough
  expert
 in
  the internal of the RETE algorithm to decide if that's a good way to go
  :
 
  1) Insert forbids as facts in the RHS and check they are not already
 there
  in the LHS :
  when
  $resource : Resource(someconditions)
  $operation : Operation(someconditions)
  not Forbid(res=$resource, op=$operation)
  then
   insert(Forbid($resource, $operation))
  end
 
  2) Merge all rules in one big rule with a single RHS
  Is it possible to have something like :
  when
  // Rule 1
  ($resource : Resource(someconditions)
  $operation : Operation(someconditions))
   or
  // Rule 2
  ($resource : Resource(someconditions)
  $operation : Operation(someconditions))
  // Etc ...
  then
   globalSet.add(Pairresrouce, operation)
  end
 
  3) Define a common RHS somewhere and tell Drools all rules use this
  one.
  Is there a possibility in Drools to define reusable RHS ? Would it help
  ?
 
  4) Any other idea ?
 
 
  Thanks in advance for your help.
  Brgds,
 
  Raphael Jolivet
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  --
  View this message in context:
 http://drools.46999.n3.nabble.com/Needs-advice-to-help-Drools-on-a-big-problem-and-avoid-GC-overhead-tp4028838.html
  Sent from the Drools: User forum mailing list archive at Nabble.com.
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users


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


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


Re: [rules-users] Drools Case Based Reasoning

2014-03-18 Thread Wolfgang Laun
CBR as in http://en.wikipedia.org/wiki/Case-based_reasoning?

If the number of identical variables, added with weights, is the
target function, a simple search strategy should be sufficient for
finding the best past case.

-W


On 18/03/2014, gboro54 gbor...@gmail.com wrote:
 This sounds like something that could be accomplished with Planner. Is that
 the case or am I completely off the mark here? My company is looking at
 technologies to do case base planning and since we already use drools for
 other business rules figure I would poke around



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-Case-Based-Reasoning-tp4028784.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Drools Case Based Reasoning

2014-03-18 Thread Wolfgang Laun
On 18/03/2014, gboro54 gbor...@gmail.com wrote:
 That is correct and that is my thought. My company I feel likes to over
 complicate things at times. My thought would be to use drools queries to
 handle the searching of previous cases for the solution. Does that seem
 like
 a reasonable approach?

I'd have to see a few solid use cases before I really pledge my
reputation. I'm not sure how queries can rescue the day, but I think I
could come up with a nice set of technical rules (but see 1st
sentence).

-W



 laune wrote
 CBR as in http://en.wikipedia.org/wiki/Case-based_reasoning?

 If the number of identical variables, added with weights, is the
 target function, a simple search strategy should be sufficient for
 finding the best past case.

 -W


 On 18/03/2014, gboro54 lt;

 gboro54@

 gt; wrote:
 This sounds like something that could be accomplished with Planner. Is
 that
 the case or am I completely off the mark here? My company is looking at
 technologies to do case base planning and since we already use drools
 for
 other business rules figure I would poke around



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-Case-Based-Reasoning-tp4028784.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list


 rules-users@.jboss

 https://lists.jboss.org/mailman/listinfo/rules-users

 ___
 rules-users mailing list

 rules-users@.jboss

 https://lists.jboss.org/mailman/listinfo/rules-users





 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-Case-Based-Reasoning-tp4028784p4028786.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] (no subject)

2014-03-17 Thread Wolfgang Laun
Above all, realize that only facts *insert*-ed into Working Memory can
be taken into account by rules. So, first thing, insert the Event in rule
size. Then you can, basically, write a rule like this:

rule size
when
  $p: RuleContext($size: getOldContext().getParent().getUsableSpace()
  (30*1024*1024))
  not Event( ...?... ) // (!)
then
   Event event =
 new Event(folder almost full, $p.getOldContext().getParent(),
new Date());
   event.display();
   insertLogical( event );
end

The ...?... must be replaced by constraints that check that the
first and second argument of the Event constructor are not there in
the absent Event in the rule marked with // (!)

Cheers
-W

On 17/03/2014, Sandhya Sree sandhyachinna...@gmail.com wrote:
 hi,

 i have the following rule file :

 rule size

 when
  $p: RuleContext($size: getOldContext().getParent().getUsableSpace() 
 (30*1024*1024))
 then
Event event = new Event(folder almost full,
 $p.getOldContext().getParent(), new Date());
event.display();
 end


 im loading this rule file and executing the rules once in 10 seconds in a
 continuous loop from my java class. assuming the when part is always true,
 the event object created gets displayed each and every time once in 10
 seconds. i want to create the object only once with the fact that the event
 is already there.. i.e.  i dont want to create the object again if it is
 already created.. how can i do that?


 Thanks.

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


Re: [rules-users] problem in sliding window

2014-03-17 Thread Wolfgang Laun
On 17/03/2014, Sandhya Sree sandhyachinna...@gmail.com wrote:

 declare window Ticks
 Event()
 over window:time(1m )
 end

Is there any documentation snippet that says you can declare a fact
(not even an event) like this, restricting its existence?

If not, why does this not cause an compilation error?

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


Re: [rules-users] IllegalStateException:

2014-03-14 Thread Wolfgang Laun
The clarity and precision of your descriptions is unsurpassed.
-W

On 14/03/2014, Raja Sekhar raja.amir...@gmail.com wrote:
 We are using storm in big data stack, we are reading data from database and
 apply rules on them.
 This is how storm works we have a topology and a spout(input) and
 bolts(processing and output). spouts will be reading from DB and sending
 them to the bolt. The bolt will initiate a  kiesession and fire the rules
 after a threshold is reached. the threshold  will be decided by spout Here
 what is happening , suppose we are processing a set of 500 records, 250 are
 getting processed and 250 are getting failed
 Please suggest



 On 14 March 2014 15:53, Davide Sottara dso...@gmail.com wrote:

  Major bugs are usually backported.. are you sure that this fix addresses
 your problem?
 In general, if you don't provide a detailed description of your
 environment and your
 problem, it will be extremely difficult to help you


 On 03/14/2014 10:03 AM, Raja Sekhar wrote:

 Hi Davide,
 I see that i am loosing the session since i am running is multi-threaded
 environment
 I see the following URL
 https://github.com/droolsjbpm/drools/pull/256/files

  Are these changed to main branch for version 6.0.1

  Regards,
 Raj



 On 13 March 2014 23:46, Davide Sottara dso...@gmail.com wrote:

  Do you call session.dispose() after you fire your rules?
 That exception means that your stateful session was disposed,
 and you can no longer call methods to insert facts or fire rules
 (or anything if that matters) on a session that has been disposed.
 If so, you'll need to create a new one.
 Davide


 On 03/13/2014 07:06 PM, Raja Sekhar wrote:

 Iam using Stateful sessions .
 On Mar 13, 2014 11:27 PM, Davide Sottara dso...@gmail.com wrote:

  Are you using stateful or stateless sessions?
 Davide

 On 03/13/2014 05:01 PM, Raja Sekhar wrote:

 Hi
 Can someone help me with this.

  Regards
 Raj


 On 13 March 2014 14:05, Raja Sekhar raja.amir...@gmail.com wrote:

 Hi
 Iam processing dataset stream with storm. After receiving the first
 set
 of records the rule is firing. For next set of records i getinet this
 exception
 Illegal method call. This session was previously disposed
 I after firing the rules the session is get disposed. I am not getting
 where to reeslish the session. Also how i do  i know  if the session
 is
 alive or not?

 --
 Raja Sekhar Amirapu
 --
 If any anyone can do it, i can do it. If no one else can do it, i
 must
 do it




  --
 Raja Sekhar Amirapu
 --
 If any anyone can do it, i can do it. If no one else can do it, i must
 do it


 ___
 rules-users mailing
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users



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



 ___
 rules-users mailing
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users



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




  --
 Raja Sekhar Amirapu
 --
 If any anyone can do it, i can do it. If no one else can do it, i must
 do
 it


 ___
 rules-users mailing
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users



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




 --
 Raja Sekhar Amirapu
 --
 If any anyone can do it, i can do it. If no one else can do it, i must do
 it

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


Re: [rules-users] Global type integer - Unexpected global

2014-03-14 Thread Wolfgang Laun
The error you are getting occurs if the knowledge base doesn't
contain the global at all. - Do you check for compilation errors
after building? Does a simple rule

rule hello
when
then
   System.out.println( Hello );
end

fire if you add it to your DRL?

-W

On 14/03/2014, Faraniaina Domoina Rabarijaona
rabarijaonadomo...@gmail.com wrote:
 Hello,

 I have a global integer in my drl file and I use it in a rule like this:

 global int id;

 when
f: MyFact();
 then
   MyClass mc=new MyClass();
  mc.setId(id);
 end;

 On my java code, I have:
 int id=3
 ksession.setGlobal(id, id);

 But I get the error: Unexpected global [id].
 I just test without the global in the RHS, like this:

 then
   MyClass mc=new MyClass();
  int x=3;
  mc.setId(x);
 end;

 It's working.

 What am I doing wrong ?
 I tried with the type Integer (java.lang.Integer), but same problem.

 If anyone can help me,

 Thanks,

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


Re: [rules-users] Temporal rules in decision table

2014-03-12 Thread Wolfgang Laun
You can create a rule with a timer to update Current with the required
frequency.

rule set current
   timer (int: 1s 1s)
   no-loop
when
   $c: Current()
then
   modify( $c ){ setXYZ(whatever) }
end



On 11/03/2014, Ioannis Christodoulou io.chris...@gmail.com wrote:
 Thanks a lot for the prompt reply and the detailed example!
 It took me some time but I managed to convert it to a working xls decision
 table.

 Now, I wanted to figure out how to automatically update the Current object
 regularly, in order to re-calculate the rules over time.
 My application is a java ee one. Would creating a @schedule on a singleton
 method be a good solution, or is there another better advice for it?

 Thanks again!

 Ευχαριστώ πολύ,
Ιωάννης Χριστοδούλου


 On Tue, Mar 11, 2014 at 8:50 PM, Wolfgang Laun
 wolfgang.l...@gmail.comwrote:

 As you have Level with a field date, you can access that point in time in
 milliseconds, using getTimeInMillis(). For the current time, you might
 insert an object of class Current with a member now of class Calendar.

 rule closest
 when
 Current( $now: now )
 $level: Level( $value == 2, $date: date )
 not $x: Level( Math.abs( $x.getDate().getTimeInMillis() -
 $now.getTimeInMillis() )  Math.abs( $date.getTimeInMillis() -
 $now.getTimeInMillis() ) )
 then
 // $level is the Level fact closest to Current with a level of 2
 end

 Untested. If the long expression gives you trouble, try enclosing it in
 eval(...).
 -W


 On 11 March 2014 18:14, JChrist io.chris...@gmail.com wrote:

 Hello everyone,
 I was messing with drools v6.0.1.Final the past week and I have not been
 able to completely understand how to integrate the rule engine to my
 specification.

 For the needs of my project, I want to regularly insert some data in the
 engine, similar to the following:
 class Level { double value;Calendar date; }
 this class contains some values at specific time points (both in the
 past
 and in the future).

 I would like to be able create a decision table based on the current
 time
 (plus or minus a variable offset) and the value of the closest Level to
 that
 time point.

 For example, assuming it is '2014-11-03 19:10:00' and the level objects
 in
 the session currently are:
 '1.0 2014-11-03 18:00:00' and '2.0 2014-11-03 19:00:00',

 I would want a rule to say that if current level value is 2.0 then do
 some
 stuff and it would make a match.

 I would really appreciate any help on how to overcome this issue, as
 well
 as
 any good examples/tutorials regarding this.

 Kind regards.




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Temporal-rules-in-decision-table-tp4028638.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



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



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

Re: [rules-users] Drools pipeline API

2014-03-11 Thread Wolfgang Laun
I think this is what you're looking for:

http://stackoverflow.com/questions/22181625/use-drools-6-0-new-phreak-algorithm-by-using-the-5-5-legacy-api/22190799#22190799

-W

On 10/03/2014, GrantWang grant.w...@intrado.com wrote:
 Thanks, Mark.

 Would you please help with my 2nd question, i.e. the best way to monitor
 several directories and load DRL files on the fly in Drools 6.0 release?

 Best regards.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-pipeline-API-tp4028616p4028625.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] Large data sets

2014-03-11 Thread Wolfgang Laun
On 11/03/2014, Raja Sekhar raja.amir...@gmail.com wrote:
 Hi
 Is it a good approach to apply rules on large data-sets ranging 100,000 to
 50 million records Of course it depends upon the logic written in the rule
 conditions and consequences.

Yes, it depends. And on what the consequences do. And on how you
insert and call fireAllRules().

-W



 --
 Raja Sekhar Amirapu
 --
 If any anyone can do it, i can do it. If no one else can do it, i must do
 it

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


Re: [rules-users] Large data sets

2014-03-11 Thread Wolfgang Laun
If you can insert one fact, you can insert many facts: just write a
loop getting the objects and calling session.insert(.).

Other decisions depend on the structure of your rule base, and what
needs to be done with the facts: can they be processed one by one or
do they all have to be together in Working Memory, e.g., to find
matching pairs, conflicting groups,...

-W


On 11/03/2014, Mercier Jonathan jmerc...@genoscope.cns.fr wrote:
 On 11/03/2014, Raja Sekhar raja.amir...@gmail.com wrote:
 Hi
 Is it a good approach to apply rules on large data-sets ranging 100,000
 to
 50 million records Of course it depends upon the logic written in the
 rule
 conditions and consequences.
 Wolfgang you say:

 Yes, it depends. And on what the consequences do. And on how you
 insert and call fireAllRules().


 I am interested by a little example how to insert large data set and
 call them efficiently.

 Regards
 ___
 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] Temporal rules in decision table

2014-03-11 Thread Wolfgang Laun
As you have Level with a field date, you can access that point in time in
milliseconds, using getTimeInMillis(). For the current time, you might
insert an object of class Current with a member now of class Calendar.

rule closest
when
Current( $now: now )
$level: Level( $value == 2, $date: date )
not $x: Level( Math.abs( $x.getDate().getTimeInMillis() -
$now.getTimeInMillis() )  Math.abs( $date.getTimeInMillis() -
$now.getTimeInMillis() ) )
then
// $level is the Level fact closest to Current with a level of 2
end

Untested. If the long expression gives you trouble, try enclosing it in
eval(...).
-W


On 11 March 2014 18:14, JChrist io.chris...@gmail.com wrote:

 Hello everyone,
 I was messing with drools v6.0.1.Final the past week and I have not been
 able to completely understand how to integrate the rule engine to my
 specification.

 For the needs of my project, I want to regularly insert some data in the
 engine, similar to the following:
 class Level { double value;Calendar date; }
 this class contains some values at specific time points (both in the past
 and in the future).

 I would like to be able create a decision table based on the current time
 (plus or minus a variable offset) and the value of the closest Level to
 that
 time point.

 For example, assuming it is '2014-11-03 19:10:00' and the level objects in
 the session currently are:
 '1.0 2014-11-03 18:00:00' and '2.0 2014-11-03 19:00:00',

 I would want a rule to say that if current level value is 2.0 then do some
 stuff and it would make a match.

 I would really appreciate any help on how to overcome this issue, as well
 as
 any good examples/tutorials regarding this.

 Kind regards.




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Temporal-rules-in-decision-table-tp4028638.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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

  1   2   3   4   5   6   7   8   9   10   >