0

需要澄清关于分数约束使用问题事实类的声明,但在计划期间不会改变(只要问题保持不变)。

Optaplanner 可以处理问题属性依赖于事实值的场景(并返回优化的解决方案)吗?

例如:在 Vehicle Routing 问题中,optaplanner 引擎是否可以基于 Vehicle_1 从 Location_A 到 Location_B 的行驶时间比 Vehicle_0 花费更多时间(例如 1.2 倍)这一事实返回优化解决方案。

类似地,在 Project Job Scheduling 示例中,Resource_X 需要 1.2 天才能完成一项任务,而 Resource_Y 需要 0.9 天才能完成相同的任务。

4

1 回答 1

0

是的,它可以。有几个例子实际上是这样做的。有几种方法可以设计/实现它。这是我更喜欢的一个:

@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
     }

}
于 2016-02-24T10:32:38.330 回答