Timefold benchmark can't find benchmark.xml

64 views Asked by At

I'm trying to use the Timefold benchmark tools by following along in the user guide. I'm using Timefold 1.3.0 with Java 17 on Windows 11.

I have a simple project that starts like this:

public class TimefoldBenchmark {

    public static void main(String[] args) throws IOException {
        PlannerBenchmarkFactory benchmarkFactory = PlannerBenchmarkFactory.createFromXmlResource("benchmarkConfig.xml");

When I run, I immediately get this exception on the PlannerBenchmarkFactory line:

Exception in thread "main" java.lang.IllegalArgumentException: The XML schema (/benchmark.xsd) does not exist.
Maybe build the sources with Maven first?
    at [email protected]/ai.timefold.solver.core.impl.io.jaxb.GenericJaxbIO.readSchemaResource(GenericJaxbIO.java:112)
    at [email protected]/ai.timefold.solver.core.impl.io.jaxb.GenericJaxbIO.validate(GenericJaxbIO.java:248)
    at [email protected]/ai.timefold.solver.benchmark.impl.io.PlannerBenchmarkConfigIO.read(PlannerBenchmarkConfigIO.java:24)
    at [email protected]/ai.timefold.solver.benchmark.config.PlannerBenchmarkConfig.createFromXmlReader(PlannerBenchmarkConfig.java:210)
    at [email protected]/ai.timefold.solver.benchmark.config.PlannerBenchmarkConfig.createFromXmlInputStream(PlannerBenchmarkConfig.java:186)
    at [email protected]/ai.timefold.solver.benchmark.config.PlannerBenchmarkConfig.createFromXmlResource(PlannerBenchmarkConfig.java:127)
    at [email protected]/ai.timefold.solver.benchmark.config.PlannerBenchmarkConfig.createFromXmlResource(PlannerBenchmarkConfig.java:102)
    at [email protected]/ai.timefold.solver.benchmark.api.PlannerBenchmarkFactory.createFromXmlResource(PlannerBenchmarkFactory.java:102)
    at com.soartech.peirce.eval/com.soartech.peirce.eval.TimefoldBenchmark.main(TimefoldBenchmark.java:28)

My benchmark file looks like just the blueprint example in the user guide, except I'm making the problems programmatically (but it never gets to that part of the code).

I looked in timefold-solver-benchmark-1.3.0.jar and benchmark.xsd in indeed there in the root of the jar. What am I doing wrong?

1

There are 1 answers

1
Cromm On

As indicated in the method to load the benchmark configuration, createFromXmlResource, your benchmark.xml file should be in the resource folder.