aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/population
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-02-14 18:13:21 +0000
committerEduardo Pedroni <ep625@york.ac.uk>2014-02-14 18:13:21 +0000
commitafa484021ba94d12e98da682a9ff69c3837d5dbb (patch)
tree2150c437cb74ccf141f8cfde228ebf5dd442314a /src/jcgp/population
parent6419b69faeb4736db1ccb50cfa5a030f9aa818aa (diff)
Generic data type functionality implemented. All tests were refactored to reflect this, and some chromosome tests were rewritten with more rigorous assertions.
Diffstat (limited to 'src/jcgp/population')
-rw-r--r--src/jcgp/population/Chromosome.java2
-rw-r--r--src/jcgp/population/Connection.java2
-rw-r--r--src/jcgp/population/Input.java7
-rw-r--r--src/jcgp/population/Node.java2
-rw-r--r--src/jcgp/population/Output.java2
5 files changed, 8 insertions, 7 deletions
diff --git a/src/jcgp/population/Chromosome.java b/src/jcgp/population/Chromosome.java
index f61b780..12a8978 100644
--- a/src/jcgp/population/Chromosome.java
+++ b/src/jcgp/population/Chromosome.java
@@ -158,7 +158,7 @@ public class Chromosome {
* @param values
* @throws ParameterMismatchException
*/
- public void setInputs(int ... values) throws ParameterMismatchException {
+ public void setInputs(Object ... values) throws ParameterMismatchException {
// if the values provided don't match the specified number of inputs, the user should be warned
if (values.length == inputs.length) {
// set inputs for evaluation
diff --git a/src/jcgp/population/Connection.java b/src/jcgp/population/Connection.java
index 3312de3..ff11d7c 100644
--- a/src/jcgp/population/Connection.java
+++ b/src/jcgp/population/Connection.java
@@ -2,6 +2,6 @@ package jcgp.population;
public interface Connection {
- public int getValue();
+ public Object getValue();
}
diff --git a/src/jcgp/population/Input.java b/src/jcgp/population/Input.java
index ee008ce..2154dd9 100644
--- a/src/jcgp/population/Input.java
+++ b/src/jcgp/population/Input.java
@@ -2,18 +2,19 @@ package jcgp.population;
public class Input implements Connection {
- private int value = 0, index;
+ private Object value = 0;
+ private int index;
public Input(int index) {
this.index = index;
}
- public void setValue(int newValue) {
+ public void setValue(Object newValue) {
value = newValue;
}
@Override
- public int getValue() {
+ public Object getValue() {
return value;
}
diff --git a/src/jcgp/population/Node.java b/src/jcgp/population/Node.java
index b2e29df..e58c1a4 100644
--- a/src/jcgp/population/Node.java
+++ b/src/jcgp/population/Node.java
@@ -23,7 +23,7 @@ public class Node implements MutableElement, Connection {
}
@Override
- public int getValue() {
+ public Object getValue() {
return function.run(Arrays.copyOfRange(connections, 0, function.getArity()));
}
diff --git a/src/jcgp/population/Output.java b/src/jcgp/population/Output.java
index f0bcbbf..dae7278 100644
--- a/src/jcgp/population/Output.java
+++ b/src/jcgp/population/Output.java
@@ -13,7 +13,7 @@ public class Output implements MutableElement {
this.index = index;
}
- public int calculate() {
+ public Object calculate() {
return source.getValue();
}