Question

I tried to initialize the solution using Drools Planner 5.4.Final Contruction Heuristic Type BEST_FIT.

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

The following error occurs during evaluation at runtime

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

Does anybody have any hints?

Thanks

This is the stacktrace

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)
Était-ce utile?

La solution

According to the stacktrace you're doing something like

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

while it should be something like:

<solver>
  ...
  <constructionHeuristic>
    ...    
  </constructionHeuristic>
  <localSearch>
    ...
  </localSearch>
<solver>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top