Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Properties 属性依赖于事实值的场景_Properties_Optaplanner_Fact - Fatal编程技术网

Properties 属性依赖于事实值的场景

Properties 属性依赖于事实值的场景,properties,optaplanner,fact,Properties,Optaplanner,Fact,需要澄清关于分数约束使用问题事实类,但在规划期间不会更改(只要问题保持不变)的声明 Optaplanner能否处理问题属性依赖于事实值的场景(并返回优化的解决方案) 例如:在车辆路径问题中,optaplanner引擎能否返回优化的解决方案,这是因为车辆_1从位置_A到位置_B比车辆_0花费更多的时间(比如1.2倍) 类似地,在项目作业调度示例中,资源X需要1.2天才能完成一项任务,而资源Y需要0.9天才能完成同一项任务。是的,它可以。几个示例实际上可以做到这一点。 有几种方法可以设计/实现它。以

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

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

例如:在车辆路径问题中,optaplanner引擎能否返回优化的解决方案,这是因为车辆_1从位置_A到位置_B比车辆_0花费更多的时间(比如1.2倍)


类似地,在项目作业调度示例中,资源X需要1.2天才能完成一项任务,而资源Y需要0.9天才能完成同一项任务。

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

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

}
什么时候
$a:任务分配($id:id)
$b:TaskAssignment($id
您的每个域类要么是问题事实,要么是规划实体。区别在于后者在计划期间更改,前者仅在ProblemFactChange的过程中或在solve()方法调用之前更改。