-
Enhancement
-
Resolution: Done
-
Minor
-
None
Old title: Benchmark doesn't work with Joda datetime API
My problem's domain uses Joda's DateTime and Duration classes. After starting a benchmark I'm getting an exception. See below:
Code running the benchmark:
XmlPlannerBenchmarkFactory plannerBenchmarkFactory = new XmlPlannerBenchmarkFactory();
plannerBenchmarkFactory.configure("/pl/mskiba/dancingCobra/domain/BenchmarkConfig.xml");
PlannerBenchmark plannerBenchmark = plannerBenchmarkFactory.buildPlannerBenchmark();
plannerBenchmark.benchmark();
BenchmarkConfig.xml:
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>/home/marcin/benchmark</benchmarkDirectory>
<warmUpSecondsSpend>30</warmUpSecondsSpend><inheritedSolverBenchmark>
<problemBenchmarks>
<xstreamAnnotatedClass>pl.mskiba.dancingCobra.domain.Schedule</xstreamAnnotatedClass>
<inputSolutionFile>/home/marcin/workspace/DancingCobra/src/main/resources/pl/mskiba/dancingCobra/domain/testProblems/Problem.xml</inputSolutionFile>
<problemStatisticType>BEST_SOLUTION_CHANGED</problemStatisticType>
</problemBenchmarks>
<solver>
<solutionClass>pl.mskiba.dancingCobra.domain.Schedule</solutionClass>
<planningEntityClass>pl.mskiba.dancingCobra.domain.TaskAssignment</planningEntityClass>
<scoreDirectorFactory>
<scoreDefinitionType>HARD_AND_SOFT</scoreDefinitionType>
<scoreDrl>/pl/mskiba/dancingCobra/domain/score/scoreRules.drl</scoreDrl>
</scoreDirectorFactory>
<termination>
<scoreAttained>0hard/0soft</scoreAttained>
<maximumHoursSpend>1</maximumHoursSpend>
</termination>
</solver>
</inheritedSolverBenchmark><solverBenchmark>
<name>First Benchmark</name>
<solver>
<localSearch>
<selector>
<selector>
<moveFactoryClass>pl.mskiba.dancingCobra.domain.move.AssignedMoveFactory</moveFactoryClass>
</selector>
<selector>
<moveFactoryClass>pl.mskiba.dancingCobra.domain.move.UnassignedMoveFactory</moveFactoryClass>
</selector>
</selector>
<acceptor>
<undoMoveTabuSize>5</undoMoveTabuSize>
<moveTabuSize>5</moveTabuSize>
</acceptor>
<forager>
<minimalAcceptedSelection>1000</minimalAcceptedSelection>
<pickEarlyType>FIRST_BEST_SCORE_IMPROVING</pickEarlyType>
</forager>
</localSearch>
</solver>
</solverBenchmark></plannerBenchmark>
After running this code I'm getting:
0 [main] INFO org.drools.planner.benchmark.core.DefaultPlannerBenchmark - Benchmarking started: solverBenchmarkList size (1).
1 [main] INFO org.drools.planner.benchmark.core.DefaultPlannerBenchmark - ================================================================================
1 [main] INFO org.drools.planner.benchmark.core.DefaultPlannerBenchmark - Warming up
1 [main] INFO org.drools.planner.benchmark.core.DefaultPlannerBenchmark - ================================================================================
And an Exception:
java.lang.IllegalArgumentException: Problem reading inputSolutionFile: /home/marcin/workspace/DancingCobra/src/main/resources/pl/mskiba/dancingCobra/domain/testProblems/Problem.xml
at org.drools.planner.benchmark.core.XStreamProblemIO.read(XStreamProblemIO.java:64)
at org.drools.planner.benchmark.core.ProblemBenchmark.readPlanningProblem(ProblemBenchmark.java:161)
at org.drools.planner.benchmark.core.ProblemBenchmark.warmUp(ProblemBenchmark.java:147)
at org.drools.planner.benchmark.core.DefaultPlannerBenchmark.warmUp(DefaultPlannerBenchmark.java:191)
at org.drools.planner.benchmark.core.DefaultPlannerBenchmark.benchmark(DefaultPlannerBenchmark.java:131)
at pl.mskiba.dancingCobra.scheduleTest.BenchmarkTest.test(BenchmarkTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.thoughtworks.xstream.converters.ConversionException: Cannot create org.joda.time.chrono.ISOChronology$Stub by JDK serialization : null : Cannot create org.joda.time.chrono.ISOChronology$Stub by JDK serialization : null
---- Debugging information ----
message : Cannot create org.joda.time.chrono.ISOChronology$Stub by JDK serialization : null
cause-exception : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
cause-message : Cannot create org.joda.time.chrono.ISOChronology$Stub by JDK serialization : null
class : org.joda.time.chrono.ISOChronology$Stub
required-type : org.joda.time.chrono.ISOChronology$Stub
converter-type : com.thoughtworks.xstream.converters.reflection.SerializableConverter
line number : 13
class[1] : org.joda.time.DateTime
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : pl.mskiba.dancingCobra.domain.utils.TimePeriod
class[3] : java.util.ArrayList
converter-type[2] : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[4] : pl.mskiba.dancingCobra.domain.Worker
class[5] : pl.mskiba.dancingCobra.domain.Schedule
version : null
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
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:355)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:306)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
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:355)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:306)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
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.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:79)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:72)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:66)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:61)
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:355)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:306)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
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.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:79)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:72)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:66)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:61)
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:355)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:306)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
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:1058)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1042)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:913)
at org.drools.planner.benchmark.core.XStreamProblemIO.read(XStreamProblemIO.java:62)
... 28 more
Caused by: com.thoughtworks.xstream.converters.reflection.ObjectAccessException: Cannot create org.joda.time.chrono.ISOChronology$Stub by JDK serialization : null
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.instantiateUsingSerialization(PureJavaReflectionProvider.java:119)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.newInstance(PureJavaReflectionProvider.java:69)
at com.thoughtworks.xstream.converters.reflection.ReflectionProviderWrapper.newInstance(ReflectionProviderWrapper.java:42)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.instantiateNewInstance(AbstractReflectionConverter.java:426)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:233)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
... 79 more
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2553)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at org.joda.time.chrono.ISOChronology$Stub.readObject(ISOChronology.java:231)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:969)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.instantiateUsingSerialization(PureJavaReflectionProvider.java:116)
... 84 more
I can see that there is a problem with org.joda.time.chrono.ISOChronology.
In addition - if I run the following code:
XStream xStream = new XStream();
Schedule problem = (Schedule) xStream.fromXML(new FileReader("/home/marcin/workspace/DancingCobra/src/main/resources/pl/mskiba/dancingCobra/domain/testProblems/Problem.xml"));
SolverFactory solverFactory = new XmlSolverFactory("/pl/mskiba/dancingCobra/domain/scheduleSolverConfig.xml");
Solver solver = solverFactory.buildSolver();
solver.setPlanningProblem(problem);
solver.solve();
Everything works fine! Same problem, same XML file, same configuration, but with Drools Benchmarker it simply doesn't work.