aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-05-11 14:37:16 +0100
committerEduardo Pedroni <ep625@york.ac.uk>2014-05-11 14:37:16 +0100
commit95b4a9421923cec63b6e0e8f58972d146100bd0f (patch)
tree77964472c043316903f43ae59c897f5d351b2b3a /src
parentb4baeeb0e8be030132b9fa79bc4628725a8ecec8 (diff)
parentf0956d0c343187122a8c35939261528658948633 (diff)
Merge branch 'gui' of https://bitbucket.org/epedroni/jcgp into gui
Diffstat (limited to 'src')
-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");