微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

optaplanner Matrix benchmarking failed 原因:Unmarshalling of benchmarkConfigResource failed on line number (40)

如何解决optaplanner Matrix benchmarking failed 原因:Unmarshalling of benchmarkConfigResource failed on line number (40)

我之前在没有基于模板的基准测试的情况下成功使用了基准测试,但是基于模板的基准测试在这里不能工作。 我使用 https://docs.optaplanner.org/

中的测试用例
<plannerBenchmark>
  <benchmarkDirectory>local/data</benchmarkDirectory>
  <parallelBenchmarkCount>(availableProcessorCount / 2)+1</parallelBenchmarkCount>
  <warmUpSecondsspentLimit>60</warmUpSecondsspentLimit>
  <inheritedSolverBenchmark>
    ...
  </inheritedSolverBenchmark>

<#list [5,7,11,13] as entityTabuSize>
<#list [500,1000,2000] as acceptedCountLimit>
  <solverBenchmark>
    <name>Tabu Search entityTabuSize ${entityTabuSize} acceptedCountLimit ${acceptedCountLimit}</name>
    <solver>
      <localSearch>
        <unionMoveSelector>
          <changeMoveSelector/>
          <swapMoveSelector/>
        </unionMoveSelector>
        <acceptor>
          <entityTabuSize>${entityTabuSize}</entityTabuSize>
        </acceptor>
        <forager>
          <acceptedCountLimit>${acceptedCountLimit}</acceptedCountLimit>
        </forager>
      </localSearch>
    </solver>
  </solverBenchmark>
</#list>
</#list>
</plannerBenchmark>

好像有问题

<#list [5,13] as entityTabuSize>

optaPlanner 版本是 7.43.0 xstream 版本为 1.4.14

有sonme错误信息

Caused by: com.thoughtworks.xstream.converters.ConversionException: 
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.io.StreamException
cause-message       : 
class               : org.optaplanner.benchmark.config.PlannerBenchmarkConfig
required-type       : org.optaplanner.benchmark.config.PlannerBenchmarkConfig
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
line number         : 40
version             : 1.4.14
-------------------------------
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:77)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1404)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1383)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1268)
    at org.optaplanner.benchmark.config.PlannerBenchmarkConfig.createFromXmlReader(PlannerBenchmarkConfig.java:228)
    at org.optaplanner.benchmark.config.PlannerBenchmarkConfig.createFromXmlInputStream(PlannerBenchmarkConfig.java:204)
    at org.optaplanner.benchmark.config.PlannerBenchmarkConfig.createFromXmlResource(PlannerBenchmarkConfig.java:140)
    ... 21 more
Caused by: com.thoughtworks.xstream.io.StreamException: 
    at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:124)
    at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148)
    at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:135)
    at com.thoughtworks.xstream.io.xml.AbstractPullReader.hasMoreChildren(AbstractPullReader.java:87)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:329)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    ... 32 more
Caused by: org.xmlpull.v1.XmlPullParserException: unexpected character in markup # (position: END_TAG seen ...</inheritedSolverBenchmark>\r\n\r\n\r\n<#... @40:3) 
    at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1261)
    at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
    at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:109)
    ... 38 more

解决方法

根据stacktrace,您使用的是PlannerBenchmarkConfig.createFromXmlResource(),可用于读取基准配置XML,但不能读取FreeMarker 模板。 要读取基准配置 FreeMarker 模板,请使用 PlannerBenchmarkConfig.createFromFreemarkerXmlResource() 方法之一。 有关详情,请参阅 Template-based benchmarking

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。