Optaplanner 只产生单链解决方案

Optaplanner produces only single chain solution

我正在使用 Optaplanner 解决安装人员预订分配问题,这是一个链接问题,类似于车辆路径。安装程序(车辆)可能有多个预订(客户)分配给它。我需要实施链条,因为我需要评估与特定订单的另一预订相关的一个预订。 因此,我在解决方案中将 Booking 和 Installer 声明为 @PlanningEntityCollectionProperty。 Booking 和 Installer 都实现了 Standstill。但仅在 Booking 中,我为方法 getPreviousStandstill() 声明了@PlanningVariable。

我的配置:

<solver>
  <!--<environmentMode>FAST_ASSERT</environmentMode>-->

  <!-- Domain model configuration -->
  <solutionClass>InstallationSolution</solutionClass>
  <entityClass>Standstill</entityClass>
  <entityClass>Booking</entityClass>



  <!-- Score configuration -->
  <scoreDirectorFactory>
    <scoreDefinitionType>HARD_SOFT</scoreDefinitionType>
    <!--<easyScoreCalculatorClass>org.optaplanner.examples.cloudbalancing.solver.score.CloudBalancingEasyScoreCalculator</easyScoreCalculatorClass>-->
    <!--<easyScoreCalculatorClass>org.optaplanner.examples.cloudbalancing.solver.score.CloudBalancingMapBasedEasyScoreCalculator</easyScoreCalculatorClass>-->
    <!--<incrementalScoreCalculatorClass>org.optaplanner.examples.cloudbalancing.solver.score.CloudBalancingIncrementalScoreCalculator</incrementalScoreCalculatorClass>-->
    <!--<scoreDrl>com/tmrnd/pejal/opta/solver/fulfillmentScoreRules.drl</scoreDrl>-->
    <initializingScoreTrend>ONLY_DOWN</initializingScoreTrend>
    <!--<assertionScoreDirectorFactory>-->
      <!--<easyScoreCalculatorClass>org.optaplanner.examples.cloudbalancing.solver.score.CloudBalancingMapBasedEasyScoreCalculator</easyScoreCalculatorClass>-->
    <!--</assertionScoreDirectorFactory>-->
  </scoreDirectorFactory>

  <!-- Optimization algorithms configuration -->
  <termination>
    <!-- <secondsSpentLimit>20</secondsSpentLimit>-->
    <unimprovedSecondsSpentLimit>15</unimprovedSecondsSpentLimit>
  </termination>
  <constructionHeuristic>
    <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>

  </constructionHeuristic>
  <localSearch>
    <unionMoveSelector>
      <changeMoveSelector/>
      <swapMoveSelector/>
      <subChainChangeMoveSelector>
        <selectReversingMoveToo>true</selectReversingMoveToo>
      </subChainChangeMoveSelector>
      <subChainSwapMoveSelector>
        <selectReversingMoveToo>true</selectReversingMoveToo>
      </subChainSwapMoveSelector>
    </unionMoveSelector>
    <acceptor>
      <entityTabuSize>20</entityTabuSize>

    </acceptor>
    <forager>
      <acceptedCountLimit>1000</acceptedCountLimit>
    </forager>
  </localSearch>
</solver>

当我尝试解决 () 时,我得到了一个安装人员,所有预订都分配给他。我需要做些什么来改善这种情况?

我最初的猜测是 OptaPlanner 只知道 1 个锚点(1 个安装程序)。检查解决方案列表的大小是否大于 1。然后检查 getter 是否有 @ValueRangeProvider 以及是否在 @PlanningEntity 的 valueRangeProviderRefs 中添加了该 ValueRangeProvider 的 ID。

还要注意一个可能也适用于此的常见陷阱(但如果您正确使用值范围提供程序则不应该):list.add(list) 而不是 list.addAll(list)