<div dir="ltr"><div>I regret, I can't reconstruct the requirements from these rules. There are too many parameters unknown to me.<br><br></div><div>The idea to construct a fact for each of the 15 days seems to be OK, although I think that this need not be done in this explicit and in this somewhat circumstantial way. I suppose a "ShiftType() from $pattern.getShiftTypes() would be suffucient, but then there's no information about the day offset in the ShiftType.<br>
<br></div><div>The problem you are experiencing is that the index of an (array) list is readily available in procedural code, at least during the classic iterative access through the list (using "for int i = ..."). But this information is not really coupled with the element at the position. Whenever the index has a "deeper" meaning for the application, it ought to be part of the data, relieving the actual index from this burden. Hope this makes sense.<br>
</div><div><br></div>-W<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 11 August 2013 06:09, john poole <span dir="ltr"><<a href="mailto:jdpoole@gmail.com" target="_blank">jdpoole@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the reply. The series of shifts that a Doctor works in my schedule<br>
is 15 days straight, but not the same Shift for each of those days.<br>
I ended up doing it like this, maybe it explains the requirements better.<br>
Its working, but it looks ugly.<br>
<br>
rule "pattern15dayShiftAssignment"<br>
when<br>
$pattern : Neuro15DaysPattern(<br>
$dayOfWeekFirst : getDayOfWeek(0),<br>
$shiftType0: getShiftType(0),<br>
$shiftType1: getShiftType(1),<br>
$shiftType2: getShiftType(2),<br>
$shiftType3: getShiftType(3),<br>
$shiftType4: getShiftType(4),<br>
$shiftType5: getShiftType(5),<br>
$shiftType6: getShiftType(6),<br>
$shiftType7: getShiftType(7),<br>
$shiftType8: getShiftType(8),<br>
$shiftType9: getShiftType(9),<br>
$shiftType10: getShiftType(10),<br>
$shiftType11: getShiftType(11),<br>
$shiftType12: getShiftType(12),<br>
$shiftType13: getShiftType(13),<br>
$shiftType14: getShiftType(14)<br>
);<br>
then<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType1, 1) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType2, 2) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType3, 3) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType4, 4) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType5, 5) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType6, 6) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType7, 7) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType8, 8) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType9, 9) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType10, 10) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType11, 11) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType11, 11) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType12, 12) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType13, 13) );<br>
insertLogical( new PatternShiftAssignment($pattern, $shiftType14, 14) );<br>
System.out.println( $pattern +" "+ $shiftType14 );<br>
end<br>
<br>
rule "unwantedPatternNeuro15Days"<br>
when<br>
$pattern : Neuro15DaysPattern($dayOfWeekFirst : getDayOfWeek(0),<br>
$shiftType0: getShiftType(0), $code : code);<br>
<br>
PatternShiftAssignment( pattern == $pattern, $shiftType : shiftType,<br>
$dayIndex: patternIndex)<br>
<br>
$shiftAssignment0 : ShiftAssignment( $code == shiftDateDayIndex %<br>
2,<br>
shiftType == $shiftType0,<br>
shiftDateDayOfWeek == $dayOfWeekFirst,<br>
$employee: employee,<br>
$shiftDateDayIndex0 : shiftDateDayIndex);<br>
<br>
$shiftassignment : ShiftAssignment( shiftType == $shiftType,<br>
shiftDateDayIndex ==<br>
($dayIndex+$shiftDateDayIndex0),<br>
$employee !=<br>
employee<br>
)<br>
<br>
then<br>
insertLogical(new<br>
IntConstraintOccurrence("unwantedPatternNeuro15Days",<br>
ConstraintType.NEGATIVE_SOFT,<br>
$pattern.getWeight(),<br>
$employee, $pattern, $dayIndex));<br>
end<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Long-pattern-for-Nurse-Rostering-tp4025432p4025444.html" target="_blank">http://drools.46999.n3.nabble.com/Long-pattern-for-Nurse-Rostering-tp4025432p4025444.html</a><br>
<div class="HOEnZb"><div class="h5">Sent from the Drools: User forum mailing list archive at Nabble.com.<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br></div>