我正在处理一个几乎与coachshuttlegathering示例相同的问题。我有垃圾箱和车辆应该收集废物箱。每个垃圾箱都有一个有效载荷,每辆车都有一个容量。
我设置我的解决方案,如在coachshuttlegathering示例中所示,这基本上有效,但我最终在本地optimas,因为默认移动不够粗糙。具体来说,我需要允许2个不同车辆的2个垃圾箱链一次性分配到不同的车辆。
我尝试将现有的subChainChangeMoveSelector与cartesianProductMoveSelector结合使用,如下所示:
<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}}
我没有任何自定义VariableListeners
答案 0 :(得分:1)
这是a known issue in OptaPlanner 6.4.0.Final。它发生在复杂的CompositeMoves中,这是由于Move接口的设计。修复它并非易事,请参阅PLANNER-611。
更新:这已针对7.0.0.CR1
修复。
答案 1 :(得分:0)
&#34;实体(Wastebin {id = 3})有一个变量(previousRouteComponent),其值为(Wastebin {id = 3})&#34;
那意味着Wastebin-3指向自己?这将违反链式变量原则。从理论上讲,笛卡尔的生产行动不应该导致 - 但如果你的输入问题是有效的,那无论如何都必须发生......
启用environmentMode FULL_ASSERT并查看它是否先前失败。