aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/tests')
-rw-r--r--src/jcgp/tests/ChromosomeTests.java16
-rw-r--r--src/jcgp/tests/NodeTests.java34
2 files changed, 49 insertions, 1 deletions
diff --git a/src/jcgp/tests/ChromosomeTests.java b/src/jcgp/tests/ChromosomeTests.java
index ece8203..3b7319f 100644
--- a/src/jcgp/tests/ChromosomeTests.java
+++ b/src/jcgp/tests/ChromosomeTests.java
@@ -146,7 +146,7 @@ public class ChromosomeTests {
}
}
System.out.println("Out of " + connectionPicks + " connections picked from " + ((chosenColumn >= Parameters.getLevelsBack()) ? Parameters.getLevelsBack() : chosenColumn) * Parameters.getRows() +
- " nodes and " + Parameters.getInputs() + " allowed nodes, " + connectionNodes + " were nodes and " + connectionInputs + " were inputs.");
+ " allowed nodes and " + Parameters.getInputs() + " inputs, " + connectionNodes + " were nodes and " + connectionInputs + " were inputs.");
System.out.println("Node/input ratio: " + ((double) ((chosenColumn >= Parameters.getLevelsBack()) ? Parameters.getLevelsBack() : chosenColumn) * Parameters.getRows()) / (double) Parameters.getInputs() +
", picked ratio: " + (double) connectionNodes / (double) connectionInputs);
@@ -228,6 +228,20 @@ public class ChromosomeTests {
*/
@Test
public void activeNodeTest() {
+ // active node detection happens recursively, the user only calls a single method
+ // set connections to a known configuration
+ for (int i = 0; i < Parameters.getOutputs(); i++) {
+ chromosome.getOutput(i).setConnection(chromosome.getNode(0, 0));
+ }
+
+ chromosome.getNode(0, 0).setConnection(chromosome.getInput(0));
+ assertTrue("Active connection not in list.", chromosome.getActiveNodes().contains(chromosome.getInput(0)));
+ assertTrue("Active connection not in list.", chromosome.getActiveNodes().contains(chromosome.getNode(0, 0)));
+
+ // change outputs, print list
+ chromosome.getOutput(0).setConnection(chromosome.getNode(0, Parameters.getColumns() - 1));
+
+ System.out.println("Active connections: " + chromosome.getActiveNodes().toString() + "\n");
}
}
diff --git a/src/jcgp/tests/NodeTests.java b/src/jcgp/tests/NodeTests.java
new file mode 100644
index 0000000..921879f
--- /dev/null
+++ b/src/jcgp/tests/NodeTests.java
@@ -0,0 +1,34 @@
+package jcgp.tests;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ * Tests which cover the behaviour specified for a node.
+ *
+ * - A node should contain read-only row and column values which are set upon construction.
+ * - It should contain a fully accessible Function object.
+ * - It should contain a set of connections which can be initialised and randomly
+ * modified.
+ *
+ * WARNING: changing parameters may cause the tests to incorrectly fail!
+ *
+ * @author Eduardo Pedroni
+ *
+ */
+public class NodeTests {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @Test
+ public void test() {
+
+ }
+
+}