ANRGenstar / genstar

Generation of Synthetic Populations Library
20 stars 2 forks source link

Problem with population generation (reading the Configuration file ?) #7

Closed ptaillandier closed 7 years ago

ptaillandier commented 7 years ago

Hi,

The testLocation main (sell/example/TestLocation.java) does not work anymore. The problem comes from the population generation. The problem seems to come from the reading of the configuration file.

Log: Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: Failed calling method ---- Debugging information ---- message : Failed calling method cause-exception : java.lang.NullPointerException cause-message : null method : core.io.configuration.GosplConfigurationFile.readResolve() class : core.io.configuration.GosplConfigurationFile required-type : core.io.configuration.GosplConfigurationFile converter-type : com.thoughtworks.xstream.converters.reflection.ReflectionConverter path : /GosplConfiguration version : 1.4.9

at com.thoughtworks.xstream.core.util.SerializationMembers.callReadResolve(SerializationMembers.java:82)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:282)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
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:1230)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1214)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1178)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1120)
at core.io.configuration.GosplXmlSerializer.deserializeGSConfig(GosplXmlSerializer.java:104)
at core.io.configuration.GosplXmlSerializer.deserializeGSConfig(GosplXmlSerializer.java:116)
at gospl.distribution.GosplDistributionFactory.<init>(GosplDistributionFactory.java:63)
at spll.example.TestLocalisation.generatePopulation(TestLocalisation.java:260)
at spll.example.TestLocalisation.main(TestLocalisation.java:105)

Caused by: java.lang.NullPointerException at java.util.HashMap.putMapEntries(HashMap.java:500) at java.util.HashMap.putAll(HashMap.java:784) at core.io.configuration.GosplConfigurationFile.(GosplConfigurationFile.java:42) at core.io.configuration.GosplConfigurationFile.readResolve(GosplConfigurationFile.java:66) 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:497) at com.thoughtworks.xstream.core.util.SerializationMembers.callReadResolve(SerializationMembers.java:78) ... 16 more

chapuisk commented 7 years ago

Population generation is ok. But still have problem creating shape file in TestLocation.

Exception in thread "main" java.lang.NullPointerException at java.util.HashMap.merge(HashMap.java:1216) at java.util.stream.Collectors.lambda$toMap$173(Collectors.java:1320) at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) at core.io.geo.GeofileFactory.createShapeFile(GeofileFactory.java:239) at core.io.GSExportFactory.createShapeFile(GSExportFactory.java:72) at spll.example.TestLocalisation.main(TestLocalisation.java:243)

chapuisk commented 7 years ago

In order to fix bug, you have to upload the new sample folder or generate a new configuration file, using the one in gospl

ptaillandier commented 7 years ago

fixed (now, it is possible to save a population into a shapefile even if some entities do not have a location)

samthiriot commented 7 years ago

Had this bug as well. In last commit I added something on the constructor of the GoSplConfigurationFile to never have null. Was making my tests functional again, hope it makes sense ? this.keyAttribute.putAll(keyAttribute == null ? Collections.emptyMap(): keyAttribute);