Optaplanner求解阶段陷入建筑启发阶段

时间:2016-04-03 04:52:35

标签: java eclipse logback wildfly-8 optaplanner

我正在基于Optaplanner车辆路线网示例为护士排队建立一个网络应用程序。当我试图在我的Eclipse内部运行JBoss WildFly 8.x时,它只运行到构建启发阶段,然后在没有任何进展的情况下停留在那里。 有趣的是,代码实际上是从optaplanner 6.3.0-final发行版中的护士排班示例中移除的。在Windows应用程序中,它运行顺畅,没有任何麻烦或卡住。

更新

我终于将日志级别设置为TRACE,这是出来的日志:

2016-04-06 23:10:49,930 INFO  [org.optaplanner.webexamples.nurserostering.rest.persistence.NurseRosteringDao] (default task-11) Opened: D:\Users\Administrator\wildfly-8.2.1.Final\standalone\deployments\optaplanner-webexamples.war\WEB-INF\classes\org\optaplanner\webexamples\nurserostering\data\team-machine1.xml
2016-04-06 23:10:59,194 TRACE [org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor] (default task-12)     Model annotations parsed for Solution NurseRoster:
2016-04-06 23:10:59,195 TRACE [org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor] (default task-12)         Entity ShiftAssignment:
2016-04-06 23:10:59,195 TRACE [org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor] (default task-12)             Variable employee (genuine)
2016-04-06 23:11:03,850 INFO  [org.drools.compiler.kie.builder.impl.KieRepositoryImpl] (default task-12) KieModule was added: MemoryKieModule[releaseId=org.default:artifact:1.0.0-SNAPSHOT]
2016-04-06 23:11:04,499 INFO  [org.optaplanner.core.impl.solver.DefaultSolver] (pool-6-thread-1) Solving started: time spent (395), best score (uninitialized/0hard/-260soft), environment mode (REPRODUCIBLE), random (JDK with seed 0).
2016-04-06 23:11:04,505 TRACE [org.optaplanner.core.impl.heuristic.selector.value.decorator.SortingValueSelector] (pool-6-thread-1)     Created cachedValueList: size (10), valueSelector (Sorting(FromSolutionPropertyValueSelector(employee))).
2016-04-06 23:11:04,508 TRACE [org.optaplanner.core.impl.heuristic.selector.value.decorator.SortingValueSelector] (pool-6-thread-1)     Sorted cachedValueList: size (10), valueSelector (Sorting(FromSolutionPropertyValueSelector(employee))).
2016-04-06 23:11:04,665 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (0), score (0hard/-260soft), move (2010-01-01(Fri)_E@null {null -> A(A)}).
2016-04-06 23:11:04,676 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (1), score (-1hard/-259soft), move (2010-01-01(Fri)_E@null {null -> B(B)}).
2016-04-06 23:11:04,682 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (2), score (-1hard/-260soft), move (2010-01-01(Fri)_E@null {null -> C(C)}).
2016-04-06 23:11:04,699 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (3), score (0hard/-260soft), move (2010-01-01(Fri)_E@null {null -> D(D)}).
2016-04-06 23:11:04,707 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (4), score (-1hard/-260soft), move (2010-01-01(Fri)_E@null {null -> E(E)}).
2016-04-06 23:11:04,713 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (5), score (-1hard/-259soft), move (2010-01-01(Fri)_E@null {null -> F(F)}).
2016-04-06 23:11:04,718 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (6), score (0hard/-259soft), move (2010-01-01(Fri)_E@null {null -> G(G)}).
2016-04-06 23:11:04,726 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (7), score (-1hard/-259soft), move (2010-01-01(Fri)_E@null {null -> H(H)}).
2016-04-06 23:11:04,732 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (8), score (-1hard/-258soft), move (2010-01-01(Fri)_E@null {null -> I(I)}).
2016-04-06 23:11:04,738 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (9), score (0hard/-258soft), move (2010-01-01(Fri)_E@null {null -> J(J)}).
2016-04-06 23:11:04,739 DEBUG [org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase] (pool-6-thread-1)     CH step (0), time spent (634), score (0hard/-258soft), selected move count (10), picked move (2010-01-01(Fri)_E@null {null -> J(J)}).
...
2016-04-06 23:11:07,274 DEBUG [org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase] (pool-6-thread-1)     CH step (150), time spent (3170), score (-1hard/-103soft), selected move count (10), picked move (2010-01-28(Thu)_L@null {null -> C(C)}).
2016-04-06 23:11:07,275 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (0), score (-3hard/-104soft), move (2010-01-28(Thu)_D@null {null -> A(A)}).
2016-04-06 23:11:07,276 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (1), score (-2hard/-104soft), move (2010-01-28(Thu)_D@null {null -> B(B)}).
2016-04-06 23:11:07,276 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (2), score (-3hard/-103soft), move (2010-01-28(Thu)_D@null {null -> C(C)}).
2016-04-06 23:11:07,277 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (3), score (-2hard/-103soft), move (2010-01-28(Thu)_D@null {null -> D(D)}).
2016-04-06 23:11:07,278 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (4), score (-1hard/-107soft), move (2010-01-28(Thu)_D@null {null -> E(E)}).
2016-04-06 23:11:07,279 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (5), score (-2hard/-105soft), move (2010-01-28(Thu)_D@null {null -> F(F)}).
2016-04-06 23:11:07,280 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (6), score (-2hard/-106soft), move (2010-01-28(Thu)_D@null {null -> G(G)}).
2016-04-06 23:11:07,288 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (7), score (-2hard/-104soft), move (2010-01-28(Thu)_D@null {null -> H(H)}).
2016-04-06 23:11:07,289 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (8), score (-2hard/-104soft), move (2010-01-28(Thu)_D@null {null -> I(I)}).
2016-04-06 23:11:07,290 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (9), score (-2hard/-104soft), move (2010-01-28(Thu)_D@null {null -> J(J)}).
2016-04-06 23:11:07,290 DEBUG [org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase] (pool-6-thread-1)     CH step (151), time spent (3186), score (-1hard/-107soft), selected move count (10), picked move (2010-01-28(Thu)_D@null {null -> E(E)}).
2016-04-06 23:11:07,291 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (0), score (-2hard/-108soft), move (2010-01-28(Thu)_N@null {null -> A(A)}).
2016-04-06 23:11:07,292 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (1), score (-3hard/-108soft), move (2010-01-28(Thu)_N@null {null -> B(B)}).
2016-04-06 23:11:07,293 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (2), score (-3hard/-107soft), move (2010-01-28(Thu)_N@null {null -> C(C)}).
2016-04-06 23:11:07,293 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (3), score (-1hard/-107soft), move (2010-01-28(Thu)_N@null {null -> D(D)}).
2016-04-06 23:11:07,294 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (4), score (-3hard/-109soft), move (2010-01-28(Thu)_N@null {null -> E(E)}).
2016-04-06 23:11:07,295 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (5), score (-2hard/-109soft), move (2010-01-28(Thu)_N@null {null -> F(F)}).
2016-04-06 23:11:07,296 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (6), score (-1hard/-110soft), move (2010-01-28(Thu)_N@null {null -> G(G)}).
2016-04-06 23:11:07,297 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (7), score (-3hard/-108soft), move (2010-01-28(Thu)_N@null {null -> H(H)}).
2016-04-06 23:11:07,299 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (8), score (-2hard/-109soft), move (2010-01-28(Thu)_N@null {null -> I(I)}).
2016-04-06 23:11:07,300 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (9), score (-1hard/-107soft), move (2010-01-28(Thu)_N@null {null -> J(J)}).
2016-04-06 23:11:07,300 DEBUG [org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase] (pool-6-thread-1)     CH step (152), time spent (3196), score (-1hard/-107soft), selected move count (10), picked move (2010-01-28(Thu)_N@null {null -> D(D)}).
2016-04-06 23:11:07,330 INFO  [org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase] (pool-6-thread-1) Construction Heuristic phase (0) ended: step total (153), time spent (3226), best score (-1hard/-107soft).
2016-04-06 23:11:07,400 TRACE [org.optaplanner.core.impl.heuristic.selector.move.factory.MoveListFactoryToMoveSelectorBridge] (pool-6-thread-1)     Created cachedMoveList: size (1530), moveSelector (MoveListFactory(class org.optaplanner.webexamples.nurserostering.rest.solver.move.factory.EmployeeChangeMoveFactory)).
2016-04-06 23:11:07,405 TRACE [org.optaplanner.core.impl.heuristic.selector.move.factory.MoveListFactoryToMoveSelectorBridge] (pool-6-thread-1)     Created cachedMoveList: size (11628), moveSelector (MoveListFactory(class org.optaplanner.webexamples.nurserostering.rest.solver.move.factory.ShiftAssignmentSwapMoveFactory)).
2016-04-06 23:11:07,411 TRACE [org.optaplanner.core.impl.heuristic.selector.move.factory.MoveListFactoryToMoveSelectorBridge] (pool-6-thread-1)     Created cachedMoveList: size (268), moveSelector (MoveListFactory(class org.optaplanner.webexamples.nurserostering.rest.solver.move.factory.ShiftAssignmentPillarPartSwapMoveFactory)).
2016-04-06 23:13:58,592 INFO  [org.optaplanner.core.impl.solver.BasicPlumbingTermination] (default task-36) Terminating solver early.

