OptaPlanner在CartesianProductMoveSelector创建的CompositeMove上抛出IllegalStateException [英] OptaPlanner throwing IllegalStateException on CompositeMove created by CartesianProductMoveSelector

查看:130
本文介绍了OptaPlanner在CartesianProductMoveSelector创建的CompositeMove上抛出IllegalStateException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上我的问题是,OptaPlanner抛出了这个问题:

so basically my problem is, that OptaPlanner is throwing this:

java.lang.IllegalStateException: The entity (...) has a variable (previousEntry) with value (...) which has a sourceVariableName variable (nextEntry) with a value (...) which is not null.
Verify the consistency of your input problem for that sourceVariableName variable.
    at org.optaplanner.core.impl.domain.variable.inverserelation.SingletonInverseVariableListener.insert(SingletonInverseVariableListener.java:72)
    at org.optaplanner.core.impl.domain.variable.inverserelation.SingletonInverseVariableListener.afterVariableChanged(SingletonInverseVariableListener.java:51)
    at org.optaplanner.core.impl.domain.variable.listener.support.VariableListenerSupport.triggerVariableListenersInNotificationQueues(VariableListenerSupport.java:209)
    at org.optaplanner.core.impl.score.director.AbstractScoreDirector.triggerVariableListeners(AbstractScoreDirector.java:259)
    at org.optaplanner.core.impl.heuristic.move.AbstractMove.doMove(AbstractMove.java:36)
    at org.optaplanner.core.impl.heuristic.move.AbstractMove.doMove(AbstractMove.java:30)
    at org.optaplanner.core.impl.heuristic.move.CompositeMove.doMove(CompositeMove.java:108)
    at org.optaplanner.core.impl.heuristic.move.CompositeMove.doMove(CompositeMove.java:37)
    at org.optaplanner.core.impl.score.director.AbstractScoreDirector.doAndProcessMove(AbstractScoreDirector.java:187)
    at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.doMove(LocalSearchDecider.java:132)
    at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.decideNextStep(LocalSearchDecider.java:116)
    at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:70)
    at org.optaplanner.core.impl.solver.AbstractSolver.runPhases(AbstractSolver.java:88)
    at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:191)

我正在使用此动作创建移动

I'm creating the move using this:

<cartesianProductMoveSelector>
    <ignoreEmptyChildIterators>true</ignoreEmptyChildIterators>
    <changeMoveSelector/>
    <swapMoveSelector/>
</cartesianProductMoveSelector>

我正在尝试优化链,因此我的计划变量previousEntry有一个影子变量(nextEntry).如果使用unionMoveSelector,一切都将正常工作,但是现在我想尝试合并我的动作,以便OptaPlanner可以摆脱局部最优.我只有1个刨削变量.

I'm trying to optimize a chain, so I have a shadow variable (nextEntry) for my planning variable previousEntry. Everything is working if I use unionMoveSelector, but now I want to try to combine my moves so OptaPlanner can get out from a local optimum. I only have 1 planing variable.

刚刚更新到7.19.0.Final,问题仍然存在...

just updated to 7.19.0.Final the problem still exists...

刚刚使用FULL_ASSERT测试并获得了相同的结果,而没有cartesianProductMoveSelector我得到了一个结果:

just tested with FULL_ASSERT and got the same result, without cartesianProductMoveSelector I get a result:

Solving ended: time spent (371190), best score (0hard/-31648770soft), score calculation speed (81/sec), phase total (3), environment mode (FULL_ASSERT).

如果我添加cartesianProductMoveSelector,我会得到完全相同的异常

If I add cartesianProductMoveSelector I get exactly the same exception

好吧,我只是用optaplanner的vrp-example(7.17.0.Final)示例进行了测试,并得到了完全相同的异常:

well I just tested it with the vrp-example of optaplanner (7.17.0.Final) and got exact the same exception:

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.IllegalStateException: The entity (Customer-7) has a variable (previousStandstill) with value (Customer-33) which has a sourceVariableName variable (nextCustomer) with a value (Customer-5) which is not null.
Verify the consistency of your input problem for that sourceVariableName variable.
at org.optaplanner.core.impl.domain.variable.inverserelation.SingletonInverseVariableListener.insert(SingletonInverseVariableListener.java:72)
at org.optaplanner.core.impl.domain.variable.inverserelation.SingletonInverseVariableListener.afterVariableChanged(SingletonInverseVariableListener.java:51)
at org.optaplanner.core.impl.domain.variable.listener.support.VariableListenerSupport.triggerVariableListenersInNotificationQueues(VariableListenerSupport.java:209)
at org.optaplanner.core.impl.score.director.AbstractScoreDirector.triggerVariableListeners(AbstractScoreDirector.java:261)
at org.optaplanner.core.impl.heuristic.move.AbstractMove.doMove(AbstractMove.java:36)
at org.optaplanner.core.impl.heuristic.move.AbstractMove.doMove(AbstractMove.java:30)
at org.optaplanner.core.impl.heuristic.move.CompositeMove.doMove(CompositeMove.java:108)
at org.optaplanner.core.impl.heuristic.move.CompositeMove.doMove(CompositeMove.java:37)
at org.optaplanner.core.impl.score.director.AbstractScoreDirector.doAndProcessMove(AbstractScoreDirector.java:189)
at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.doMove(LocalSearchDecider.java:132)
at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.decideNextStep(LocalSearchDecider.java:116)
at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:70)
at org.optaplanner.core.impl.solver.AbstractSolver.runPhases(AbstractSolver.java:88)
at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:191)
at org.optaplanner.examples.common.business.SolutionBusiness.solve(SolutionBusiness.java:329)
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)

我将提交一个问题

可以在此处

推荐答案

在创建具有多个ChainedChange和ChainedSwapMoves的CompositeMove时,体验相同.这样做的原因是,您的第一个举动可能会更改在第一个举动之后的Move中操纵的PlanningEntity的PlanningValue.虽然移动的创建已经捕获了所有变量和值的状态,但是第二个移动预计将不再存在现有的计划状态.

experienced the same when creating a CompositeMove with multiple ChainedChange and ChainedSwapMoves. The reason for this is, that your first move might Change the PlanningValue of a PlanningEntity manipulated in a Move following that first one. While the creation of the moves already captures the Status of all the variables and values, the second move anticipates a not longer existing planning Status.

示例: 在您的移动"之前进行链接:

Example: chain before your Move:

(I)A-> B-> C-> D

(I) A -> B -> C -> D

您的综合举动: 1)ChainedChangeMove,用于将B移动到A的前面 2)通过ChainedChangeMove将D移动到C的前面

your Composite Move: 1) ChainedChangeMove for Moving B in front of A 2) ChainedChangeMove for Moving D in front of C

在移动创建中,值将存储在移动中的(I)中.第1步将正确执行.

in the move creation the values will be stored a shown in (I) in the moves. Move 1 will execute correct.

移动1)之后的解决方案: (II)B-> A-> C-> D

Solution after move 1): (II) B -> A -> C -> D

第二步现在将尝试将D移到B后面,但是A的previousStandstill变量中已经引用了B

the second move will now try to move D behind B, but B is already referenced in the previousStandstill variable of A

您可以使用其他版本的合成举动创建类似的场景.只要链接的移动在创建移动时保存了链的状态,联合移动和复合移动都可能会失败.

You can create similiar scenarios with other versions of composite moves. As long as the chained moves save the status of the chain at creation of the move, union moves and compsite moves will potentially fail.

这篇关于OptaPlanner在CartesianProductMoveSelector创建的CompositeMove上抛出IllegalStateException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