optaplanner - optaplanner 矩阵基准测试失败原因:在行号 (40) 上对 benchmarkConfigResource 进行解组失败
问题描述
我之前成功地使用了没有基于模板的基准测试的基准,但是基于模板的基准测试在这里不能工作。我使用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, 7, 11, 13] as entityTabuSize>
optaPlanner 版本是 7.43.0 xstream 版本是 1.4.14
有一些错误信息
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
解决方案
根据堆栈跟踪,您使用的是PlannerBenchmarkConfig.createFromXmlResource()
,可用于读取基准配置 XML,但不能用于读取 FreeMarker 模板。要阅读基准配置 FreeMarker 模板,请使用其中一种PlannerBenchmarkConfig.createFromFreemarkerXmlResource()
方法。有关更多详细信息,请参阅基于模板的基准测试。
推荐阅读
- c# - 如何在 Python 中定义作为类实例的类字段?
- java - 为什么这段代码在多次重新计算深度时检查二叉树是否平衡需要时间 O(n log n)?
- python - 使用 Python (Linux/Windows) 的网络带宽 (Mbps) 和磁盘 I/O (MB/s)
- r - 如何根据数据框中相邻单元格的值汇总数据
- python - tf.reduce_mean 的数值稳定性
- javascript - 设置格式化值中断函数
- c# - 除了从用户输入派生的 ITurnContext RecognizeAsync 之外,为 LuisRecognizer 提供预定文本上下文的最佳方法是什么?
- c++ - 为什么glm不翻译顶点
- go - 在 Go 切片中追加时超出范围
- kotlin - 错误:Kotlin:浮点文字不符合预期的浮点类型