aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-05-11 10:19:55 +0100
committerEduardo Pedroni <ep625@york.ac.uk>2014-05-11 10:19:55 +0100
commitf0956d0c343187122a8c35939261528658948633 (patch)
treefbc7c394cd7c812dace091e71f3ebe796ecb8e70
parent7a54a44b01f1b4ac5b39dc5d7a9d4e62d066982b (diff)
Percent point mutator had a bug, fixed now
-rw-r--r--src/jcgp/backend/modules/mutator/PercentPointMutator.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/jcgp/backend/modules/mutator/PercentPointMutator.java b/src/jcgp/backend/modules/mutator/PercentPointMutator.java
index 015edf4..ed36f30 100644
--- a/src/jcgp/backend/modules/mutator/PercentPointMutator.java
+++ b/src/jcgp/backend/modules/mutator/PercentPointMutator.java
@@ -33,7 +33,11 @@ public class PercentPointMutator extends PointMutator {
mutationRate = new DoubleParameter(10, "Percent mutation", false, false) {
@Override
public void validate(Number newValue) {
- genesMutated.set((int) ((newValue.intValue()) * (((((double) resources.nodes() + resources.outputs()))) / 100)));
+
+ int totalGenes = (resources.nodes() * (resources.arity() + 1)) + resources.outputs();
+ int mutations = (int) (newValue.doubleValue() * (double) (totalGenes / 100.0));
+ genesMutated.set(mutations);
+
if (newValue.doubleValue() <= 0 || newValue.doubleValue() > 100) {
status = ParameterStatus.INVALID;
status.setDetails("Mutation rate must be > 0 and <= 100");