Re: [rules-users] Writing a pattern in which each event constraint depends on the previous event

2011-01-30 Thread Wolfgang Laun
2011/1/31 Greg Barton 
>
> Yes, the accumulate function itself should maintain the sort internally.

Which, in this case, means that the timestamp can't be in the
FactHandle, i.e., it must be a field of the class representing the
fact and set by code when the fact is inserted (or received in the
system).

I don't really know (from the first mail in this thread) what the rule
should detect, i.e., due to which condition it should fire. But to
detect a monotonically decreasing sequence over a window of a givent
length it is sufficient to check for the absence of any increase from
one event to a later event. Therefore, a simple "not" pattern should
do. Another pattern would have to ascertain that there are at least 2
elements.

$a : StockTick( $p: price ) over window:time(20s)
exists StockTick( this after $a) over window:time(20s)
not StockTick( this after $a, price >= $p ) over window:time(20s)

-W


>
> @OlliSee : See the thread titled "How to write a rule that fires when it 
> matches against specific facts in working memory."
> --- On Sun, 1/30/11, Wolfgang Laun  wrote:
>
> From: Wolfgang Laun 
> Subject: Re: [rules-users] Writing a pattern in which each event constraint 
> depends on the previous event
> To: "Rules Users List" 
> Date: Sunday, January 30, 2011, 10:25 AM
>
>
>
> On 30 January 2011 12:55, OlliSee  wrote:
>
> @Wolfgang: I guess you are referring to the list I use. Of course I expect
> them to be ordered by timestamp.
>
>
> You sure do, but the question is whether you get them in this order during 
> processing by accumulate. There is no documentation that accumulate passes 
> through a set of selected facts in the order they were inserted. It could 
> just as well be the (random) order of some hash key, or reverse, or whatever.
>
> -W
>
>
>
> --
> View this message in context: 
> http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2383235.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> -Inline Attachment Follows-
>
> ___
> 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] Writing a pattern in which each event constraint depends on the previous event

2011-01-30 Thread Greg Barton
Yes, the accumulate function itself should maintain the sort internally.
@OlliSee : See the thread titled "How to write a rule that fires when it 
matches against specific facts in working memory."
--- On Sun, 1/30/11, Wolfgang Laun  wrote:

From: Wolfgang Laun 
Subject: Re: [rules-users] Writing a pattern in which each event constraint 
depends on the previous event
To: "Rules Users List" 
Date: Sunday, January 30, 2011, 10:25 AM



On 30 January 2011 12:55, OlliSee  wrote:



@Wolfgang: I guess you are referring to the list I use. Of course I expect

them to be ordered by timestamp.


You sure do, but the question is whether you get them in this order during 
processing by accumulate. There is no documentation that accumulate passes 
through a set of selected facts in the order they were inserted. It could just 
as well be the (random) order of some hash key, or reverse, or whatever.


-W

 
--

View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2383235.html


Sent from the Drools - User mailing list archive at Nabble.com.

___

rules-users mailing list

rules-users@lists.jboss.org

https://lists.jboss.org/mailman/listinfo/rules-users




-Inline Attachment Follows-

___
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] Writing a pattern in which each event constraint depends on the previous event

2011-01-30 Thread Wolfgang Laun
On 30 January 2011 12:55, OlliSee  wrote:

>
> @Wolfgang: I guess you are referring to the list I use. Of course I expect
> them to be ordered by timestamp.
>


You sure do, but the question is whether you get them in this order during
processing by accumulate. There is no documentation that accumulate passes
through a set of selected facts in the order they were inserted. It could
just as well be the (random) order of some hash key, or reverse, or
whatever.

-W



> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2383235.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Writing a pattern in which each event constraint depends on the previous event

2011-01-30 Thread OlliSee

@Greg: Could you hand me a link to that discussion?

@Wolfgang: I guess you are referring to the list I use. Of course I expect
them to be ordered by timestamp.
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2383235.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Writing a pattern in which each event constraint depends on the previous event

2011-01-29 Thread radai.rosenblatt

how about numbering your ticks ?
as a rough outline, this might look something like:

1st : Tick ($number : num)
2nd : Tick (num == $number+1, {this.value below 1st.value})
3rd : Tick (num == $number+2, {this.value above 2nd.value})

this should find all "bottoms"

-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2382430.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Writing a pattern in which each event constraint depends on the previous event

2011-01-29 Thread Wolfgang Laun
Is there a *defined *order in which objects resulting from an "over" clause
are presented to the preceding from? Otherwise, an accumulate function
requiring a specific order is based on implementation details.
-W

On 29 January 2011 18:24, Greg Barton  wrote:

