aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/modules/mutator
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/backend/modules/mutator')
-rw-r--r--src/jcgp/backend/modules/mutator/PointMutator.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/jcgp/backend/modules/mutator/PointMutator.java b/src/jcgp/backend/modules/mutator/PointMutator.java
index 1f38cfe..ab8efad 100644
--- a/src/jcgp/backend/modules/mutator/PointMutator.java
+++ b/src/jcgp/backend/modules/mutator/PointMutator.java
@@ -18,11 +18,11 @@ public class PointMutator implements Mutator {
public PointMutator(final Resources resources) {
mutationRate = new DoubleParameter(50, "Percent mutation", false, false) {
@Override
- public void validate(double newValue) {
- if (newValue <= 0 || newValue > 100) {
+ public void validate(Number newValue) {
+ if (newValue.doubleValue() <= 0 || newValue.doubleValue() > 100) {
status = ParameterStatus.INVALID;
status.setDetails("Mutation rate must be > 0 and <= 100");
- } else if ((int) ((newValue / 100) * resources.getDouble("nodes")) <= 0) {
+ } else if ((int) ((newValue.doubleValue() / 100) * (double) resources.nodes()) <= 0) {
status = ParameterStatus.WARNING;
status.setDetails("With mutation rate " + mutationRate.get() + ", 0 genes will be mutated.");
} else {
@@ -33,7 +33,7 @@ public class PointMutator implements Mutator {
report = new BooleanParameter(false, "Report") {
@Override
- public void validate(boolean newValue) {
+ public void validate(Boolean newValue) {
// blank
}
};
@@ -41,7 +41,7 @@ public class PointMutator implements Mutator {
@Override
public void mutate(Chromosome chromosome, Resources resources) {
- int mutations = (int) ((mutationRate.get()) * ((((resources.getDouble("nodes")) + (resources.getDouble("outputs")))) / 100));
+ 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++) {
MutableElement m = chromosome.getRandomMutableElement();
@@ -54,7 +54,7 @@ public class PointMutator implements Mutator {
if (report.get()) resources.reportln("to " + ((Output) m).getSource().toString());
} else if (m instanceof Node) {
- int geneType = resources.getRandomInt(1 + resources.getInt("arity"));
+ int geneType = resources.getRandomInt(1 + resources.arity());
if (geneType < 1) {
if (report.get()) resources.report("changed function from " + ((Node) m).getFunction().getName() + " ");
@@ -62,7 +62,7 @@ public class PointMutator implements Mutator {
if (report.get()) resources.reportln("to " + ((Node) m).getFunction().getName());
} else {
- int connection = resources.getRandomInt(resources.getInt("arity"));
+ int connection = resources.getRandomInt(resources.arity());
if (report.get()) resources.report("changed connection " + connection + " from " + ((Node) m).getConnection(connection) + " ");
m.setConnection(connection, chromosome.getRandomConnection(((Node) m).getColumn()));
@@ -74,7 +74,7 @@ public class PointMutator implements Mutator {
}
@Override
- public Parameter[] getLocalParameters() {
+ public Parameter<?>[] getLocalParameters() {
return new Parameter[] {mutationRate, report};
}