aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/tests/PopulationTests.java
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-04-01 23:00:53 +0100
committerEduardo Pedroni <ep625@york.ac.uk>2014-04-01 23:00:53 +0100
commit02fd2bc7059da416937beb1abe67e5ca60379030 (patch)
tree609341fe10aaa0f2dc45a1e72eba20bd24fb1281 /src/jcgp/tests/PopulationTests.java
parenta757deacded0d7357a9f68462d3f2051e16004ee (diff)
Settings pane now actually controls the parameters, not much left to do.
Diffstat (limited to 'src/jcgp/tests/PopulationTests.java')
-rw-r--r--src/jcgp/tests/PopulationTests.java86
1 files changed, 0 insertions, 86 deletions
diff --git a/src/jcgp/tests/PopulationTests.java b/src/jcgp/tests/PopulationTests.java
deleted file mode 100644
index a11becf..0000000
--- a/src/jcgp/tests/PopulationTests.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package jcgp.tests;
-
-import static org.junit.Assert.assertTrue;
-import jcgp.JCGP.Resources;
-import jcgp.population.Chromosome;
-import jcgp.population.Population;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * Tests which cover the behaviour specified for a population.
- *
- * - It should be possible to iterate through all the chromosomes in a population.
- * - When constructed with no arguments, it should generate populationSize
- * random chromosomes, distributed according to the EA parameters.
- * - If one or more chromosomes are passed into the constructor, it should use them
- * as parents to create the rest of the population.
- *
- *
- * @author Eduardo Pedroni
- *
- */
-public class PopulationTests {
-
- private Population population;
- private static Resources resources;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- resources = new Resources();
-
-
-// // initialise function set
-// FunctionSet functionSet = new FunctionSet(new Arithmetic.Addition(), new Arithmetic.Subtraction());
-//
-// // initialise utilities
-// Utilities.setResources(new Random(1234), functionSet);
-//
-// // initialise parameters
-// Resources.setColumns(20);
-// Resources.setRows(20);
-// Resources.setInputs(2);
-// Resources.setOutputs(4);
-// Resources.setLevelsBack(1);
-// Resources.setMutationRate(10);
-// Resources.setTotalGenerations(100);
-// Resources.setTotalRuns(5);
-// Resources.setPopulationSize(1, 4);
-// Resources.setMaxArity(functionSet.getMaxArity());
- }
-
- @Before
- public void setUp() throws Exception {
- population = new Population(resources);
- }
-
- @Test
- public void defaultPopulationTest() {
- // check that the constructor really generates populationSize chromosomes when none is given
- int chromosomes = 0;
- while (true) {
- try {
- population.getChromosome(chromosomes);
- } catch (IndexOutOfBoundsException e) {
- break;
- }
- chromosomes++;
- }
-
- assertTrue("Incorrect number of chromosomes generated.", chromosomes == resources.getInt("popSize"));
- }
-
- @Test
- public void preinitialisedChromosomeTest() {
- // the original chromosome that will be cloned
- Chromosome oc = new Chromosome(resources);
-
- // 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);
- }
-}