diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-07 00:01:25 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-07 00:01:25 +0100 |
commit | efee474689b37f43897b8572cec4e3669874b0d4 (patch) | |
tree | dfee6baee989cc2a751755240bad23a1ad09c7f5 /src/jcgp | |
parent | e6dd7711c7dad5e000445208eb5845801f4ccffc (diff) |
A few more changes made, functionsets are now selected by the fitness function as part of the problem setting
Diffstat (limited to 'src/jcgp')
-rw-r--r-- | src/jcgp/JCGP.java | 4 | ||||
-rw-r--r-- | src/jcgp/backend/modules/fitness/testcase/TestCaseEvaluator.java | 16 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/jcgp/JCGP.java b/src/jcgp/JCGP.java index 2c7023e..70b01a8 100644 --- a/src/jcgp/JCGP.java +++ b/src/jcgp/JCGP.java @@ -70,7 +70,9 @@ public class JCGP { mutator = mutators[0]; - fitnessFunction = fitnessFunctions[0]; + //fitnessFunction = fitnessFunctions[0]; + + //resources.setTestCases(new TestCase(new Integer[]{1, 2, 3}, new Integer[]{-4, 5, 6})); } diff --git a/src/jcgp/backend/modules/fitness/testcase/TestCaseEvaluator.java b/src/jcgp/backend/modules/fitness/testcase/TestCaseEvaluator.java index 51676e3..4b0654c 100644 --- a/src/jcgp/backend/modules/fitness/testcase/TestCaseEvaluator.java +++ b/src/jcgp/backend/modules/fitness/testcase/TestCaseEvaluator.java @@ -1,6 +1,7 @@ package jcgp.backend.modules.fitness.testcase; import java.util.ArrayList; +import java.util.Collections; import jcgp.backend.modules.fitness.FitnessFunction; import jcgp.backend.population.Population; @@ -45,7 +46,7 @@ public abstract class TestCaseEvaluator implements FitnessFunction { } } - protected ArrayList<TestCase> testCases; + protected ArrayList<TestCase<?>> testCases; @Override public void evaluate(Population population, Resources resources) { @@ -69,7 +70,18 @@ public abstract class TestCaseEvaluator implements FitnessFunction { } public int getMaxFitness() { - return 0; + int fitness = 0; + + for (TestCase<?> tc : testCases) { + fitness += tc.getOutputs().length; + } + + return fitness; + } + + public void setTestCases(TestCase<?>... testCases) { + this.testCases = new ArrayList<TestCase<?>>(); + Collections.addAll(this.testCases, testCases); } } |