日志中有什么问题吗?请帮助我,谢谢和问候。

更新2

我将我的桌面应用程序护士名单更新到optaplanner 6.3.0-final,然后运行它,结果是它卡在得分-1hard / -107soft。它还提示我一个异常,这是堆栈跟踪:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Solving failed.
    at com.employee.scheduler.common.swingui.SolverAndPersistenceFrame$SolveWorker.done(SolverAndPersistenceFrame.java:299)
    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:756)
    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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    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.IllegalStateException: The notificationQueues might not be empty (false) so any shadow variables might be stale so score calculation is unreliable.
Maybe a ScoreDirector.before*() method was called without calling ScoreDirector.triggerVariableListeners(), before calling ScoreDirector.calculateScore().
    at com.employee.scheduler.common.swingui.SolverAndPersistenceFrame$SolveWorker.done(SolverAndPersistenceFrame.java:299)
    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:756)
    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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    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)

更新3

我打开environmentMode为FULL_ASSERT,这是我的config.xml:

<solver>
  <environmentMode>FULL_ASSERT</environmentMode>
  ...
</solver>

然后我尝试运行它,它仍然停留在本地搜索阶段(就像我之前发布的日志一样)。这是日志:

11:29:21,671 DEBUG [org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase] (pool-6-thread-1)     CH step (151), time spent (10808), score (-1hard/-107soft), selected move count (10), picked move (2010-01-28(Thu)_D@null {null -> E(E)}).
11:29:21,676 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (0), score (-2hard/-108soft), move (2010-01-28(Thu)_N@null {null -> A(A)}).
11:29:21,680 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (1), score (-3hard/-108soft), move (2010-01-28(Thu)_N@null {null -> B(B)}).
11:29:21,684 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (2), score (-3hard/-107soft), move (2010-01-28(Thu)_N@null {null -> C(C)}).
11:29:21,689 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (3), score (-1hard/-107soft), move (2010-01-28(Thu)_N@null {null -> D(D)}).
11:29:21,693 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (4), score (-3hard/-109soft), move (2010-01-28(Thu)_N@null {null -> E(E)}).
11:29:21,699 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (5), score (-2hard/-109soft), move (2010-01-28(Thu)_N@null {null -> F(F)}).
11:29:21,706 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (6), score (-1hard/-110soft), move (2010-01-28(Thu)_N@null {null -> G(G)}).
11:29:21,714 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (7), score (-3hard/-108soft), move (2010-01-28(Thu)_N@null {null -> H(H)}).
11:29:21,721 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (8), score (-2hard/-109soft), move (2010-01-28(Thu)_N@null {null -> I(I)}).
11:29:21,728 TRACE [org.optaplanner.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider] (pool-6-thread-1)         Move index (9), score (-1hard/-107soft), move (2010-01-28(Thu)_N@null {null -> J(J)}).
11:29:21,733 DEBUG [org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase] (pool-6-thread-1)     CH step (152), time spent (10870), score (-1hard/-107soft), selected move count (10), picked move (2010-01-28(Thu)_N@null {null -> D(D)}).
11:29:21,739 INFO  [org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase] (pool-6-thread-1) Construction Heuristic phase (0) ended: step total (153), time spent (10876), best score (-1hard/-107soft).
11:29:21,754 TRACE [org.optaplanner.core.impl.heuristic.selector.move.factory.MoveListFactoryToMoveSelectorBridge] (pool-6-thread-1)     Created cachedMoveList: size (1530), moveSelector (MoveListFactory(class org.optaplanner.webexamples.nurserostering.rest.solver.move.factory.EmployeeChangeMoveFactory)).
11:29:21,759 TRACE [org.optaplanner.core.impl.heuristic.selector.move.factory.MoveListFactoryToMoveSelectorBridge] (pool-6-thread-1)     Created cachedMoveList: size (11628), moveSelector (MoveListFactory(class org.optaplanner.webexamples.nurserostering.rest.solver.move.factory.ShiftAssignmentSwapMoveFactory)).
11:29:21,765 TRACE [org.optaplanner.core.impl.heuristic.selector.move.factory.MoveListFactoryToMoveSelectorBridge] (pool-6-thread-1)     Created cachedMoveList: size (268), moveSelector (MoveListFactory(class org.optaplanner.webexamples.nurserostering.rest.solver.move.factory.ShiftAssignmentPillarPartSwapMoveFactory)).
11:33:26,137 INFO  [org.optaplanner.core.impl.solver.BasicPlumbingTermination] (default task-17) Terminating solver early.

