[rules-users] Inconsistent behaviour of insertLogical in rules having from pattern

2014-08-28 Thread Vincent LEGENDRE
Hi all, 

It is 2 days I am fighting with a strange behaviour of insertLogical in rules 
having from pattern in conditions : it works the first time, and not after ... 

- 
Here is my use-case (simplified) : 

I have a class that represent a Flight. A Flight has a start/end datetime and 
is associated with a Airplane and a list of Crew : 
class Flight { 
String airplaneId; 
ListString crewIds; 
Date start; 
Date end; 
} 

I want to maintain an alert list that contains all overlaps for each airplane 
and each crew. So I have rules like: 

rule Overlap Airplane 
when 
$f1 : Flight($airplaneId : airplaneId) 
$f2 : Flight(this != $1, airplaneId == $airplaneId, ... and periods 
intersecting ... ) 
then 
insertLogical(new Alert(...)); 
end 

rule Overlap Crews 
when 
$f1 : Flight() 
$crew : String from $f1.getCrewIds() 
$f2 : Flight(this != $1, eval($f2.getCrewIds().contains($crew)) , ... and 
periods intersecting ... ) 
then 
insertLogical(new Alert(...)); 
end 


- 
Ok. So what I do to test all that stuff : 
- create a new session 
- add a first single Flight -- no alerts at all, normal 
- add a second Flight insersecting the first one with same airplane and same 
crews list -- 3 new alerts inserted (one for airplane, one for each crew) : 
normal 
- remove this second Flight -- the 3 preivous alerts are retracted : still ok 
- re-add this second Flight -- only the 'airplane' rule triggers, I only get 
one new alert insteads of the previous same 3  The alerts not inserted 
correspond to the rule having 'from' in it 


- 
To test that it is the source of the problem, I add a new explicit association 
object that I insert in WM : 
class CrewAffectation { 
String idCrew; 
String idFlight; 
} 

For each inserted Flight, I also insert corresponding new CrewAffectation 
objects. (in case of retract, I retract them of course). 
I change the last rule to something like : 

