我看过一个博客,用于使用附近的选择将VRPTW缩放到超过1000个位置。 我尝试实现它,这是我写的xml:
<unionMoveSelector>
<changeMoveSelector>
<entitySelector id="entitySelector1">
<entityClass>vehiclerouting.domain.Customer</entityClass>
</entitySelector>
<valueSelector variableName="previousStandstill">
<nearbySelection>
<originEntitySelector mimicSelectorRef="entitySelector1"/>
<nearbyDistanceMeterClass>vehiclerouting.domain.solver.nearby.CustomerNearbyDistanceMeter</nearbyDistanceMeterClass>
`<nearbySelectionDistributionType>PARABOLIC_DISTRIBUTION</nearbySelectionDistributionType>
</nearbySelection>
</valueSelector>
</changeMoveSelector>
<swapMoveSelector>
<entitySelector id="entitySelector2">
<entityClass>vehiclerouting.domain.Customer</entityClass>
</entitySelector>
<secondaryEntitySelector>
<entityClass>vehiclerouting.domain.Customer</entityClass>
<nearbySelection>
<originEntitySelector mimicSelectorRef="entitySelector2"/>
<nearbyDistanceMeterClass>vehiclerouting.domain.solver.nearby.CustomerNearbyDistanceMeter</nearbyDistanceMeterClass>
<nearbySelectionDistributionType>PARABOLIC_DISTRIBUTION</nearbySelectionDistributionType>
</nearbySelection>
</secondaryEntitySelector>
</swapMoveSelector>
</unionMoveSelector>
以下是异常(与154客户一起运行时):
2017/09/12 12:15:00.538 [SimpleAsyncTaskExecutor-1] [DEBUG] org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase - CH step (153), time spent (6850), score (-70002hard/-57992000soft), selected move count (156), picked move (161581 {null -> 161582}).
2017/09/12 12:15:00.547 [SimpleAsyncTaskExecutor-1] [INFO] org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase - Construction Heuristic phase (0) ended: time spent (6859), best score (-70002hard/-57992000soft), score calculation speed (1842/sec), step total (154).
2017/09/12 12:15:00.599 [SimpleAsyncTaskExecutor-1] [DEBUG] org.drools.core.common.DefaultAgenda - State was INACTIVE is now DISPOSED
2017/09/12 12:15:00.603 [SimpleAsyncTaskExecutor-1] [DEBUG] org.drools.core.common.DefaultAgenda - State was INACTIVE is now FIRING_ALL_RULES
2017/09/12 12:15:00.607 [SimpleAsyncTaskExecutor-1] [DEBUG] org.drools.core.common.DefaultAgenda - State was FIRING_ALL_RULES is now HALTING
2017/09/12 12:15:00.607 [SimpleAsyncTaskExecutor-1] [DEBUG] org.drools.core.common.DefaultAgenda - State was HALTING is now INACTIVE
2017/09/12 12:15:00.641 [SimpleAsyncTaskExecutor-1] [DEBUG] mobi.fareye.module.rabbitmq.AutoRoutingListener - Exception :
java.lang.NegativeArraySizeException: null
at org.optaplanner.core.impl.heuristic.selector.common.nearby.NearbyDistanceMatrix.addAllDestinations(NearbyDistanceMatrix.java:35) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.heuristic.selector.entity.nearby.NearEntityNearbyEntitySelector.phaseStarted(NearEntityNearbyEntitySelector.java:96) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.phase.event.PhaseLifecycleSupport.firePhaseStarted(PhaseLifecycleSupport.java:37) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.heuristic.selector.AbstractSelector.phaseStarted(AbstractSelector.java:49) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.phase.event.PhaseLifecycleSupport.firePhaseStarted(PhaseLifecycleSupport.java:37) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.heuristic.selector.AbstractSelector.phaseStarted(AbstractSelector.java:49) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.heuristic.selector.move.decorator.FilteringMoveSelector.phaseStarted(FilteringMoveSelector.java:51) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.phase.event.PhaseLifecycleSupport.firePhaseStarted(PhaseLifecycleSupport.java:37) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.heuristic.selector.AbstractSelector.phaseStarted(AbstractSelector.java:49) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.phaseStarted(LocalSearchDecider.java:95) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.phaseStarted(DefaultLocalSearchPhase.java:115) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:64) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
at org.optaplanner.core.impl.solver.AbstractSolver.runPhases(AbstractSolver.java:87) ~[optaplanner-core-7.2.0.Final.jar:7.2.0.Final]
我想,我可能在xml配置中做错了。谢谢你的帮助。