> See the current discussion of accumulate functions.  That should satisfy
> your need.
>
> GreG
>
> On Jan 29, 2011, at 10:18, OlliSee  wrote:
>
> >
> > Hello everyone.
> >
> > Lets say we have StockTicks...
> > Is it possible to detect a monotonically decreasing StockTick stream over
> a
> > window?
> >
> > If I knew the number of events I want to check on, I'd do it this way
> >
> > $a : StockTick() over window:time(20s)
> > $b : StockTick(this after $a, price < $a.price) over window:time(20s)
> > ...
> >
> > But I don't know for how long the StockTick prices continue to decrease..
> > I imagine doing something like that
> >
> > $list : List(size > 0) from collect(StockTick() over window:time(20s))
> > forall($a : StockTick() from $list
> >$b : StockTick(this after $a, price < $a.price from $list
> > )
> >
> > That results in a nice exception.
> > Any idea how to do this work? And more efficiently than my approach?
> >
> > Thanks
> > Oliver
> >
> >
> >
> > Exception in thread "Thread-1" java.lang.ClassCastException:
> > org.drools.common.DefaultFactHandle cannot be cast to
> > org.drools.common.EventFactHandle
> >at
> >
> org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:336)
> >at
> >
> org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110)
> >at
> >
> org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:115)
> >at
> >
> org.drools.common.DoubleBetaConstraints.isAllowedCachedLeft(DoubleBetaConstraints.java:166)
> >at
> >
> org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274)
> >at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
> >at
> >
> org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220)
> >at
> >
> org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81)
> >at
> >
> org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:279)
> >at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
> >at
> >
> org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220)
> >at
> >
> org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81)
> >at
> >
> org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:662)
> >at
> org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:270)
> >at
> >
> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)
> >at
> >
> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:378)
> >at
> org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
> >at
> org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
> >at
> >
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1187)
> >at
> >
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1089)
> >at
> >
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:893)
> >at
> >
> org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:238)
> >
> > --
> > View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2370165.html
> > Sent from the Drools - User mailing list archive at Nabble.com.
> > ___
> > rules-users mailing list
> > rules-users@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
>
> ___
> 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] Writing a pattern in which each event constraint depends on the previous event

2011-01-29 Thread Greg Barton
See the current discussion of accumulate functions.  That should satisfy your 
need.

GreG

On Jan 29, 2011, at 10:18, OlliSee  wrote:

> 
> Hello everyone. 
> 
> Lets say we have StockTicks... 
> Is it possible to detect a monotonically decreasing StockTick stream over a
> window? 
> 
> If I knew the number of events I want to check on, I'd do it this way 
> 
> $a : StockTick() over window:time(20s) 
> $b : StockTick(this after $a, price < $a.price) over window:time(20s) 
> ... 
> 
> But I don't know for how long the StockTick prices continue to decrease.. 
> I imagine doing something like that 
> 
> $list : List(size > 0) from collect(StockTick() over window:time(20s)) 
> forall($a : StockTick() from $list 
>$b : StockTick(this after $a, price < $a.price from $list 
> ) 
> 
> That results in a nice exception. 
> Any idea how to do this work? And more efficiently than my approach? 
> 
> Thanks 
> Oliver 
> 
> 
> 
> Exception in thread "Thread-1" java.lang.ClassCastException:
> org.drools.common.DefaultFactHandle cannot be cast to
> org.drools.common.EventFactHandle
>at
> org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:336)
>at
> org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110)
>at
> org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:115)
>at
> org.drools.common.DoubleBetaConstraints.isAllowedCachedLeft(DoubleBetaConstraints.java:166)
>at
> org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274)
>at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
>at
> org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220)
>at
> org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81)
>at
> org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:279)
>at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
>at
> org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220)
>at
> org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81)
>at
> org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:662)
>at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:270)
>at
> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)
>at
> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:378)
>at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
>at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
>at
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1187)
>at
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1089)
>at
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:893)
>at
> org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:238)
> 
> -- 
> View this message in context: 
> http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2370165.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

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


[rules-users] Writing a pattern in which each event constraint depends on the previous event

2011-01-29 Thread OlliSee

Hello everyone. 

Lets say we have StockTicks... 
Is it possible to detect a monotonically decreasing StockTick stream over a
window? 

If I knew the number of events I want to check on, I'd do it this way 

$a : StockTick() over window:time(20s) 
$b : StockTick(this after $a, price < $a.price) over window:time(20s) 
... 

But I don't know for how long the StockTick prices continue to decrease.. 
I imagine doing something like that 

$list : List(size > 0) from collect(StockTick() over window:time(20s)) 
forall($a : StockTick() from $list 
$b : StockTick(this after $a, price < $a.price from $list 
) 

That results in a nice exception. 
Any idea how to do this work? And more efficiently than my approach? 

Thanks 
Oliver 



Exception in thread "Thread-1" java.lang.ClassCastException:
org.drools.common.DefaultFactHandle cannot be cast to
org.drools.common.EventFactHandle
at
org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:336)
at
org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110)
at
org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:115)
at
org.drools.common.DoubleBetaConstraints.isAllowedCachedLeft(DoubleBetaConstraints.java:166)
at
org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81)
at
org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:279)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81)
at
org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:662)
at 
org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:270)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:378)
at 
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
at 
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1187)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1089)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:893)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:238)

-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2370165.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users