Optaplanner VariableListener损坏

时间:2016-02-24 19:52:38

标签: optaplanner

我正面临Optaplanner的问题。

当我尝试在VehicleRoutingProblem上实现Pick和Delivery类型的解决方案时,它开始了。 在我的一个测试中,我在调试中看到了一些错误,但结果似乎是最好的解决方案。 这就是我所看到的:

  • 代理-0
  • 客户-11_PICKUP_1_ [1]
  • 客户-12_DELIVERY_1 _ []
  • 客户-21_PICKUP_2_ [2]
  • 客户-22_DELIVERY_2 _ []
  • 客户-41_PICKUP_4_ [4]
  • 客户-42_DELIVERY_4 _ []
  • 客户-31_PICKUP_3_ [4,3]
  • 客户-32_DELIVERY_3_ [4]

这是客户链表的路径。

Agent-0是代理。

Customer-XX是客户。

PICKUP_X或DELIVERY_X是代理必须执行的操作类型,X代表项目编号。

括号中的内容是代理的内容。

正如您在示例中看到的那样,在DELIVERY_4之后,出现了编号为4的项目,但它已经交付......

我认为variablelistener存在问题。 Customer中有一个影子变量(agentContents),用于跟踪代理的内容。

所以我决定打开FULL_ASSERT。 而我所看到的非常有趣。 有一个例外:

java.lang.IllegalStateException: Solving failed.
    at org.optaplanner.examples.common.swingui.SolverAndPersistenceFrame$SolveWorker.done(SolverAndPersistenceFrame.java:298)
    at javax.swing.SwingWorker$5.run(Unknown Source)
    at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(Unknown Source)
    at sun.swing.AccumulativeRunnable.run(Unknown Source)
    at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(Unknown Source)
    at javax.swing.Timer.fireActionPerformed(Unknown Source)
    at javax.swing.Timer$DoPostEvent.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: VariableListener corruption: the entity (Customer-32)'s shadow variable (Customer.agentContents)'s corrupted value ([4]) changed to uncorrupted value ([]) after all VariableListeners were triggered without changes to the genuine variables.
Probably the VariableListener class for that shadow variable (Customer.agentContents) forgot to update it when one of its sources changed after completedAction (Undo(Customer-21 {Customer-12 -> Customer-32})).
    at org.optaplanner.core.impl.score.director.AbstractScoreDirector.assertShadowVariablesAreNotStale(AbstractScoreDirector.java:349)
    at org.optaplanner.core.impl.phase.scope.AbstractPhaseScope.assertExpectedUndoMoveScore(AbstractPhaseScope.java:144)
    at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.doMove(LocalSearchDecider.java:153)
    at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.decideNextStep(LocalSearchDecider.java:121)
    at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:72)
    at org.optaplanner.core.impl.solver.DefaultSolver.runPhases(DefaultSolver.java:214)
    at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:176)
    at org.optaplanner.examples.common.business.SolutionBusiness.solve(SolutionBusiness.java:307)
    at org.optaplanner.examples.common.swingui.SolverAndPersistenceFrame$SolveWorker.doInBackground(SolverAndPersistenceFrame.java:287)
    at org.optaplanner.examples.common.swingui.SolverAndPersistenceFrame$SolveWorker.doInBackground(SolverAndPersistenceFrame.java:1)
    at javax.swing.SwingWorker$1.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at javax.swing.SwingWorker.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

撤消移动似乎会引发问题。 但我无法确切地看出问题出在哪里。我认为我的variablelistener是冒犯了。

另外,我不知道如何阅读:撤消(客户-21 {客户-12->客户-32}))。

你有办法调试这个吗? 如果需要,我可以给你一些代码。

谢谢。

0 个答案:

没有答案