diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-13 10:41:25 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-13 10:41:25 +0100 |
commit | e7d7e8506a511d78f9e323ac09587f79ad503f42 (patch) | |
tree | 8d87a718af29470b5bb8e5dfeb0ce18865f185cb /src/jcgp/backend/modules/problem | |
parent | dbae5ce2e0765f229e11b692a2aba570286980f4 (diff) |
Performance suddenly decreased, looking into why
Diffstat (limited to 'src/jcgp/backend/modules/problem')
-rw-r--r-- | src/jcgp/backend/modules/problem/TestCaseProblem.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/jcgp/backend/modules/problem/TestCaseProblem.java b/src/jcgp/backend/modules/problem/TestCaseProblem.java index 68318cf..ee72860 100644 --- a/src/jcgp/backend/modules/problem/TestCaseProblem.java +++ b/src/jcgp/backend/modules/problem/TestCaseProblem.java @@ -52,8 +52,6 @@ public abstract class TestCaseProblem<U extends Object> extends Problem { private IntegerParameter maxFitness; private final int inputCount, outputCount; - private U type; - public TestCaseProblem(Resources resources) { super(); @@ -67,12 +65,14 @@ public abstract class TestCaseProblem<U extends Object> extends Problem { } }; testCases = FXCollections.observableArrayList(); - //testCases = new ObservableList<TestCase<U>>(); } @Override public void evaluate(Population population, Resources resources) { + // set fittest to 0, change it whenever a fitter one is found + population.setFittest(0); + // for every chromosome in the population for (int i = 0; i < resources.populationSize(); i++) { // assume an initial fitness of 0 @@ -89,6 +89,9 @@ public abstract class TestCaseProblem<U extends Object> extends Problem { } // assign the resulting fitness to the respective individual population.getChromosome(i).setFitness(fitness); + if (fitness >= population.getFittest().getFitness()) { + population.setFittest(i); + } } } @@ -147,10 +150,6 @@ public abstract class TestCaseProblem<U extends Object> extends Problem { public int getOutputCount() { return outputCount; } - - public Class<?> getType() { - return type.getClass(); - } } |