Weighted Sum Optimisation Value and Roulette Wheel + Stochastic Universal selector
Summary
When attempting to use weighted sum comparator with roulette wheel and/or stochastic universal selector, an error is thrown because WeightedSumOptimisationValue cannot be cast to Number.
Component
optimisation.api
Steps to reproduce
Attempt to run evolutionary algorithm search configuration with weighted-sum comparator and roulette-wheel selector, for example
Current Behaviour
ClassCast Exception
Expected Behavior
No exception, this should be possible
Relevant logs and/or screenshots
11:56:21.556 [main] ERROR d.e.c.m.Evoal - Main class threw an exception.
java.util.concurrent.CompletionException: java.lang.ClassCastException: class de.evoal.optimisation.main.comparator.WeightedSumOptimisationValue cannot be cast to class java.lang.Number (de.evoal.optimisation.main.comparator.WeightedSumOptimisationValue is in module de.evoal.optimisation.api@2024.10.0-rc1.999999 of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.ClassCastException: class de.evoal.optimisation.main.comparator.WeightedSumOptimisationValue cannot be cast to class java.lang.Number (de.evoal.optimisation.main.comparator.WeightedSumOptimisationValue is in module de.evoal.optimisation.api@2024.10.0-rc1.999999 of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
at io.jenetics.base/io.jenetics.RouletteWheelSelector.fitnessOf(RouletteWheelSelector.java:85)
...
Possible fixes
Change WeightedSumOptimisationValue class to extend Number. Proposed fix in associated branch.
Contact Person
/cc @berber