在VehicleRouting中使用nearbySelection会导致Mimic异常

时间:2015-01-21 16:12:31

标签: optaplanner

我试图基于Optaplanner Vehiclerouting示例(6.2.0-CR4)实现CVRPTW。

Optaplanner是一个很棒的项目!

为了加快寻找合适的解决方案,我开始尝试附近的选择。但是,当我配置CustomerNearbyDistanceMeter的使用时,抛出以下异常:

  

线程中的异常" 1271a58a-a134-4b68-b485-f6e678307357" java.lang.IllegalStateException:重放必须在记录之后发生。 recordEntitySelector(Recording(Filtering(FromSolutionEntitySelector(Customer))))next()尚未被调用。       at org.optaplanner.core.impl.heuristic.selector.entity.mimic.MimicReplayingEntitySelector $ ReplayingEntityIterator.next(MimicReplayingEntitySelector.java:104)       at org.optaplanner.core.impl.heuristic.selector.entity.nearby.NearEntityNearbyEntitySelector $ RandomNearbyEntityIterator.next(NearEntityNearbyEntitySelector.java:203)       at org.optaplanner.core.impl.heuristic.selector.entity.decorator.FilteringEntitySelector $ JustInTimeFilteringEntityIterator.createUpcomingSelection(FilteringEntitySelector.java:107)       at org.optaplanner.core.impl.heuristic.selector.common.iterator.UpcomingSelectionIterator.hasNext(UpcomingSelectionIterator.java:40)       在org.optaplanner.core.impl.heuristic.selector.common.iterator.AbstractRandomSwapIterator。(AbstractRandomSwapIterator.java:35)       at org.optaplanner.core.impl.heuristic.selector.move.generic.SwapMoveSelector $ 2.(SwapMoveSelector.java:125)       at org.optaplanner.core.impl.heuristic.selector.move.generic.SwapMoveSelector.iterator(SwapMoveSelector.java:125)       at org.optaplanner.core.impl.heuristic.selector.move.composite.UnionMoveSelector $ RandomUnionMoveIterator。(UnionMoveSelector.java:140)       at org.optaplanner.core.impl.heuristic.selector.move.composite.UnionMoveSelector.iterator(UnionMoveSelector.java:125)       at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.decideNextStep(LocalSearchDecider.java:112)       在org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:66)       在org.optaplanner.core.impl.solver.DefaultSolver.runPhases(DefaultSolver.java:213)       在org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:176)       在com.itmatic.optimisations.app.VehicleRoutingTask.run(VehicleRoutingTask.java:103)

我配置如下:

 <constructionHeuristic>
    <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
  </constructionHeuristic>
  <localSearch>
    <unionMoveSelector>
      <changeMoveSelector>
          <entitySelector id="entitySelector1"/>
          <filterClass>com.vos.optimisations.solver.move.CustomerChangeMoveFilter</filterClass>
          <valueSelector>
            <nearbySelection>
              <originEntitySelector mimicSelectorRef="entitySelector1"/>
              <nearbyDistanceMeterClass>com.vos.optimisations.domain.solver.nearby.CustomerNearbyDistanceMeter</nearbyDistanceMeterClass>
              <linearDistributionSizeMaximum>1000</linearDistributionSizeMaximum>
            </nearbySelection>
          </valueSelector>
      </changeMoveSelector>
      <swapMoveSelector>
        <entitySelector id="entitySelector2"/>
        <filterClass>com.vos.optimisations.solver.move.CustomerSwapMoveFilter</filterClass>
          <secondaryEntitySelector>
            <nearbySelection>
              <originEntitySelector mimicSelectorRef="entitySelector2"/>
              <nearbyDistanceMeterClass>com.vos.optimisations.domain.solver.nearby.CustomerNearbyDistanceMeter</nearbyDistanceMeterClass>
              <linearDistributionSizeMaximum>1000</linearDistributionSizeMaximum>
            </nearbySelection>
          </secondaryEntitySelector>
      </swapMoveSelector>
      <swapMoveSelector/>
      <subChainChangeMoveSelector>
        <selectReversingMoveToo>true</selectReversingMoveToo>
      </subChainChangeMoveSelector>
      <subChainSwapMoveSelector>
        <selectReversingMoveToo>true</selectReversingMoveToo>
      </subChainSwapMoveSelector>
    </unionMoveSelector>
    <acceptor>
      <lateAcceptanceSize>600</lateAcceptanceSize>
    </acceptor>
    <forager>
      <acceptedCountLimit>10</acceptedCountLimit>
    </forager>
  </localSearch>
</solver>

异常是什么意思,为什么会被抛出?

UPDATE:我删除了过滤器类,但仍然会抛出模仿异常。

仅当SwapMoveSelector到位时才会发生异常!!

0 个答案:

没有答案