我正在使用 VRP 问题示例并进行一些更改。一是计算所有任务的到达和目的地时间。另一个是某些任务对必须具有相同的到达时间。更新到达时间后,我“移动”并行任务 - 并更改它们的日期。因此移动步骤可以改变另一辆车上任务的影子变量。
但是,验证两个任务的到达是否相同的 drools 规则并没有看到这种变化。就像他们根本没有改变对象一样。我究竟做错了什么?也许我的做法是错误的?
并行任务未标记为 ShadowVaraible 或 PlanningVariable。
听众:
public class ArrivalTimeUpdatingVariableListener implements VariableListener<Task> {
@Override
public void afterEntityAdded(ScoreDirector scoreDirector, Task task) {
updateTaskAssignmentTimes(scoreDirector);
}
@Override
public void afterVariableChanged(ScoreDirector scoreDirector, Task task) {
updateTaskAssignmentTimes(scoreDirector);
}
(...)
scoreDirector.beforeVariableChanged(task, "arrivalTime");
task.setArrivalTime(task.getArrivalTime() + diff);
scoreDirector.afterVariableChanged(task, "arrivalTime");
(...)
}
任务:
@PlanningEntity(difficultyWeightFactoryClass = DepotAngleTaskDifficultyWeightFactory.class)
public class Task extends AbstractPersistable implements Standstill {
(...)
@CustomShadowVariable(variableListenerClass = ArrivalTimeUpdatingVariableListener.class, sources = {@PlanningVariableReference(variableName = "previousStandstill")})
private Long arrivalTime;
@CustomShadowVariable(variableListenerClass = ArrivalTimeUpdatingVariableListener.class, sources = {@PlanningVariableReference(variableName = "previousStandstill")})
private Long departureTime;
(...)
}
博士升:
rule "Parallel task soft relation"
when
$task : Task(assigned, relations.tasksParallel.size() > 0, $tasksParallel : relations.tasksParallel)
Task(assigned, $tasksParallel.contains(id), doesNotHaveSameArrivalTime($task))
then
scoreHolder.addHardConstraintMatch(kcontext, -1088);
end
Smart猫小萌
相关分类