<br> Ge0ffrey,<br><br> Isn't the bellow rule causing an infinite loop for you?<br><br>rule "existExamSeating"<br> when<br> $period : Period();<br> $room : Room();<br> exists Exam(period == $period, room == $room);
<br> not ExamSeating(period == $period, room == $room);<br> then<br> insertLogical(new ExamSeating($period, $room));<br>end<br><br> You see, the insertLogical in the consequence will cause the LHS condition:
<br><br> not ExamSeating(period == $period, room == $room);<br>
<br> To fail. When it fails, it automatically retreats the logical insert, what causes the condition to be true again and fire the rule again. And you have an infinite loop... don't you?<br><br> []s<br> Edson
<br><br><div><span class="gmail_quote">2008/1/20, Geoffrey De Smet <<a href="mailto:ge0ffrey.spam@gmail.com">ge0ffrey.spam@gmail.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>In my statefull working memory on which I fireAllRules over a 1000 timse<br>per second, I have rule which hurts performance because it gets<br>backwards chained (which is bad in my use case):<br><br><br>// More seating required during a period in a room than available
<br>// in that room.<br>rule "roomCapacityTooSmall" // TODO improve performance, as it takes 50%<br>of the performance<br> when<br> $period : Period();<br> $room : Room($capacity : capacity);
<br> $totalStudentListSize : Number(intValue > $capacity)<br> from accumulate(<br> Exam(period == $period, room == $room,<br> $studentListSize : topicStudentListSize),
<br> sum($studentListSize)<br> );<br> then<br> insertLogical(new IntConstraintOccurrence(<br> "roomCapacityTooSmall", ConstraintType.NEGATIVE_HARD,<br> $period, $room));
<br>end<br><br><br>In an effort to turn this into a statefull insertLogical,<br>I 've tried this:<br><br>// More seating required during a period in a room than available<br>// in that room.<br>rule "existExamSeating"
<br> when<br> $period : Period();<br> $room : Room();<br> exists Exam(period == $period, room == $room);<br> not ExamSeating(period == $period, room == $room);<br> then<br> insertLogical(new ExamSeating($period, $room));
<br>end<br>rule "addExamToExamSeating"<br> when<br> $exam : Exam($period : period, $room : room);<br> $examSeating : ExamSeating(period == $period, room == $room,<br> examSet not contains $exam);
<br> then<br> $examSeating.getExamSet().add($exam);<br> update($examSeating);<br>end<br>rule "removeExamFromExamSeatingPeriod"<br> when<br> $exam : Exam($period : period, $room : room);
<br> $examSeating : ExamSeating(examSet contains $exam,<br> period != $period);<br> then<br> $examSeating.getExamSet().remove($exam);<br> update($examSeating);<br>end<br>rule "removeExamFromExamSeatingRoom"
<br> when<br> $exam : Exam($period : period, $room : room);<br> $examSeating : ExamSeating(examSet contains $exam,<br> room != room);<br> then<br> $examSeating.getExamSet().remove($exam);
<br> update($examSeating);<br>end<br>rule "roomCapacityTooSmall"<br> when<br> $examSeating : ExamSeating(studentSize > roomCapacity, $period<br>: period, $room : room);<br> then<br> insertLogical(new IntConstraintOccurrence(
<br> "roomCapacityTooSmall", ConstraintType.NEGATIVE_HARD,<br> $period, $room));<br>end<br><br><br><br>However, this turns out to be so slow it's at least 100 times slower<br>(and probably a lot more as I had no time to let the benchmark finish).
<br><br>What could explain this?<br>Is "exists" or "contains" backwards chained?<br>Am I missing something?<br><br>Thanks for any and all help.<br><br>--<br>With kind regards,<br>Geoffrey De Smet<br><br>
_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br>
JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>