如何工作 run/implement optaplanner 的基准测试?

How to work run/implement Benchmark for optaplanner?

我需要有关使用 OptaPlanner 进行基准测试的帮助。我 运行 有两个问题。首先是查看对提供的示例进行基准测试的结果。我看到 vehiclerouting 示例有两个应用程序。其中之一是 VehicleRoutingBenchmarkApp。我 运行 这个应用程序并认为 index.html 会生成,但事实并非如此。所以我不清楚该怎么做。

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

Documentation link here.

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

这样做的结果是源源不断地输出日志。很难理解它所传达的内容。我如何才能像我认为 index.html 那样将所有 t运行 设置为漂亮的 GUI?提前致谢。

我得到的跟踪堆栈如下:

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)

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

应该类似于以下内容:

<plannerBenchmark>
    <benchmarkDirectory>local/data/report/vehiclerouting</benchmarkDirectory>
    .....
    <inputSolutionFile>data/vehiclerouting/unsolved/TestCase_1.xml</inputSolutionFile>
    .....
</plannerBenchmark>