First of all you can try adding:
$ae1 :Event(symbol == 1, $Pr1 : price) and
$ce1 :Event(this != $ae1, symbol == 1, price > ($Pr1/1.2), this after $ae1
)
That will avoid the cross product.
Post again the result with that.
2009/9/17 PF <pif1979(a)gmail.com>
Hi guys,
We made some experiments with Drools Fusion and we wonder if there is any
way to speed it up. In our experiments, we detected complex events in
streams of stock tickers and got times significantly slower with Drools than
with other CEP systems (and also higher memory consumption in the same order
of magnitude):
Number of events Drools 5.0 Fusion Esper 3.1.0 Etalis with SWI Prolog
Etalis with Yap Prolog
10000 1179 453 328 265 (time in miliseconds to process the stream of
events)
20000 2359 828 701 531
30000 3538 1141 1023 780
40000 4718 1500 1356 1078
50000 5897 1813 1702 1329
I can provide some of our code if someone needs it (beside what I pasted
below).
Please tell me if you know any obvious optimizations? Or if you think this
is due to Java (vs. C in other implementations), or any other reasons.
Thank you, regards,
Paul Fodor
Our program has 5 rules to detect complex events:
fusion.drl:
rule "experiment A -Rule 0/0"
when
$ae1 :Event(symbol == 1, $Pr1 : price) and
$ce1 :Event(this after $ae1 , symbol == 1, price > ($Pr1/1.2) )
then
//System.out.println("Ce1 fired !");
end
rule "experiment A -Rule 0/1"
when
(
$ae2 :Event(symbol == 2,$Pr2 : price) and
$ce2 : Event(this after $ae2 , symbol == 2,price > ($Pr2/1.2) )
)
then
//System.out.println("Ce2 fired !");
end
rule "experiment A -Rule1"
when
(
$ae1 :Event(symbol == 1, $Pr1 : price) and
$ce1 :Event(this after $ae1 , symbol == 1, price > ($Pr1/1.2) )
)
or
(
$ae2 :Event(symbol == 2,$Pr2 : price) and
$ce2 : Event(this after $ae2 , symbol == 2,price > ($Pr2/1.2) )
)
then
//System.out.println("Ce3 fired !");
end
rule "experiment A -Rule4"
when
(
$ae1 :Event(symbol == 1, $Pr1 : price) and
$ce1 :Event(this after $ae1 , symbol == 1, price > ($Pr1/1.2) )
)
and
(
$ae2 :Event(symbol == 2,$Pr2 : price) and
$ce2 : Event(this after $ae2 , symbol == 2,price > ($Pr2/1.2) , this
after[0,20m] $ce1 )
)
then
//System.out.println("Ce4 fired !");
end
rule "experiment A -Rule5"
when
(
$ae1 :Event(symbol == 1, $Pr1 : price) and
$ce1 :Event(this after $ae1 , symbol == 1, price > ($Pr1/1.2))
)
and
(
$ae2 :Event(symbol == 2,$Pr2 : price) and
$ce2 : Event(this after $ae2 , symbol == 2,price > ($Pr2/1.2) , this
overlaps $ce1)
)
then
//System.out.println("Ce5 fired !");
end
We have an Event class for events with its parameters and an EventStream
class to fire the events:
EventStream.java:
...
import org.drools.runtime.StatefulKnowledgeSession;
public class EventStream {
public StatefulKnowledgeSession get_working_session() { return ksession;}
...
void generateEventStream(double duration, double p) {
...
//Drools
Event temp = new Event(symbol,currValue);
ksession.insert(temp);
...
}
}
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users