Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-1961

NPE in ChainedSwapMove

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 7.39.0.Final
    • 7.36.0.Final
    • optaplanner-core
    • None
    • 2020 Week 22-24 (from May 25)
    • 3
    • Hide

      1. Apply the attached diff to 7.36.1.Final
      2. Run the VehicleRoutingApp
      3. Import belgium/basic/air/belgium-n100-k10.vrp or any other non-serialized problem
      4. Solve

      Show
      1. Apply the attached diff to 7.36.1.Final 2. Run the VehicleRoutingApp 3. Import belgium/basic/air/belgium-n100-k10.vrp or any other non-serialized problem 4. Solve
    • NEW
    • NEW

      If a planning entity has a chained and a normal planning variable, the default local search phase fails with a NullPointerException when it tries to generate swap moves. The problem is that the inverseVariableSupply is null for the non-chained variables.

      Workaround: specify selectors like this:

       <localSearch>
          <unionMoveSelector>
            <changeMoveSelector/>
            <swapMoveSelector>
      		<variableNameInclude>previousStandstill</variableNameInclude>
            </swapMoveSelector>
            <subChainChangeMoveSelector>
              <subChainSelector>
            	  <valueSelector variableName="previousStandstill"/>
            	</subChainSelector>
            	<valueSelector variableName="previousStandstill"/>
              <selectReversingMoveToo>true</selectReversingMoveToo>
            </subChainChangeMoveSelector>
            <subChainSwapMoveSelector>
            	<subChainSelector>
            	  <valueSelector variableName="previousStandstill"/>
            	</subChainSelector>
       		<secondarySubChainSelector>
                <valueSelector variableName="previousStandstill"/>
              </secondarySubChainSelector>
              <selectReversingMoveToo>true</selectReversingMoveToo>
            </subChainSwapMoveSelector>
            <!-- TODO use nearby selection to scale out -->
          </unionMoveSelector>
          <acceptor>
            <lateAcceptanceSize>200</lateAcceptanceSize>
          </acceptor>
          <forager>
            <acceptedCountLimit>1</acceptedCountLimit>
          </forager>
        </localSearch>
      

      Console output:

      Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Solving failed.
      	at org.optaplanner.examples.common.swingui.SolverAndPersistenceFrame$SolveWorker.done(SolverAndPersistenceFrame.java:382)
      	at javax.swing.SwingWorker$5.run(SwingWorker.java:737)
      	at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:832)
      	at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
      	at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:842)
      	at javax.swing.Timer.fireActionPerformed(Timer.java:313)
      	at javax.swing.Timer$DoPostEvent.run(Timer.java:245)
      	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
      	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
      	at java.awt.EventQueue.access$500(EventQueue.java:97)
      	at java.awt.EventQueue$3.run(EventQueue.java:709)
      	at java.awt.EventQueue$3.run(EventQueue.java:703)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
      	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
      	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
      	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
      Caused by: java.lang.NullPointerException
      	at org.optaplanner.core.impl.heuristic.selector.move.generic.chained.ChainedSwapMove.<init>(ChainedSwapMove.java:43)
      	at org.optaplanner.core.impl.heuristic.selector.move.generic.SwapMoveSelector$2.newSwapSelection(SwapMoveSelector.java:150)
      	at org.optaplanner.core.impl.heuristic.selector.move.generic.SwapMoveSelector$2.newSwapSelection(SwapMoveSelector.java:147)
      	at org.optaplanner.core.impl.heuristic.selector.common.iterator.AbstractRandomSwapIterator.createUpcomingSelection(AbstractRandomSwapIterator.java:58)
      	at org.optaplanner.core.impl.heuristic.selector.common.iterator.UpcomingSelectionIterator.hasNext(UpcomingSelectionIterator.java:42)
      	at org.optaplanner.core.impl.heuristic.selector.move.composite.UnionMoveSelector$RandomUnionMoveIterator.refreshMoveIteratorMap(UnionMoveSelector.java:190)
      	at org.optaplanner.core.impl.heuristic.selector.move.composite.UnionMoveSelector$RandomUnionMoveIterator.hasNext(UnionMoveSelector.java:164)
      	at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.decideNextStep(LocalSearchDecider.java:108)
      	at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:70)
      	at org.optaplanner.core.impl.solver.AbstractSolver.runPhases(AbstractSolver.java:98)
      	at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:189)
      	at org.optaplanner.examples.common.business.SolutionBusiness.solve(SolutionBusiness.java:334)
      	at org.optaplanner.examples.common.swingui.SolverAndPersistenceFrame$SolveWorker.doInBackground(SolverAndPersistenceFrame.java:370)
      	at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at javax.swing.SwingWorker.run(SwingWorker.java:334)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      

              lpetrovi@redhat.com Lukáš Petrovický (Inactive)
              firesharker Balint Fabry (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: