Optaplanner仅生产单链解决方案

时间:2015-02-04 07:30:12

标签: optaplanner chained

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

我的配置:

<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>

当我尝试解决()时,我得到了一个安装程序,其中包含所有预订。我需要做些什么来改善这种情况?

1 个答案:

答案 0 :(得分:1)

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

另外请注意这里可能存在的常见陷阱(但如果正确使用值范围提供程序则不应该这样):list.add(list)而不是list.addAll(list)