From 7a54a44b01f1b4ac5b39dc5d7a9d4e62d066982b Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sat, 10 May 2014 10:30:20 +0100 Subject: Fixed digital problem with more than one test case, improved mu+lambda to be more like CGP --- src/jcgp/backend/modules/problem/DigitalCircuitProblem.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/jcgp/backend/modules/problem') 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 { 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); } -- cgit v1.2.3