diff options
Diffstat (limited to 'src/jcgp/tests/NodeTests.java')
-rw-r--r-- | src/jcgp/tests/NodeTests.java | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/jcgp/tests/NodeTests.java b/src/jcgp/tests/NodeTests.java index 74b8140..330ef7a 100644 --- a/src/jcgp/tests/NodeTests.java +++ b/src/jcgp/tests/NodeTests.java @@ -1,13 +1,9 @@ package jcgp.tests; import static org.junit.Assert.assertTrue; - -import java.util.Random; - -import jcgp.Utilities; -import jcgp.modules.function.Arithmetic; -import jcgp.modules.function.Function; -import jcgp.parameters.Parameters; +import jcgp.CGP.Resources; +import jcgp.function.Arithmetic; +import jcgp.function.Function; import jcgp.population.Chromosome; import jcgp.population.Connection; import jcgp.population.Node; @@ -35,32 +31,22 @@ public class NodeTests { private Node node; private static Chromosome chromosome; + private static Resources resources; // these numbers will be used by the node under test private final int arg1 = 2; private final int arg2 = 5; @BeforeClass public static void setUpBeforeClass() { - // initialise utilities - Utilities.setResources(new Random(1234), null); - - // initialise parameters - Parameters.setColumns(0); - Parameters.setRows(0); - Parameters.setInputs(0); - Parameters.setOutputs(0); - Parameters.setLevelsBack(0); - Parameters.setMutationRate(10); - Parameters.setTotalGenerations(100); - Parameters.setTotalRuns(5); - Parameters.setMaxArity(2); - - chromosome = new Chromosome(); + + resources = new Resources(); + + chromosome = new Chromosome(resources); } @Before public void setUp() throws Exception { - node = new Node(chromosome, 0, 0); + node = new Node(chromosome, 0, 0, (int) resources.get("arity")); // make node with anonymous addition function and hard-coded value connections node.initialise(new Arithmetic.Addition(), new Connection[]{new Connection() { @@ -117,6 +103,12 @@ public class NodeTests { // blank return 0; } + + @Override + public String getName() { + // blank + return null; + } }; node.setFunction(f); @@ -194,7 +186,7 @@ public class NodeTests { return null; } }; - node.setConnection(conn2); + node.setConnection(resources.getRandomInt((int) resources.get("arity")), conn2); assertTrue("Connection was not found in node.", node.getConnection(0) == conn2 || node.getConnection(1) == conn2); |