はい、できます。いくつかの例が実際にそれを行っています。それを設計/実装するにはいくつかの方法があります。これが私が好むものです:
@PlanningEntity class TaskAssignment {
Task task;
@PlanningVariable Employee employee;
public int getDuration() {
// Warning: If affinity's or task types would change during planning (except during real-time planning ProblemFactChange of course),
// we would need to do this through DRL or break incremental score calculation.
return employee.getAffinityTo(task.getType()).getDuration();
}
}
rule affinityBasedDuration
when
TaskAssignment(employee != null, $d : duration)
then
// addSoft(-$d)
end
引数を渡すこともできます:
when
$a : TaskAssignment($id : id)
$b : TaskAssignment($id < id, $d: calculateOverlap($a))
then
// addSoft(-$d)
end
@PlanningEntity class TaskAssignment {
...
public int calculateOverlap(TaskAssignment other) {
// calculate overlap with this.startTimestamp vs other.startTimestamp
// and this.endTimestamp vs other.endTimestamp
}
}