任何人都有意见吗?打开环境模式我应该期待什么?

1 个答案:

答案 0 :(得分:0)

从日志中分析:

23:11:07,411 TRACE...     Created cachedMoveList: ...
// 2 minutes and not a single move selected. That's impossible.
// It must be stuck in a infinite loop somehow.
// Do a thread dump (ctrl-break) 20 seconds after that "Created cachedMoveList" line. Before terminating it to see where it's spending it's time.
// 
// Terminated asynchronously. This means it's actually in a loop that does checks the termination status
23:13:58,592 INFO ...     Terminating solver early.

这说明了很多:

  • 并非所有动作都是禁忌或所有动作都是可撤消的,因为没有选择任何动作(否则我们会看到那些动作的TRACE日志消息)。
  • 不是你有一个自定义的MoveFactoryList进入一个无限循环,因为否则terminateEarly()调用不会立即被尊重 - 它将被忽略。
  • 并非所有的移动选择器都是空的,至少有3个缓存的移动选择器记录它们的大小超过1k移动。在这种情况下,我们还会看到调试步骤日志消息,我们不会这样做。

所以我不知道发生了什么。但它看起来像一个真正的错误,或者至少是一个我还没见过的独特情况。通过creating a new jira给我发送一个复制器,并在那里附上一个复制器,我将会看一看。一个好的复制者有一个pom.xml我可以打开并有主要类或测试类我可以运行来重现问题(所以我不需要浪费时间将它部署到wildfly等)。

相关问题