aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/backend/modules')
-rw-r--r--src/jcgp/backend/modules/problem/DigitalCircuitProblem.java12
-rw-r--r--src/jcgp/backend/modules/problem/Problem.java2
-rw-r--r--src/jcgp/backend/modules/problem/SymbolicRegressionProblem.java4
-rw-r--r--src/jcgp/backend/modules/problem/TestCaseProblem.java16
4 files changed, 9 insertions, 25 deletions
diff --git a/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java b/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java
index e2f17c3..ff77a0d 100644
--- a/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java
+++ b/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java
@@ -31,9 +31,9 @@ public class DigitalCircuitProblem extends TestCaseProblem<UnsignedInteger> {
}
@Override
- public void evaluate(Population population, Resources resources) {
+ public void evaluate(Population population) {
// for every chromosome in the population
- for (int i = 0; i < resources.populationSize(); i++) {
+ for (int i = 0; i < getResources().populationSize(); i++) {
// assume an initial fitness of 0
int fitness = 0;
@@ -41,13 +41,13 @@ public class DigitalCircuitProblem extends TestCaseProblem<UnsignedInteger> {
for (int t = 0; t < testCases.size(); t++) {
population.get(i).setInputs((Object[]) testCases.get(t).getInputs());
// check each output
- for (int o = 0; o < resources.outputs(); o++) {
+ for (int o = 0; o < getResources().outputs(); o++) {
Integer output = ((UnsignedInteger) population.get(i).getOutput(o).calculate()).get();
- Integer matches = ~(output ^ testCases.get(t).getOutput(o).get());
+ Integer matches = ~(output ^ testCases.get(t).getOutputs()[o].get());
// check only the relevant bits
int bits;
- if (resources.inputs() < 5) {
- bits = (int) Math.pow(2.0, (double) resources.inputs());
+ if (getResources().inputs() < 5) {
+ bits = (int) Math.pow(2.0, (double) getResources().inputs());
} else {
bits = 32;
}
diff --git a/src/jcgp/backend/modules/problem/Problem.java b/src/jcgp/backend/modules/problem/Problem.java
index 2af2373..6785733 100644
--- a/src/jcgp/backend/modules/problem/Problem.java
+++ b/src/jcgp/backend/modules/problem/Problem.java
@@ -74,7 +74,7 @@ public abstract class Problem extends Module {
* @param population the population to be evaluated.
* @param resources parameters and utilities for optional reference.
*/
- public abstract void evaluate(Population population, Resources resources);
+ public abstract void evaluate(Population population);
/**
* Used to assert whether a given population contains a perfect solution
diff --git a/src/jcgp/backend/modules/problem/SymbolicRegressionProblem.java b/src/jcgp/backend/modules/problem/SymbolicRegressionProblem.java
index 3b5f539..6bc4790 100644
--- a/src/jcgp/backend/modules/problem/SymbolicRegressionProblem.java
+++ b/src/jcgp/backend/modules/problem/SymbolicRegressionProblem.java
@@ -84,7 +84,7 @@ public class SymbolicRegressionProblem extends TestCaseProblem<Double> {
}
@Override
- public void evaluate(Population population, Resources resources) {
+ public void evaluate(Population population) {
// for every chromosome in the population
for (int i = 0; i < getResources().populationSize(); i++) {
// assume an initial fitness of 0
@@ -95,7 +95,7 @@ public class SymbolicRegressionProblem extends TestCaseProblem<Double> {
// check each output
for (int o = 0; o < getResources().outputs(); o++) {
Double cgpValue = (Double) population.get(i).getOutput(o).calculate();
- Double dataValue = testCases.get(t).getOutput(o);
+ Double dataValue = testCases.get(t).getOutputs()[o];
if (hitsBasedFitness.get()) {
if (Math.abs(cgpValue - dataValue) <= errorThreshold.get()) {
fitness++;
diff --git a/src/jcgp/backend/modules/problem/TestCaseProblem.java b/src/jcgp/backend/modules/problem/TestCaseProblem.java
index 188e236..964860c 100644
--- a/src/jcgp/backend/modules/problem/TestCaseProblem.java
+++ b/src/jcgp/backend/modules/problem/TestCaseProblem.java
@@ -50,22 +50,6 @@ public abstract class TestCaseProblem<T> extends Problem {
}
/**
- * @param index the index to return.
- * @return the indexed input.
- */
- public U getInput(int index) {
- return inputs[index];
- }
-
- /**
- * @param index the index to return.
- * @return the indexed output.
- */
- public U getOutput(int index) {
- return outputs[index];
- }
-
- /**
* @return the complete array of inputs.
*/
public U[] getInputs() {