如何运行/实施optaplanner的Benchmark?

时间:2016-07-01 19:19:12

标签: java benchmarking optaplanner

我需要协助使用OptaPlanner进行基准测试。我遇到了两个问题。第一个是通过对提供的示例进行基准测试的结果。我看到车辆路由示例有两个应用程序。其中之一是“VehicleRoutingBenchmarkApp”。我运行这个应用程序,并认为index.html将生成,但它不是。所以我不清楚如何做到这一点。

第二个问题是实施。我只是在试验,所以我按照VehicleRoutingApp main()中的文档指示添加了代码片段,以便我可以看到会发生什么。

文档链接:https://docs.jboss.org/drools/release/6.0.0.CR3/optaplanner-docs/html/benchmarkingAndTweaking.html

System.out.println("-------------- benchmark stuff --------------");
        PlannerBenchmarkFactory plannerBenchmarkFactory = PlannerBenchmarkFactory.createFromXmlResource(
                "org/optaplanner/examples/vehiclerouting/benchmark/vehicleRoutingBenchmarkConfig.xml");
        PlannerBenchmark plannerBenchmark = plannerBenchmarkFactory.buildPlannerBenchmark();
        plannerBenchmark.benchmark();

这样的结果是输出日志的恒定流。很难理解它的传达方式。我如何将所有这些翻译成一个漂亮的GUI,因为我认为index.html是假设的?提前谢谢。

我得到的tracestack如下:

Exception in thread "main" java.lang.IllegalStateException: The directory dataDir (C:\Intellij\Workspace\optaplanner-developer\data\vehiclerouting) does not exist.
 Either the working directory should be set to the directory that contains the data directory (which is not the data directory itself), or the system property org.optaplanner.examples.dataDir should be set properly.
 The data directory is different in a git clone (optaplanner/optaplanner-examples/data) and in a release zip (examples/sources/data).
 In an IDE (IntelliJ, Eclipse, NetBeans), open the "Run configuration" to change "Working directory" (or add the system property in "VM options").
    at org.optaplanner.examples.common.persistence.AbstractSolutionDao.<init>(AbstractSolutionDao.java:46)
    at org.optaplanner.examples.common.persistence.XStreamSolutionDao.<init>(XStreamSolutionDao.java:32)
    at org.optaplanner.examples.vehiclerouting.persistence.VehicleRoutingDao.<init>(VehicleRoutingDao.java:25)
    at org.optaplanner.examples.vehiclerouting.persistence.VehicleRoutingImporter.<init>(VehicleRoutingImporter.java:57)
    at org.optaplanner.examples.vehiclerouting.persistence.VehicleRoutingFileIO.<init>(VehicleRoutingFileIO.java:28)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.optaplanner.core.config.util.ConfigUtils.newInstance(ConfigUtils.java:46)
    at org.optaplanner.benchmark.config.ProblemBenchmarksConfig.buildSolutionFileIO(ProblemBenchmarksConfig.java:149)
    at org.optaplanner.benchmark.config.ProblemBenchmarksConfig.buildProblemBenchmarkList(ProblemBenchmarksConfig.java:111)
    at org.optaplanner.benchmark.config.SolverBenchmarkConfig.buildSolverBenchmark(SolverBenchmarkConfig.java:88)
    at org.optaplanner.benchmark.config.PlannerBenchmarkConfig.buildPlannerBenchmark(PlannerBenchmarkConfig.java:210)
    at org.optaplanner.benchmark.impl.XStreamXmlPlannerBenchmarkFactory.buildPlannerBenchmark(XStreamXmlPlannerBenchmarkFactory.java:156)
    at org.optaplanner.examples.common.app.CommonBenchmarkApp.buildAndBenchmark(CommonBenchmarkApp.java:68)
    at org.optaplanner.examples.vehiclerouting.app.VehicleRoutingBenchmarkApp.main(VehicleRoutingBenchmarkApp.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

1 个答案:

答案 0 :(得分:1)

对于那些试图学习optaplanner并且有相同问题的人来说,解决方案在你引用的benchmarkConfig.xml文件中。您应该创建一个具有根<ol> <li> list point <ol> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> </ol> </li> <li> list point <ol> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> </ol> </li> <li> list point <ol> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> </ol> </li> <li> list point <ol> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> <li> list point <ol> <li>list point</li> <li>list point</li> </ol> </li> </ol> </li> </ol>标记的xml。在此内部,您可以添加另一个名为<plannerBenchmark>的标记。您可以在此处指定生成报告的位置。请务必将<benchmarkDiretory>设置为指向正确的数据集,可以是.xml或.vrp。其余的就像魔术​​一样。

应该看起来类似于以下内容:

<inputSolutionFile>