diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-25 19:38:16 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-25 19:38:16 +0100 |
commit | b0c0698e5503c2506217117bf144fde31e6f6601 (patch) | |
tree | 11a6e20fb565f1e75fb25852e757e4a37e4c313b /src/jcgp/backend/tests | |
parent | 9ac2848be66c39acdc291dc3b48b91178acc1a05 (diff) |
Commented lots of packages.
Diffstat (limited to 'src/jcgp/backend/tests')
-rw-r--r-- | src/jcgp/backend/tests/ChromosomeTests.java | 16 | ||||
-rw-r--r-- | src/jcgp/backend/tests/NodeTests.java | 24 | ||||
-rw-r--r-- | src/jcgp/backend/tests/OutputTests.java | 4 | ||||
-rw-r--r-- | src/jcgp/backend/tests/PopulationTests.java | 6 |
4 files changed, 19 insertions, 31 deletions
diff --git a/src/jcgp/backend/tests/ChromosomeTests.java b/src/jcgp/backend/tests/ChromosomeTests.java index 36278ba..bc0c57d 100644 --- a/src/jcgp/backend/tests/ChromosomeTests.java +++ b/src/jcgp/backend/tests/ChromosomeTests.java @@ -2,7 +2,7 @@ package jcgp.backend.tests; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import jcgp.backend.function.DoubleArithmetic; +import jcgp.backend.function.SymbolicRegressionFunctions; import jcgp.backend.population.Chromosome; import jcgp.backend.population.Connection; import jcgp.backend.population.Input; @@ -46,7 +46,7 @@ public class ChromosomeTests { @BeforeClass public static void setUpBeforeClass() { resources = new ModifiableResources(); - resources.setFunctionSet(new DoubleArithmetic()); + resources.setFunctionSet(new SymbolicRegressionFunctions()); } @Before @@ -285,12 +285,12 @@ public class ChromosomeTests { public void compareActiveTest() { // create a clone of the chromosome, compare active nodes - should return true Chromosome c = new Chromosome(chromosome); - assertTrue("Active nodes did not match.", chromosome.compareActiveTo(c)); - assertTrue("Symmetry not obeyed.", c.compareActiveTo(chromosome)); + assertTrue("Active nodes did not match.", chromosome.compareActiveGenesTo(c)); + assertTrue("Symmetry not obeyed.", c.compareActiveGenesTo(chromosome)); // create a new random chromosome, this time they should not match c = new Chromosome(resources); - assertTrue("Active nodes did match.", !chromosome.compareActiveTo(c)); + assertTrue("Active nodes did match.", !chromosome.compareActiveGenesTo(c)); } /** @@ -300,12 +300,12 @@ public class ChromosomeTests { public void compareTest() { // create a clone of the chromosome, compare - should return true Chromosome c = new Chromosome(chromosome); - assertTrue("Chromosomes did not match.", chromosome.compareTo(c)); - assertTrue("Symmetry not obeyed.", c.compareTo(chromosome)); + assertTrue("Chromosomes did not match.", chromosome.compareGenesTo(c)); + assertTrue("Symmetry not obeyed.", c.compareGenesTo(chromosome)); // create a new random chromosome, this time they should not match c = new Chromosome(resources); - assertTrue("Chromosomes did match.", !chromosome.compareTo(c)); + assertTrue("Chromosomes did match.", !chromosome.compareGenesTo(c)); } /** * Utility for creating a chromosome of known configuration. diff --git a/src/jcgp/backend/tests/NodeTests.java b/src/jcgp/backend/tests/NodeTests.java index 4054661..c63b41e 100644 --- a/src/jcgp/backend/tests/NodeTests.java +++ b/src/jcgp/backend/tests/NodeTests.java @@ -2,7 +2,7 @@ package jcgp.backend.tests; import static org.junit.Assert.assertTrue; import jcgp.backend.exceptions.InvalidArgumentsException; -import jcgp.backend.function.DoubleArithmetic; +import jcgp.backend.function.SymbolicRegressionFunctions; import jcgp.backend.function.Function; import jcgp.backend.population.Chromosome; import jcgp.backend.population.Connection; @@ -41,7 +41,7 @@ public class NodeTests { public static void setUpBeforeClass() { resources = new ModifiableResources(); - resources.setFunctionSet(new DoubleArithmetic()); + resources.setFunctionSet(new SymbolicRegressionFunctions()); chromosome = new Chromosome(resources); } @@ -49,7 +49,7 @@ public class NodeTests { public void setUp() throws Exception { node = new Node(chromosome, 0, 0, resources.arity()); // make node with anonymous addition function and hard-coded value connections - node.initialise(new DoubleArithmetic.Addition(), + node.initialise(new SymbolicRegressionFunctions.Addition(), new Connection[]{new Connection() { @Override @@ -80,7 +80,7 @@ public class NodeTests { Function f = new Function() { @Override - public Object run(Connection... connections) { + public Object run(Object... connections) { // blank return 0; } @@ -90,12 +90,6 @@ public class NodeTests { // blank return 0; } - - @Override - public String getName() { - // blank - return null; - } }; node.setFunction(f); @@ -113,7 +107,7 @@ public class NodeTests { ((int) node.getValue()) == arg1 + arg2); // put in a different function, check the output has changed appropriately - node.setFunction(new DoubleArithmetic.Subtraction()); + node.setFunction(new SymbolicRegressionFunctions.Subtraction()); assertTrue("Node did not return expected value (difference of arguments).", ((Integer) node.getValue()) == arg1 - arg2); @@ -142,7 +136,7 @@ public class NodeTests { Function function = new Function() { @Override - public Object run(Connection... connections) + public Object run(Object... connections) throws InvalidArgumentsException { // blank return null; @@ -152,12 +146,6 @@ public class NodeTests { public int getArity() { return 2; } - - @Override - public String getName() { - // blank - return null; - } }; node.initialise(function, conn0, conn1); diff --git a/src/jcgp/backend/tests/OutputTests.java b/src/jcgp/backend/tests/OutputTests.java index 95b7fc7..8cc10a8 100644 --- a/src/jcgp/backend/tests/OutputTests.java +++ b/src/jcgp/backend/tests/OutputTests.java @@ -1,7 +1,7 @@ package jcgp.backend.tests; import static org.junit.Assert.assertTrue; -import jcgp.backend.function.DoubleArithmetic; +import jcgp.backend.function.SymbolicRegressionFunctions; import jcgp.backend.population.Chromosome; import jcgp.backend.population.Connection; import jcgp.backend.population.Output; @@ -35,7 +35,7 @@ public class OutputTests { @BeforeClass public static void setUpBeforeClass() { resources = new ModifiableResources(); - resources.setFunctionSet(new DoubleArithmetic()); + resources.setFunctionSet(new SymbolicRegressionFunctions()); chromosome = new Chromosome(resources); } diff --git a/src/jcgp/backend/tests/PopulationTests.java b/src/jcgp/backend/tests/PopulationTests.java index fca9c4f..2f36ce1 100644 --- a/src/jcgp/backend/tests/PopulationTests.java +++ b/src/jcgp/backend/tests/PopulationTests.java @@ -1,7 +1,7 @@ package jcgp.backend.tests; import static org.junit.Assert.assertTrue; -import jcgp.backend.function.DoubleArithmetic; +import jcgp.backend.function.SymbolicRegressionFunctions; import jcgp.backend.population.Chromosome; import jcgp.backend.population.Population; import jcgp.backend.resources.ModifiableResources; @@ -32,7 +32,7 @@ public class PopulationTests { @BeforeClass public static void setUpBeforeClass() throws Exception { resources = new ModifiableResources(); - resources.setFunctionSet(new DoubleArithmetic()); + resources.setFunctionSet(new SymbolicRegressionFunctions()); } @Before @@ -64,6 +64,6 @@ public class PopulationTests { // initialise a population with a copy of it population = new Population(oc, resources); // check that the first parent chromosome is identical to, but not the same instance as, the one given - assertTrue("Incorrect chromosome in population.", population.getChromosome(0).compareTo(oc) && population.getChromosome(0) != oc); + assertTrue("Incorrect chromosome in population.", population.getChromosome(0).compareGenesTo(oc) && population.getChromosome(0) != oc); } } |