diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-02-11 22:17:30 +0000 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-02-11 22:17:30 +0000 |
commit | ccdecd80ffe482fbe994515e98eeae68fb4ca401 (patch) | |
tree | 50013c63d2e524ac69350256dd87fc0902dce0f9 /src/jcgp/tests | |
parent | dd3b6446671f31d716eb07e546c6150b4d080abd (diff) |
Finished writing chromosome tests, implemented active node detection, started writing node tests.
Diffstat (limited to 'src/jcgp/tests')
-rw-r--r-- | src/jcgp/tests/ChromosomeTests.java | 16 | ||||
-rw-r--r-- | src/jcgp/tests/NodeTests.java | 34 |
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() { + + } + +} |