Closed konical closed 10 years ago
In org.encog.ml.genetic.mutate.MutatePerturb.performOperation():
As written this line will not work for small values. value += (perturbAmount - (rnd.nextDouble() * perturbAmount * 2));
It should be changed to: value += value * (perturbAmount - (rnd.nextDouble() * perturbAmount * 2));
Examples: using perturbAmount = 0.2 and random perturbation = ( (perturbAmount - (rnd.nextDouble() * perturbAmount * 2)) ) = -0.1424
using encog calculation - value = 15, perturbation % = -0.842%, new value = 14.87 value = 0.001, perturbation % = -8771%, new value = -0.086713711
VALUE FOR SMALL NUMBER IS PERTURBED BY ~9000% !
using changed code: value = 15, perturbation % = -14.24%, new value = 12.86 value = 0.001, perturbation % =-14.24%, new value = 0.000857636
Value for small number is perturbed by the requested amount.
Thanks good point. I will add this soon.
Thank you good fix. I have this in the code now.
In org.encog.ml.genetic.mutate.MutatePerturb.performOperation():
As written this line will not work for small values. value += (perturbAmount - (rnd.nextDouble() * perturbAmount * 2));
It should be changed to: value += value * (perturbAmount - (rnd.nextDouble() * perturbAmount * 2));
Examples: using perturbAmount = 0.2 and random perturbation = ( (perturbAmount - (rnd.nextDouble() * perturbAmount * 2)) ) = -0.1424
using encog calculation - value = 15, perturbation % = -0.842%, new value = 14.87 value = 0.001, perturbation % = -8771%, new value = -0.086713711
VALUE FOR SMALL NUMBER IS PERTURBED BY ~9000% !
using changed code: value = 15, perturbation % = -14.24%, new value = 12.86 value = 0.001, perturbation % =-14.24%, new value = 0.000857636
Value for small number is perturbed by the requested amount.