<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">This list is now closed.<div><br></div><div>Please use the google group:</div><div><a href="https://groups.google.com/forum/#!forum/drools-usage">https://groups.google.com/forum/#!forum/drools-usage</a></div><div><br></div><div>Are the auto-responders informing people that the list is closed working?</div><div><br></div><div>Mark</div><div><br><div><div>On 28 Aug 2014, at 14:31, Vincent LEGENDRE &lt;<a href="mailto:vincent.legendre@eurodecision.com">vincent.legendre@eurodecision.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><div>Forgot to say : using drools 5.6.FINAL<br></div><div><br></div><hr id="zwchr"><div style="font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-size: 12pt;"><b>De: </b>"Vincent LEGENDRE" &lt;<a href="mailto:vincent.legendre@eurodecision.com">vincent.legendre@eurodecision.com</a>&gt;<br><b>À: </b>"Rules Users List" &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br><b>Envoyé: </b>Jeudi 28 Août 2014 15:28:49<br><b>Objet: </b>[rules-users] Inconsistent behaviour of insertLogical in rules having from pattern<br><div><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><div>Hi all,<br></div><div><br></div><div>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 ...<br></div><div><br></div><div>-----------------------------------------<br></div><div>Here is my use-case (simplified) :<br></div><div><br></div><div>I have a class that represent a Flight. A&nbsp;Flight has a start/end datetime and is associated with a Airplane and a list of Crew :<br></div><div>class Flight {<br></div><div>&nbsp;&nbsp;&nbsp; String airplaneId;<br></div><div>&nbsp;&nbsp;&nbsp; List&lt;String&gt; crewIds;</div><div>&nbsp;&nbsp;&nbsp; Date start;<br></div><div>&nbsp;&nbsp;&nbsp; Date end;<br></div><div>}<br></div><div><br></div><div>I want to maintain an alert list that contains all overlaps for each airplane and each crew. So I have rules like:<br></div><div><br></div><div>rule "Overlap Airplane"<br></div><div>&nbsp;&nbsp; when<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $f1 : Flight($airplaneId : airplaneId)<br></div><div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $f2 : Flight(this != $1, airplaneId == $airplaneId, ... and periods intersecting ... )</div>&nbsp;&nbsp; then<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertLogical(new Alert(...));<br></div><div>end<br></div><div><br></div><div><div>rule "Overlap Crews"</div><div>&nbsp;&nbsp; when</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $f1 : Flight()</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $crew : String from $f1.getCrewIds()<br></div><div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $f2 : Flight(this != $1, eval($f2.getCrewIds().contains($crew)) , ... and periods intersecting ... )</div>&nbsp;&nbsp; then</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertLogical(new Alert(...));</div><div>end</div><div><br></div><div><br></div><div>-----------------------------------------</div><div>Ok. So what I do to test all that stuff :<br></div><div>&nbsp; - create a new session<br></div><div>&nbsp; - add a first single Flight --&gt; no alerts at all, normal<br></div><div>&nbsp; - add a second Flight insersecting the first one with same airplane and same crews list --&gt; 3 new alerts inserted (one for airplane, one for each crew) : normal<br></div><div><div>&nbsp; - remove this second Flight --&gt; the 3 preivous alerts are retracted : still ok<br></div><div>&nbsp; - re-add this second Flight --&gt; 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<br></div><div><br></div><div><br></div><div><div>-----------------------------------------</div>To test that it is the source of the problem, I add a new explicit association object that I insert in WM :<br></div><div>class CrewAffectation {<br></div><div>&nbsp;&nbsp;&nbsp; String idCrew;<br></div><div>&nbsp;&nbsp;&nbsp; String idFlight;<br></div><div>}<br></div><div><br></div><div>For each inserted Flight, I also insert corresponding new CrewAffectation objects. (in case of retract, I retract them of course).<br></div><div>I change the last rule to something like :<br></div><div><div><br></div><div>rule "Overlap Crews"</div><div>&nbsp;&nbsp; when</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $f1 : Flight($id1 : id</div><div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $f2 : Flight(this != $1, $id2 : id, ... and periods intersecting ... )</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $crewAff1 : CrewAffectation($idCrew : idCrew, idFlight== $id1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $crewAff2 : CrewAffectation(idCrew == $idCrew, idFlight== $id2)&nbsp;&nbsp; <br></div><div>&nbsp;&nbsp;&nbsp; then<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertLogical(new Alert(...));</div><div>end</div></div><div>And with this 'no-from' approach, everything is working as expected.<br></div><div><br></div><div><div><div>-----------------------------------------</div>In addition, I suspect the truth maintenance system to have leaks, and notably in the source kBase.</div>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. </div><div>And it was in fact the same problem as the one described here : usage of from and insertLogical in the same rule. </div><div>The first created session adds and retract my 3 alerts, the second created session only adds the airplane alert. </div><div><br></div><div>With using the explicit association object, I can reuse my kBase and everything is working well.</div><div><br></div><div>-----------------------------------------</div><div>Does someone already faced the problem ?<br></div><div>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) ?<br></div><div><br></div><div><br></div>Vincent<br></div><div><br></div></div></div><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users</div><div><br></div></div></div>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users</blockquote></div><br></div></body></html>