Hi guys,
While using the EpochX framework for a project, I uncovered a very delicate bug that can have a very disastrous effect on the outcome of the program. The bug is in the StatsUtils.median function, which unintentionally sorts the array. In other methods having similar functionality, the arrays are generally cloned before they are adjusted, and I think the median function should also do this.
The effect of this bug can really propagate throughout the program. For example in the following piece of pseudocode:
on generation end:
1. get median fitness of programs
2. get best program of generation
In step 1, the array with fitnesses gets sorted and cached as a statistic for that generation. In step 2, getting the best program assumes that the array of fitnesses is ordered in the same way as the array of programs, such that the index for the lowest fitness corresponds to the index for the best program. However, because the fitness array is sorted, they have a different ordering, and the returned program could be any program.
The fix is to clone an array before sorting it.
Are you willing to release an update containing this fix, or should I create a custom version for my project?
Thanks in advance!
Kind regards,
Sjors