Skip to content

MutatePerturb.performOperation calculation is not correct #148

@konical

Description

@konical

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions