Ok. So what I do to test all that stuff :
- 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