de.evoal.core.optimisation.random-population only supports double values
Summary
When using de.evoal.core.optimisation.random-population
for generating an initial population, EvoAl crashes as the population generator only generates double
values.
Component
evoal.core
de.evoal.core.optimisation.random-population
Steps to reproduce
Create a single property in the search space that is an integer and start a search
.
Current Behaviour
EvoAl crashes, e.g.:
java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Integer (java.lang.Double and java.lang.Integer are in module java.base of loader 'bootstrap')
at de.evoal.core.main@0.9.0-SNAPSHOT/de.evoal.core.api.properties.Properties.getAsInteger(Properties.java:66)
at de.evoal.core.ea@0.9.0-SNAPSHOT/de.evoal.core.ea.main.codec.vector.chromosome.DynamicIntegerChromosome.toJenetics(DynamicIntegerChromosome.java:34)
at de.evoal.core.ea@0.9.0-SNAPSHOT/de.evoal.core.ea.main.codec.vector.VectorGenotypeCodec.lambda$encode$2(VectorGenotypeCodec.java:79)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at de.evoal.core.ea@0.9.0-SNAPSHOT/de.evoal.core.ea.main.codec.vector.VectorGenotypeCodec.encode(VectorGenotypeCodec.java:80)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at weld.core.impl@3.1.9.Final/org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
at weld.core.impl@3.1.9.Final/org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106)
at de.evoal.core.ea@0.9.0-SNAPSHOT/de.evoal.core.ea.api.codec.CustomCodec$EvoalComponent$Codec$1669996192$Proxy$_$$_WeldClientProxy.encode(Unknown Source)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:200)
at java.base/java.util.stream.StreamSpliterators$InfiniteSupplyingSpliterator$OfRef.tryAdvance(StreamSpliterators.java:1358)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:292)
at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206)
at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:161)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:298)
at java.base/java.util.Spliterators$1Adapter.hasNext(Spliterators.java:681)
at java.base/java.lang.Iterable.forEach(Iterable.java:74)
at io.jenetics.base/io.jenetics.util.MSeq.of(MSeq.java:563)
at io.jenetics.base/io.jenetics.util.ISeq.of(ISeq.java:240)
at io.jenetics.base/io.jenetics.engine.EvolutionStreamable.stream(EvolutionStreamable.java:238)
at io.jenetics.base/io.jenetics.engine.EvolutionStreamable.stream(EvolutionStreamable.java:255)
at de.evoal.core.ea@0.9.0-SNAPSHOT/de.evoal.core.ea.main.initial.InitialStream.create(InitialStream.java:46)
at de.evoal.core.ea@0.9.0-SNAPSHOT/de.evoal.core.ea.main.search.EvolutionaryAlgorithmOptimisation.run(EvolutionaryAlgorithmOptimisation.java:113)
at de.evoal.core.main@0.9.0-SNAPSHOT/de.evoal.core.main.search.HeuristicSearchMain.run(HeuristicSearchMain.java:54)
at de.evoal.core.main@0.9.0-SNAPSHOT/de.evoal.core.main.search.HeuristicSearchMain$Proxy$_$$_WeldClientProxy.run(Unknown Source)
at de.evoal.core.main@0.9.0-SNAPSHOT/de.evoal.core.main.Evoal.main(Evoal.java:69)
Expected Behavior
No crash expected
Possible fixes
Check the data type of a property and generate either a double
or an integer
.
Contact Person
/cc @berber