diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-21 00:09:55 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-21 00:09:55 +0100 |
commit | efe490fec1c7a94f004b496c7c97c82083fe44ec (patch) | |
tree | ffe7a8bb411a9208c3220247247081eb90ac4fc0 /src/jcgp/backend/modules/mutator | |
parent | 88314e71f908efcfc38da3b800319c171a6ccceb (diff) |
Tooltips are looking strange, checking on a different machine
Diffstat (limited to 'src/jcgp/backend/modules/mutator')
-rw-r--r-- | src/jcgp/backend/modules/mutator/PointMutator.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/jcgp/backend/modules/mutator/PointMutator.java b/src/jcgp/backend/modules/mutator/PointMutator.java index ab8efad..44c453a 100644 --- a/src/jcgp/backend/modules/mutator/PointMutator.java +++ b/src/jcgp/backend/modules/mutator/PointMutator.java @@ -7,18 +7,21 @@ import jcgp.backend.population.Output; import jcgp.backend.resources.Resources; import jcgp.backend.resources.parameters.BooleanParameter; import jcgp.backend.resources.parameters.DoubleParameter; +import jcgp.backend.resources.parameters.IntegerParameter; import jcgp.backend.resources.parameters.Parameter; import jcgp.backend.resources.parameters.ParameterStatus; public class PointMutator implements Mutator { private DoubleParameter mutationRate; + private IntegerParameter nodesMutated; private BooleanParameter report; public PointMutator(final Resources resources) { mutationRate = new DoubleParameter(50, "Percent mutation", false, false) { @Override public void validate(Number newValue) { + nodesMutated.set((int) ((newValue.intValue()) * (((((double) resources.nodes() + resources.outputs()))) / 100))); if (newValue.doubleValue() <= 0 || newValue.doubleValue() > 100) { status = ParameterStatus.INVALID; status.setDetails("Mutation rate must be > 0 and <= 100"); @@ -30,7 +33,12 @@ public class PointMutator implements Mutator { } } }; - + nodesMutated = new IntegerParameter(0, "Genes mutated", true, false) { + @Override + public void validate(Number newValue) { + // blank + } + }; report = new BooleanParameter(false, "Report") { @Override public void validate(Boolean newValue) { @@ -41,9 +49,8 @@ public class PointMutator implements Mutator { @Override public void mutate(Chromosome chromosome, Resources resources) { - int mutations = (int) ((mutationRate.get()) * (((((double) resources.nodes() + resources.outputs()))) / 100)); - if (report.get()) resources.reportln("[Mutator] Number of mutations to be performed: " + mutations); - for (int i = 0; i < mutations; i++) { + if (report.get()) resources.reportln("[Mutator] Number of mutations to be performed: " + nodesMutated.get()); + for (int i = 0; i < nodesMutated.get(); i++) { MutableElement m = chromosome.getRandomMutableElement(); if (report.get()) resources.report("[Mutator] Mutation " + i + " selected " + m.toString() + ", "); @@ -75,7 +82,7 @@ public class PointMutator implements Mutator { @Override public Parameter<?>[] getLocalParameters() { - return new Parameter[] {mutationRate, report}; + return new Parameter[] {mutationRate, nodesMutated, report}; } @Override |