2013-10-03 54 views
0

我試圖初始化解決方案使用Drools Planner 5.4.Final構造啓發式類型BEST_FIT。Drools Planner構造Huristic java.lang.ClassCastException

<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) 
+0

什麼是完整的堆棧跟蹤?順便說一句:它真的值得升級到5.5(JIT的東西),然後到6.0(加速等)。只需按照升級配方txt。 –

回答

1

根據你正在做這樣的事情

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

,而應該是堆棧跟蹤是這樣的:

<solver> 
    ... 
    <constructionHeuristic> 
    ...  
    </constructionHeuristic> 
    <localSearch> 
    ... 
    </localSearch> 
<solver> 
+0

嗨,謝謝你的建議。我附加了錯誤的stacktrace,因爲我做了幾次嘗試。 問題是(在我的代碼中)這些行: LocalSearchSolverPhaseConfig localSearchSolverPhaseConfig =(LocalSearchSolverPhaseConfig)configurer.getSolverConfig()。getSolverPhaseConfigList()。get(0); localSearchSolverPhaseConfig.getForagerConfig()。setMinimalAcceptedSelection(options.getDepthSearch()); –

+0

因爲之前在config.xml中我只有一個求解器階段。 我糾正了我的代碼,但不幸的是,在我的問題中,我有2個計劃實體,啓發式只支持一個: java.lang.UnsupportedOperationException:目前,greedyFit實現僅支持1個planningEntityImplementationClass。 –

+0

@TommasoTaruffi升級到OptaPlanner(= Drools Planner)6.0.0.CR4或更高版本,它支持具有多個計劃實體的CH。 –