Reputation: 1366
The Task is the PlanningEntity, each task is in a group, groupId is a member of the Task class. What task is in what group is fixed, the groupId is neither PlanningVariable nor PlanningFact. Each task has a duration, it's a shadow variable that is affected by the combination(optimization) of the tasks within the group. Let's call "the sum of task durations in a group" S. S1 for group1, S2 for group2 ... The soft constraint is to minimize the largest S of all the groups. This is not to minimize all S, that's not the goal. I can only think of something like following which is not working. The "index" is the PlanningVariable.
rule "Minimize the largest group duration"
when
accumulate(
accumulate(
$g: Group(),
Task(index != null, groupId == g.getId(), $d: duration);
$s: sum($d)
)
$smax: max($s)
)
then
scoreHolder.addSoftConstraintMatch(kcontext, 1, (-$smax));
end
Upvotes: 0
Views: 53
Reputation: 5702
I am not sure I entirely understand the issue, but something like this should get you the maximum duration:
Task(..., $d: duration)
not Task(..., duration > $d)
$d
is now your maximum duration, and you can do anything you like with it.
(Note: You should add the drools
tag and possibly also remove the optaplanner
one, as this is barely related to OptaPlanner.)
Upvotes: 1