【问题标题】:OptaPlanner vehicle routing course grained movesOptaPlanner 车辆路线规划过程粒度移动
【发布时间】: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


    【解决方案1】:

    这是a known issue in OptaPlanner 6.4.0.Final。它发生在复杂的 CompositeMove 中,这是由于 Move 界面的设计造成的。修复它并非易事,请参阅PLANNER-611

    更新:此问题已针对 7.0.0.CR1 修复。

    【讨论】:

      【解决方案2】:

      “实体 (Wastebin{id=3}) 有一个变量 (previousRouteComponent),其值为 (Wastebin{id=3})”

      这意味着Wastebin-3 指向它自己?这将违反链式变量原则。从理论上讲,笛卡尔生产移动不应该导致这种情况 - 但如果您的输入问题是有效的,那么无论如何都会发生这种情况......

      开启 environmentMode FULL_ASSERT 看看是否更早失败。

      【讨论】:

      • 我将应用 FULL_ASSERT 的结果添加到我的原始问题中。重复的撤消移动步骤是否有可能以某种方式破坏变量?
      • 我能够使用 FULL_ASSERT 和我的问题中描述的笛卡尔ProductMoveSelector 重现OptaPlanner 分发中包含的车辆路线示例的问题。仍然不知道发生了什么。
      • 你能分享一个关于 optaplanner-examples 的 PR 与一个失败的单元测试吗?
      • 我创建了PR
      • 有没有人能找到解决这个问题的方法?或者可以推荐一种寻找方法?
      猜你喜欢
      • 2018-10-27
      • 2014-04-12
      • 2020-08-04
      • 1970-01-01
      • 1970-01-01
      • 2020-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多