I'm trying to implement a benchmark configuration in my project, and whatever I do, I seem to encounter some sort of error. After a few reads from the Documentation I discovered that I need to implement a SolutionIO
interface to read the input and make it into a solution.
This is my configuration without the solver:
<benchmarkDirectory>local/data/nurserostering/folder</benchmarkDirectory> <inheritedSolverBenchmark> <problemBenchmarks> ----> <problemIOClass>org.optaplanner.examples.nurserostering.persistence.CustomBenchmarkIO</problemIOClass> <----- <inputSolutionFile>data/nurserostering/import/importTest/Input0.xml</inputSolutionFile> </problemBenchmarks>
The error I'm getting is at the <problemIOClass>
tag (see end of post).
This is my CustomBenchmarkIO(Custom SolutionIO):
package org.optaplanner.examples.nurserostering.persistence; import java.io.File; import org.optaplanner.core.api.domain.solution.Solution; public interface CustomProblemIOInterface { String getFileExtension(); Solution read(File inputSolutionFile); void write(Solution solution, File outputSolutionFile); }
And here I have a class that implements that interface:
package org.optaplanner.examples.nurserostering.persistence; import java.io.File; import org.optaplanner.core.api.domain.solution.Solution; import org.optaplanner.persistence.common.api.domain.solution.SolutionFileIO; public class CustomBenchmarkIOClass implements CustomProblemIOInterface{ public String getInputFileExtension() { return null; } public String getOutputFileExtension() { // TODO Auto-generated method stub return null; } public Solution read(File inputSolutionFile) { return null; } public void write(Object solution, File outputSolutionFile) { } }
I have tried using the class and the interface, but I still get the same error.
Here is the full error log:
Exception in thread "main" java.lang.IllegalArgumentException: Unmarshalling of benchmarkConfigResource (org/optaplanner/examples/nurserostering/benchmark/monetBenchmarkConfig.xml) fails. at org.optaplanner.benchmark.impl.XStreamXmlPlannerBenchmarkFactory.configure(XStreamXmlPlannerBenchmarkFactory.java:105) at org.optaplanner.benchmark.api.PlannerBenchmarkFactory.createFromXmlResource(PlannerBenchmarkFactory.java:46) at org.optaplanner.examples.common.app.CommonBenchmarkApp$ArgOption.buildPlannerBenchmarkFactory(CommonBenchmarkApp.java:105) at org.optaplanner.examples.common.app.CommonBenchmarkApp.buildAndBenchmark(CommonBenchmarkApp.java:66) at org.optaplanner.examples.nurserostering.app.NurseRosteringBenchmarkApp.main(NurseRosteringBenchmarkApp.java:24) Caused by: com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field org.optaplanner.benchmark.config.ProblemBenchmarksConfig.problemIOClass ---- Debugging information ---- field : problemIOClass class : org.optaplanner.benchmark.config.ProblemBenchmarksConfig required-type : org.optaplanner.benchmark.config.ProblemBenchmarksConfig converter-type : com.thoughtworks.xstream.converters.reflection.ReflectionConverter line number : 6 class[1] : org.optaplanner.benchmark.config.SolverBenchmarkConfig class[2] : org.optaplanner.benchmark.config.PlannerBenchmarkConfig version : 1.4.7 ------------------------------- at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.handleUnknownField(AbstractReflectionConverter.java:495) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:351) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:257) at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65) at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:474) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:406) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:257) at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65) at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:474) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:406) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:257) at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65) 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:1185) at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1169) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1040) at org.optaplanner.benchmark.impl.XStreamXmlPlannerBenchmarkFactory.configure(XStreamXmlPlannerBenchmarkFactory.java:133) at org.optaplanner.benchmark.impl.XStreamXmlPlannerBenchmarkFactory.configure(XStreamXmlPlannerBenchmarkFactory.java:123) at org.optaplanner.benchmark.impl.XStreamXmlPlannerBenchmarkFactory.configure(XStreamXmlPlannerBenchmarkFactory.java:103) ... 4 more
I'm posting this question because I don't know what I haven't tried, as I don't know all the possible ways of implementing a benchmark.