diff options
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(); - } } |