From f0956d0c343187122a8c35939261528658948633 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 11 May 2014 10:19:55 +0100 Subject: Percent point mutator had a bug, fixed now --- src/jcgp/backend/modules/mutator/PercentPointMutator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/jcgp/backend/modules/mutator') 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"); -- cgit v1.2.3