aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/modules/problem
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/backend/modules/problem')
-rw-r--r--src/jcgp/backend/modules/problem/DigitalCircuitProblem.java4
-rw-r--r--src/jcgp/backend/modules/problem/TestCaseProblem.java43
2 files changed, 7 insertions, 40 deletions
diff --git a/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java b/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java
index e92989e..3c30e4c 100644
--- a/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java
+++ b/src/jcgp/backend/modules/problem/DigitalCircuitProblem.java
@@ -49,8 +49,8 @@ public class DigitalCircuitProblem extends TestCaseProblem<UnsignedInteger> {
}
@Override
- protected int getMaxFitness() {
- int maxFitness = (int) Math.pow(2.0, (double) resources.inputs()) * resources.outputs();
+ protected double getMaxFitness() {
+ double maxFitness = Math.pow(2.0, (double) resources.inputs()) * resources.outputs();
return maxFitness;
}
diff --git a/src/jcgp/backend/modules/problem/TestCaseProblem.java b/src/jcgp/backend/modules/problem/TestCaseProblem.java
index ff13c2e..d8dd32b 100644
--- a/src/jcgp/backend/modules/problem/TestCaseProblem.java
+++ b/src/jcgp/backend/modules/problem/TestCaseProblem.java
@@ -1,13 +1,11 @@
package jcgp.backend.modules.problem;
-import java.io.File;
import java.util.List;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-import jcgp.backend.parser.TestCaseParser;
import jcgp.backend.resources.Resources;
-import jcgp.backend.resources.parameters.IntegerParameter;
+import jcgp.backend.resources.parameters.DoubleParameter;
import jcgp.backend.resources.parameters.Parameter;
/**
@@ -49,43 +47,21 @@ public abstract class TestCaseProblem<U extends Object> extends Problem {
}
protected ObservableList<TestCase<U>> testCases;
- protected IntegerParameter maxFitness;
+ protected DoubleParameter maxFitness;
protected Resources resources;
- protected TestCaseParser parser;
-
public TestCaseProblem(Resources resources) {
super();
this.resources = resources;
- maxFitness = new IntegerParameter(0, "Max fitness", true, false) {
+ maxFitness = new DoubleParameter(0, "Max fitness", true, false) {
@Override
public void validate(Number newValue) {
// blank
}
};
testCases = FXCollections.observableArrayList();
-
- parser = new TestCaseParser(this);
- }
-
- public TestCaseProblem(Resources resources, File testCase) {
- super();
-
- this.resources = resources;
-
- maxFitness = new IntegerParameter(0, "Max fitness", true, false) {
- @Override
- public void validate(Number newValue) {
- // blank
- }
- };
- testCases = FXCollections.observableArrayList();
-
- parser = new TestCaseParser(this);
-
- parser.parse(testCase);
}
@Override
@@ -93,7 +69,7 @@ public abstract class TestCaseProblem<U extends Object> extends Problem {
return new Parameter[]{maxFitness};
}
- protected int getMaxFitness() {
+ protected double getMaxFitness() {
int fitness = 0;
for (TestCase<U> tc : testCases) {
@@ -115,7 +91,7 @@ public abstract class TestCaseProblem<U extends Object> extends Problem {
public abstract void addTestCase(String[] inputs, String[] outputs);
- public void addTestCase(TestCase<U> testCase) {
+ protected final void addTestCase(TestCase<U> testCase) {
if (testCase.getInputs().length != resources.inputs()) {
throw new IllegalArgumentException("Received test case with " + testCase.getInputs().length +
" inputs but need exactly " + resources.inputs());
@@ -128,11 +104,6 @@ public abstract class TestCaseProblem<U extends Object> extends Problem {
}
}
- public void removeTestCase(TestCase<U> testCase) {
- testCases.remove(testCase);
- maxFitness.set(getMaxFitness());
- }
-
public int getInputCount() {
return resources.inputs();
}
@@ -141,10 +112,6 @@ public abstract class TestCaseProblem<U extends Object> extends Problem {
return resources.outputs();
}
- public void parse(File file) {
- parser.parse(file);
- }
-
public void clearTestCases() {
testCases.clear();
}