I regret, I can't reconstruct the requirements from these rules. There are too many parameters unknown to me.

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.

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.

-W


On 11 August 2013 06:09, john poole <jdpoole@gmail.com> wrote:
Thanks for the reply. The series of shifts that a Doctor works in my schedule
is 15 days straight, but not the same Shift for each of those days.
I ended up doing it like this, maybe it explains the requirements better.
Its working, but it looks ugly.

rule "pattern15dayShiftAssignment"
        when
                $pattern : Neuro15DaysPattern(
                        $dayOfWeekFirst : getDayOfWeek(0),
                        $shiftType0: getShiftType(0),
                        $shiftType1: getShiftType(1),
                        $shiftType2: getShiftType(2),
                        $shiftType3: getShiftType(3),
                        $shiftType4: getShiftType(4),
                        $shiftType5: getShiftType(5),
                        $shiftType6: getShiftType(6),
                        $shiftType7: getShiftType(7),
                        $shiftType8: getShiftType(8),
                        $shiftType9: getShiftType(9),
                        $shiftType10: getShiftType(10),
                        $shiftType11: getShiftType(11),
                        $shiftType12: getShiftType(12),
                        $shiftType13: getShiftType(13),
                        $shiftType14: getShiftType(14)
                 );
        then
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType1, 1) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType2, 2) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType3, 3) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType4, 4) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType5, 5) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType6, 6) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType7, 7) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType8, 8) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType9, 9) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType10, 10) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType11, 11) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType11, 11) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType12, 12) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType13, 13) );
                insertLogical( new PatternShiftAssignment($pattern,  $shiftType14, 14) );
                System.out.println( $pattern +" "+  $shiftType14 );
end

rule "unwantedPatternNeuro15Days"
    when
        $pattern : Neuro15DaysPattern($dayOfWeekFirst : getDayOfWeek(0),
                        $shiftType0: getShiftType(0), $code : code);

        PatternShiftAssignment( pattern == $pattern, $shiftType : shiftType,
$dayIndex: patternIndex)

        $shiftAssignment0 : ShiftAssignment(    $code == shiftDateDayIndex %
2,
                                                                shiftType == $shiftType0,
                                                                shiftDateDayOfWeek == $dayOfWeekFirst,
                                                                $employee: employee,
                                                                $shiftDateDayIndex0 : shiftDateDayIndex);

        $shiftassignment : ShiftAssignment( shiftType == $shiftType,
                                                        shiftDateDayIndex ==
($dayIndex+$shiftDateDayIndex0),
                                                        $employee !=
employee
        )

    then
        insertLogical(new
IntConstraintOccurrence("unwantedPatternNeuro15Days",
                 ConstraintType.NEGATIVE_SOFT,
                $pattern.getWeight(),
                $employee, $pattern, $dayIndex));
end



--
View this message in context: http://drools.46999.n3.nabble.com/Long-pattern-for-Nurse-Rostering-tp4025432p4025444.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