[rules-users] Long pattern for Nurse Rostering

Wolfgang Laun wolfgang.laun at gmail.com
Fri Aug 9 03:26:14 EDT 2013


See for comments inline.

On 09/08/2013, john poole <jdpoole at gmail.com> wrote:
> I'm trying to create a rule for a 15 day pattern. When the patterns uses
> the
> same shift for all 15 days, I do this:
>
> rule "unWanted15DayPattern"
>     when
>         $pattern : U15DayPattern(
>             $numberOfDays : numberOfDays,

This binding is never used.

>             $shiftType : shiftType
>         )
>
>         ShiftAssignment(
>             shiftType == $shiftType,
>             $employee : employee,
>             $firstDayIndex : shiftDateDayIndex

The constraint shiftDateDayIndex % 15 == 0 should be used here.
(Principle: Avoid partial matches as early as possible.)

>         )
>
>         ShiftDate( $firstDayIndex == dayIndex, dayIndex % 15 == 0)

If the constraint is moved up: what is the purpose of this pattern? Is
it necessary to make sure that there *is* a ShiftDate with a matching
dayIndex? This won't work well, if there isn't, so I guess there
always is a matching ShiftDate - and then the pattern is now useless.

>
> //Check for different employee working that shift in the next N days
>
>        $shiftAssignment : ShiftAssignment(
>             shiftType == $shiftType,
>             employee != $employee,
>             shiftDateDayIndex > $firstDayIndex,
>             shiftDateDayIndex < $firstDayIndex + 15
>         )
>
>     then
>
>      insertLogical(new IntConstraintOccurrence("unWanted15DayPattern",
> ConstraintType.NEGATIVE_SOFT,
>                $pattern.getWeight(),
>                 $firstDayIndex));
> end
>
> But I'm having a hard time figuring out how to do it with different
> shiftTypes for each day, because it means having to use a loop.

Not necessarily. It depends how a U15DayPattern with more than one
shiftType in these days is represented. (Or what, exactly, do you mean
by "different shiftTypes for each day"?) A little more explanation
about the data model is indicated...

-W


> Not sure if that makes sense, but it anyone has used a long pattern that
> stores items in a list/array I'd love to hear how they did it.
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Long-pattern-for-Nurse-Rostering-tp4025432.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list