[rules-users] Long pattern for Nurse Rostering

john poole jdpoole at gmail.com
Sun Aug 11 00:09:01 EDT 2013


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.


More information about the rules-users mailing list