java - Drools Planner 构造启发式 java.lang.ClassCastException

标签 java drools drools-planner

我尝试使用 Drools Planner 5.4.Final 构造启发式类型 BEST_FIT 初始化解决方案。

<constructionHeuristic>
    <constructionHeuristicType>BEST_FIT</constructionHeuristicType>
</constructionHeuristic>

运行时评估时出现以下错误

java.lang.ClassCastException: org.drools.planner.config.constructionheuristic.ConstructionHeuristicSolverPhaseConfig cannot be cast to org.drools.planner.config.localsearch.LocalSearchSolverPhaseConfig

有人有任何提示吗?

谢谢

这是堆栈跟踪

com.thoughtworks.xstream.converters.ConversionException: Element constructionHeuristic of type org.drools.planner.config.constructionheuristic.ConstructionHeuristicSolverPhaseConfig is not defined as field in type org.drools.planner.config.localsearch.LocalSearchSolverPhaseConfig
---- Debugging information ----
class               : org.drools.planner.config.localsearch.LocalSearchSolverPhaseConfig
required-type       : org.drools.planner.config.localsearch.LocalSearchSolverPhaseConfig
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
line number         : 23
class[1]            : org.drools.planner.config.solver.SolverConfig
version             : null
-------------------------------
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter: writeValueToImplicitCollection (line:399)
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter: doUnmarshal (line:330)
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter: unmarshal (line:230)
com.thoughtworks.xstream.core.TreeUnmarshaller: convert (line:72)
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller: convert (line:65)
com.thoughtworks.xstream.core.TreeUnmarshaller: convertAnother (line:66)
com.thoughtworks.xstream.core.TreeUnmarshaller: convertAnother (line:50)
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter: doUnmarshal (line:318)
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter: unmarshal (line:230)
com.thoughtworks.xstream.core.TreeUnmarshaller: convert (line:72)
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller: convert (line:65)
com.thoughtworks.xstream.core.TreeUnmarshaller: convertAnother (line:66)
com.thoughtworks.xstream.core.TreeUnmarshaller: convertAnother (line:50)
com.thoughtworks.xstream.core.TreeUnmarshaller: start (line:134)
com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy: unmarshal (line:32)
com.thoughtworks.xstream.XStream: unmarshal (line:1035)
com.thoughtworks.xstream.XStream: unmarshal (line:1019)
com.thoughtworks.xstream.XStream: fromXML (line:895)
org.drools.planner.config.XmlSolverFactory: configure (line:95)
org.drools.planner.config.XmlSolverFactory: configure (line:85)
org.drools.planner.config.XmlSolverFactory: configure (line:78)

最佳答案

根据堆栈跟踪,你正在做类似的事情

<solver>
  ...
  <localSearch>
    <constructionHeuristic>
       ...    
    </constructionHeuristic>
    ...
  </localSearch>
<solver>

虽然它应该是这样的:

<solver>
  ...
  <constructionHeuristic>
    ...    
  </constructionHeuristic>
  <localSearch>
    ...
  </localSearch>
<solver>

关于java - Drools Planner 构造启发式 java.lang.ClassCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19160671/

相关文章:

java - 这个文件扫描器代码有什么问题?

java - DRools:如何在事实中的任意嵌套列表上使用

eclipse - 在 Eclipse 中安装 Drools Planner

java - 在 Scala 中实现具有原始类型的方法

java - 从方法返回后如何停止递归

java - 遗留应用程序迁移 : EJB3 or Spring

java - Hazelcast 中的未知日志跟踪

流口水复杂的事实

java - Optaplanner - 运行可执行 jar 时出错,但在 eclipse 中运行正常

java - 调度时间表算法