rule Overlap Crews 
when 
$f1 : Flight($id1 : id 
$f2 : Flight(this != $1, $id2 : id, ... and periods intersecting ... ) 
$crewAff1 : CrewAffectation($idCrew : idCrew, idFlight== $id1) 
$crewAff2 : CrewAffectation(idCrew == $idCrew, idFlight== $id2) 
then 
insertLogical(new Alert(...)); 
end 
And with this 'no-from' approach, everything is working as expected. 

- 
In addition, I suspect the truth maintenance system to have leaks, and notably 
in the source kBase. 
Why ? Because I was facing problems by reusing the same kBase to generate 
multiples kSessions : The first session created reacted well, while all the 
folowing not. 
And it was in fact the same problem as the one described here : usage of from 
and insertLogical in the same rule. 
The first created session adds and retract my 3 alerts, the second created 
session only adds the airplane alert. 

With using the explicit association object, I can reuse my kBase and everything 
is working well. 

- 
Does someone already faced the problem ? 
Does it looks like a real bug to dev team or am I doing something wrong (but as 
it work once, I guess it is a bug) ? 


Vincent 

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

Re: [rules-users] Inconsistent behaviour of insertLogical in rules having from pattern

2014-08-28 Thread Vincent LEGENDRE
Forgot to say : using drools 5.6.FINAL 

- Mail original -

De: Vincent LEGENDRE vincent.legen...@eurodecision.com 
À: Rules Users List rules-users@lists.jboss.org 
Envoyé: Jeudi 28 Août 2014 15:28:49 
Objet: [rules-users] Inconsistent behaviour of insertLogical in rules having 
from pattern 

Hi all, 

It is 2 days I am fighting with a strange behaviour of insertLogical in rules 
having from pattern in conditions : it works the first time, and not after ... 

- 
Here is my use-case (simplified) : 

I have a class that represent a Flight. A Flight has a start/end datetime and 
is associated with a Airplane and a list of Crew : 
class Flight { 
String airplaneId; 
ListString crewIds; 
Date start; 
Date end; 
} 

I want to maintain an alert list that contains all overlaps for each airplane 
and each crew. So I have rules like: 

rule Overlap Airplane 
when 
$f1 : Flight($airplaneId : airplaneId) 
$f2 : Flight(this != $1, airplaneId == $airplaneId, ... and periods 
intersecting ... ) 
then 
insertLogical(new Alert(...)); 
end 

rule Overlap Crews 
when 
$f1 : Flight() 
$crew : String from $f1.getCrewIds() 
$f2 : Flight(this != $1, eval($f2.getCrewIds().contains($crew)) , ... and 
periods intersecting ... ) 
then 
insertLogical(new Alert(...)); 
end 


- 
Ok. So what I do to test all that stuff : 
- create a new session 
- add a first single Flight -- no alerts at all, normal 
- add a second Flight insersecting the first one with same airplane and same 
crews list -- 3 new alerts inserted (one for airplane, one for each crew) : 
normal 
- remove this second Flight -- the 3 preivous alerts are retracted : still ok 
- re-add this second Flight -- only the 'airplane' rule triggers, I only get 
one new alert insteads of the previous same 3  The alerts not inserted 
correspond to the rule having 'from' in it 


- 
To test that it is the source of the problem, I add a new explicit association 
object that I insert in WM : 
class CrewAffectation { 
String idCrew; 
String idFlight; 
} 

For each inserted Flight, I also insert corresponding new CrewAffectation 
objects. (in case of retract, I retract them of course). 
I change the last rule to something like : 

rule Overlap Crews 
when 
$f1 : Flight($id1 : id 
$f2 : Flight(this != $1, $id2 : id, ... and periods intersecting ... ) 
$crewAff1 : CrewAffectation($idCrew : idCrew, idFlight== $id1) 
$crewAff2 : CrewAffectation(idCrew == $idCrew, idFlight== $id2) 
then 
insertLogical(new Alert(...)); 
end 
And with this 'no-from' approach, everything is working as expected. 

- 
In addition, I suspect the truth maintenance system to have leaks, and notably 
in the source kBase. 
Why ? Because I was facing problems by reusing the same kBase to generate 
multiples kSessions : The first session created reacted well, while all the 
folowing not. 
And it was in fact the same problem as the one described here : usage of from 
and insertLogical in the same rule. 
The first created session adds and retract my 3 alerts, the second created 
session only adds the airplane alert. 

With using the explicit association object, I can reuse my kBase and everything 
is working well. 

- 
Does someone already faced the problem ? 
Does it looks like a real bug to dev team or am I doing something wrong (but as 
it work once, I guess it is a bug) ? 


Vincent 


___ 
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] Inconsistent behaviour of insertLogical in rules having from pattern

2014-08-28 Thread Mark Proctor
This list is now closed.

Please use the google group:
https://groups.google.com/forum/#!forum/drools-usage

Are the auto-responders informing people that the list is closed working?

Mark

On 28 Aug 2014, at 14:31, Vincent LEGENDRE vincent.legen...@eurodecision.com 
wrote:

 Forgot to say : using drools 5.6.FINAL
 
 De: Vincent LEGENDRE vincent.legen...@eurodecision.com
 À: Rules Users List rules-users@lists.jboss.org
 Envoyé: Jeudi 28 Août 2014 15:28:49
 Objet: [rules-users] Inconsistent behaviour of insertLogical in rules having 
 from pattern
 
 Hi all,
 
 It is 2 days I am fighting with a strange behaviour of insertLogical in rules 
 having from pattern in conditions : it works the first time, and not after ...
 
 -
 Here is my use-case (simplified) :
 
 I have a class that represent a Flight. A Flight has a start/end datetime and 
 is associated with a Airplane and a list of Crew :
 class Flight {
 String airplaneId;
 ListString crewIds;
 Date start;
 Date end;
 }
 
 I want to maintain an alert list that contains all overlaps for each airplane 
 and each crew. So I have rules like:
 
 rule Overlap Airplane
when
   $f1 : Flight($airplaneId : airplaneId)
   $f2 : Flight(this != $1, airplaneId == $airplaneId, ... and periods 
 intersecting ... )
then
   insertLogical(new Alert(...));
 end
 
 rule Overlap Crews
when
   $f1 : Flight()
   $crew : String from $f1.getCrewIds()
   $f2 : Flight(this != $1, eval($f2.getCrewIds().contains($crew)) , ... 
 and periods intersecting ... )
then
   insertLogical(new Alert(...));
 end
 
 
 -
 Ok. So what I do to test all that stuff :
   - create a new session
   - add a first single Flight -- no alerts at all, normal
   - add a second Flight insersecting the first one with same airplane and 
 same crews list -- 3 new alerts inserted (one for airplane, one for each 
 crew) : normal
   - remove this second Flight -- the 3 preivous alerts are retracted : still 
 ok
   - re-add this second Flight -- only the 'airplane' rule triggers, I only 
 get one new alert insteads of the previous same 3  The alerts not 
 inserted correspond to the rule having 'from' in it
 
 
 -
 To test that it is the source of the problem, I add a new explicit 
 association object that I insert in WM :
 class CrewAffectation {
 String idCrew;
 String idFlight;
 }
 
 For each inserted Flight, I also insert corresponding new CrewAffectation 
 objects. (in case of retract, I retract them of course).
 I change the last rule to something like :
 
 rule Overlap Crews
when
   $f1 : Flight($id1 : id
   $f2 : Flight(this != $1, $id2 : id, ... and periods intersecting ... )
 $crewAff1 : CrewAffectation($idCrew : idCrew, idFlight== $id1)
 $crewAff2 : CrewAffectation(idCrew == $idCrew, idFlight== $id2)   
 then
   insertLogical(new Alert(...));
 end
 And with this 'no-from' approach, everything is working as expected.
 
 -
 In addition, I suspect the truth maintenance system to have leaks, and 
 notably in the source kBase.
 Why ? Because I was facing problems by reusing the same kBase to generate 
 multiples kSessions : The first session created reacted well, while all the 
 folowing not.
 And it was in fact the same problem as the one described here : usage of from 
 and insertLogical in the same rule.
 The first created session adds and retract my 3 alerts, the second created 
 session only adds the airplane alert.
 
 With using the explicit association object, I can reuse my kBase and 
 everything is working well.
 
 -
 Does someone already faced the problem ?
 Does it looks like a real bug to dev team or am I doing something wrong (but 
 as it work once, I guess it is a bug) ?
 
 
 Vincent
 
 
 ___
 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 Fusion (CEP) event life cycle

2014-08-28 Thread Ephemeris Lappis
Hello.
Indeed, I have tested with the @expires and the objects are discarded in
this case. What I had understood in the documentation is precisely the other
way that the engine is expected to control the events expiration : Inferred
Expiration (8.8.2), when no temporal constraint involves the objects, they
are discarded.
This seems the best way to be sure to eliminate as soon as possible all the
useless objects, whatever their life time. This is particularly important
with flows of thousands of events per second.
Perhaps I don't understand this well... Another idea or advice ?
Thanks for your help.
Regards.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-Fusion-CEP-event-life-cycle-tp4030471p4030727.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