[rules-users] Planer: Rule design causing problem

Reinis drools at orbit-x.de
Mon Nov 5 16:42:12 EST 2012


Hi,

I have application similar to nurse rostering. You have projects, 
resources and dates. You assign resource on date to project (thus you 
have an assignment).

Now, I have rule that is supposed to keep assignments "together". Most 
of the assignments are indeed kept together with some few but very nasty 
exceptions.

I have attached the image (Schedule.png) to visualize this. In the image 
you see assignments for Project 9 being planed en block from 13. July 
till 20. July (green box at the bottom). But then there are couple of 
assignments (above, underlined in red on 2. January and on 22. February) 
totally "out of the row".

I attempt to "pull" assignments together with this rule:

rule "penalize assignment dispersion to goLive"
     when
         $project : Project(goLive != null)
         $furthestAssignment : Assignment(project == $project, interval 
!= null, $project.goLive.compareTo(interval.end) >= 0)
         not Assignment(id > $furthestAssignment.id, project == 
$project, interval != null, $project.goLive.compareTo(interval.end) >= 
0, distanceToGoLive >= $furthestAssignment.distanceToGoLive)
     then
         insertLogical( new IntConstraintOccurrence("penalizing 
assignment dispersion", ConstraintType.NEGATIVE_SOFT,
                         $furthestAssignment.distanceToGoLive(), 
$project) );
end

There are number of other rules. The ones checking hard constraints are 
trivial and I will just omit them, the soft constraint rules might have 
impact on this issue although unlikely (I removed all the other soft 
constraint rules and still got similar weird result). Here are the other 
rules:

rule "penalize assignment with the resource without the capability 
required by project option"
     when
         $projectOption : ProjectOption()
         $penalizedAssignments : Number(intValue > 0)
             from accumulate ( Assignment($penalizedAssignment : this, 
project == $projectOption.project, resource != null, 
resource.capabilities not contains $projectOption.name),
             count($penalizedAssignment) )
     then
         insertLogical( new IntConstraintOccurrence("there are 
assignments with the resource without the capability required by project 
option", ConstraintType.NEGATIVE_SOFT,
         $penalizedAssignments.intValue(), $projectOption, 
$penalizedAssignments) );
end

rule "penalize assignment with the resource without the capability 
required by project constraint"
     when
         $projectConstraint : ProjectConstraint()
         $penalizedAssignments : Number(intValue > 0)
             from accumulate ( Assignment($penalizedAssignment : this, 
project == $projectConstraint.project, resource != null, 
resource.capabilities not contains $projectConstraint.name),
             count($penalizedAssignment) )
     then
         insertLogical( new IntConstraintOccurrence("there are 
assignments with the resource without the capability required by project 
constraint", ConstraintType.NEGATIVE_SOFT,
         $penalizedAssignments.intValue(), $projectConstraint, 
$penalizedAssignments) );
end

Am using Drools Planer 5.3. and biting out my teeth on this issue for 
about 3 moth already. Any help is worth half the kingdom to me right now.

br
Reinis

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Schedule.png
Type: image/png
Size: 171308 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20121105/bf406365/attachment-0001.png 


More information about the rules-users mailing list