【发布时间】:2016-06-03 09:46:01
【问题描述】:
我正在研究一个与 Coachshuttlegathering 示例几乎相同的问题。我有垃圾箱和可以收集垃圾箱的车辆。每个垃圾箱都有一个有效载荷,每辆车都有一个容量。
我按照 Coachshuttlegathering 示例中所示设置了我的解决方案,这基本上是可行的,但我最终处于局部最优状态,因为默认移动不够粗粒度。具体来说,我需要允许在一次移动中将来自 2 辆不同车辆的 2 条垃圾箱链分配给不同的车辆。
我尝试将现有的 subChainChangeMoveSelector 与笛卡尔产品移动选择器结合使用,如下所示:
<cartesianProductMoveSelector>
<subChainChangeMoveSelector>
<entityClass>...Wastebin</entityClass>
<subChainSelector>
<valueSelector>
<variableName>previousRouteComponent</variableName>
</valueSelector>
</subChainSelector>
<valueSelector>
<variableName>previousRouteComponent</variableName>
</valueSelector>
<selectReversingMoveToo>false</selectReversingMoveToo>
</subChainChangeMoveSelector>
<subChainChangeMoveSelector>
<entityClass>...Wastebin</entityClass>
<subChainSelector>
<valueSelector>
<variableName>previousRouteComponent</variableName>
</valueSelector>
</subChainSelector>
<valueSelector>
<variableName>previousRouteComponent</variableName>
</valueSelector>
<selectReversingMoveToo>false</selectReversingMoveToo>
</subChainChangeMoveSelector>
<fixedProbabilityWeight>1.5</fixedProbabilityWeight>
</cartesianProductMoveSelector>
当我使用此配置运行求解器时,出现以下异常:
The entity (Wastebin{id=3}) has a variable (previousRouteComponent) with value (Wastebin{id=3}) which has a sourceVariableName variable (nextWastebin) with a value (Wastebin{id=1}) which is not null.
Verify the consistency of your input problem for that sourceVariableName variable.
知道这里出了什么问题吗?一件奇怪的事情是计划实体显然指向自己。我在想也许移动选择了 2 个重叠的子链,这会在某些时候导致不一致?
编辑
开启 FULL_ASSERT 会产生更多细节:
Caused by: java.lang.IllegalStateException: UndoMove corruption: the beforeMoveScore (0/0/23/-2245/-12) is not the undoScore (0/0/23/-1358/-2) which is the uncorruptedScore (0/0/23/-1358/-2) of the workingSolution.
1) Enable EnvironmentMode FULL_ASSERT (if you haven't already) to fail-faster in case there's a score corruption.
2) Check the Move.createUndoMove(...) method of the moveClass (class org.optaplanner.core.impl.heuristic.move.CompositeMove). The move ([[Wastebin{id=3}..Wastebin{id=3}] {Wastebin{id=3} -> Vehicle{id=2}}, [Wastebin{id=3}..Wastebin{id=3}] {Wastebin{id=3} -> Wastebin{id=1}}]) might have a corrupted undoMove (Undo([[Wastebin{id=3}..Wastebin{id=3}] {Wastebin{id=3} -> Vehicle{id=2}}, [Wastebin{id=3}..Wastebin{id=3}] {Wastebin{id=3} -> Wastebin{id=1}}])).
3) Check your custom VariableListeners (if you have any) for shadow variables that are used by the score constraints with a different score weight between the beforeMoveScore (0/0/23/-2245/-12) and the undoScore (0/0/23/-1358/-2).
at org.optaplanner.core.impl.phase.scope.AbstractPhaseScope.assertExpectedUndoMoveScore(AbstractPhaseScope.java:145)
at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.doMove(LocalSearchDecider.java:153)
at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.decideNextStep(LocalSearchDecider.java:121)
at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:72)
at org.optaplanner.core.impl.solver.DefaultSolver.runPhases(DefaultSolver.java:215)
at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:176)
不幸的是,输出包含两次move,我为此问题创建了PLANNER-599。我从调试器中得到了正确的撤消动作:
[Wastebin{id=3}..Wastebin{id=3}] {Wastebin{id=3} -> Vehicle{id=1}}
[Wastebin{id=3}..Wastebin{id=3}] {Wastebin{id=3} -> Vehicle{id=1}}
我没有任何自定义变量监听器
【问题讨论】:
标签: optaplanner