diff options
Diffstat (limited to 'src/jcgp/fitness')
-rw-r--r-- | src/jcgp/fitness/FitnessFunction.java | 9 | ||||
-rw-r--r-- | src/jcgp/fitness/TestCase.java | 42 | ||||
-rw-r--r-- | src/jcgp/fitness/TruthTableEvaluator.java | 30 |
3 files changed, 0 insertions, 81 deletions
diff --git a/src/jcgp/fitness/FitnessFunction.java b/src/jcgp/fitness/FitnessFunction.java deleted file mode 100644 index 6fa63ef..0000000 --- a/src/jcgp/fitness/FitnessFunction.java +++ /dev/null @@ -1,9 +0,0 @@ -package jcgp.fitness; - -import jcgp.population.Population; - -public interface FitnessFunction { - - public void evaluate(Population population); - -} diff --git a/src/jcgp/fitness/TestCase.java b/src/jcgp/fitness/TestCase.java deleted file mode 100644 index e506d38..0000000 --- a/src/jcgp/fitness/TestCase.java +++ /dev/null @@ -1,42 +0,0 @@ -package jcgp.fitness; - -import jcgp.Parameters; -import jcgp.exceptions.ParameterMismatchException; - -public class TestCase { - - private Object[] inputs; - private Object[] outputs; - - public TestCase(Object[] inputs, Object[] outputs) throws ParameterMismatchException { - if (inputs.length == Parameters.getInputs()) { - this.inputs = inputs; - } else { - throw new ParameterMismatchException(); - } - - if (outputs.length == Parameters.getOutputs()) { - this.outputs = outputs; - } else { - throw new ParameterMismatchException(); - } - - } - - public Object getInput(int index) { - return inputs[index]; - } - - public Object getOutput(int index) { - return outputs[index]; - } - - public Object[] getInputs() { - return inputs; - } - - public Object[] getOutputs() { - return outputs; - } - -} diff --git a/src/jcgp/fitness/TruthTableEvaluator.java b/src/jcgp/fitness/TruthTableEvaluator.java deleted file mode 100644 index 4adf435..0000000 --- a/src/jcgp/fitness/TruthTableEvaluator.java +++ /dev/null @@ -1,30 +0,0 @@ -package jcgp.fitness; - -import jcgp.Parameters; -import jcgp.TruthTable; -import jcgp.population.Population; - -public class TruthTableEvaluator implements FitnessFunction { - - @Override - public void evaluate(Population population) { - // for every chromosome in the population - for (int i = 0; i < Parameters.getPopulationSize(); i++) { - int fitness = 0; - // for every test case - for (int t = 0; t < TruthTable.getTestCaseCount(); t++) { - population.getChromosome(i).setInputs(TruthTable.getTestCase(t).getInputs()); - // check every output - for (int o = 0; o < Parameters.getOutputs(); o++) { - if (population.getChromosome(i).getOutput(o).calculate() == TruthTable.getTestCase(t).getOutput(o)) { - fitness++; - } - } - } - population.getChromosome(i).setFitness(fitness); - if (Parameters.getDebug()) { - System.out.println("active nodes: " + population.getChromosome(i).getActiveNodes().size()); - } - } - } -} |