aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/modules/problem
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-05-10 10:30:20 +0100
committerEduardo Pedroni <ep625@york.ac.uk>2014-05-10 10:30:20 +0100
commit7a54a44b01f1b4ac5b39dc5d7a9d4e62d066982b (patch)
tree6cc39a323ca981bea7b5094acb724db6fd38f1b6 /src/jcgp/backend/modules/problem
parent1e5e8b97a80e7ea50bcfafa4c2eee9c541f1b35f (diff)
Fixed digital problem with more than one test case, improved mu+lambda to be more like CGP
Diffstat (limited to 'src/jcgp/backend/modules/problem')
-rw-r--r--src/jcgp/backend/modules/problem/DigitalCircuitProblem.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java b/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java
index b615675..e2f17c3 100644
--- a/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java
+++ b/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java
@@ -45,13 +45,17 @@ public class DigitalCircuitProblem extends TestCaseProblem<UnsignedInteger> {
Integer output = ((UnsignedInteger) population.get(i).getOutput(o).calculate()).get();
Integer matches = ~(output ^ testCases.get(t).getOutput(o).get());
// check only the relevant bits
- int bits = (int) Math.pow(2.0, (double) resources.inputs());
+ int bits;
+ if (resources.inputs() < 5) {
+ bits = (int) Math.pow(2.0, (double) resources.inputs());
+ } else {
+ bits = 32;
+ }
for (int b = 0; b < bits; b++) {
fitness += (matches >>> b) & 1;
}
}
}
-
// assign the resulting fitness to the respective individual
population.get(i).setFitness(fitness);
}