diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-02-04 16:53:19 +0000 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-02-04 16:53:19 +0000 |
commit | 0e34bfdb60c28a6118ec93893ddc7ceb6fa50cb5 (patch) | |
tree | 77f27ba5656e31e3bd75aebf21a96a840f813667 /src/jcgp | |
parent | 1fd678821cf133c7c431daea687f3467bb0be2dd (diff) |
Started work on StandardEA, will require some modifications.
Diffstat (limited to 'src/jcgp')
-rw-r--r-- | src/jcgp/CGP.java | 9 | ||||
-rw-r--r-- | src/jcgp/ea/StandardEA.java | 4 | ||||
-rw-r--r-- | src/jcgp/population/Population.java | 4 |
3 files changed, 8 insertions, 9 deletions
diff --git a/src/jcgp/CGP.java b/src/jcgp/CGP.java index 26d1d2b..5111508 100644 --- a/src/jcgp/CGP.java +++ b/src/jcgp/CGP.java @@ -171,9 +171,6 @@ public final class CGP { private static void setMaxArity(int maxArity) { Parameters.maxArity = maxArity; } - - - } public abstract static class Utilities { @@ -371,6 +368,9 @@ public final class CGP { private void initialise() { // initialise random number generator numberGenerator = new Random(1234); + + // initialise function set + functionSet = new FunctionSet(new Addition(), new Subtraction()); // initialise parameters Parameters.setInputs(3); @@ -383,9 +383,6 @@ public final class CGP { Parameters.setPopulationSize(5); Parameters.setLevelsBack(1); - // initialise function set - functionSet = new FunctionSet(new Addition(), new Subtraction()); - // compute and set maximum arity Parameters.setMaxArity(functionSet.getMaxArity()); diff --git a/src/jcgp/ea/StandardEA.java b/src/jcgp/ea/StandardEA.java index b98fe9e..f401d9c 100644 --- a/src/jcgp/ea/StandardEA.java +++ b/src/jcgp/ea/StandardEA.java @@ -6,9 +6,7 @@ import jcgp.population.Population; public class StandardEA implements EvolutionaryAlgorithm { @Override - public void evolve(Population population, Mutator mutator) { - - + public void evolve(Population population, Mutator mutator) { for (Chromosome chromosome : population) { mutator.mutate(chromosome); } diff --git a/src/jcgp/population/Population.java b/src/jcgp/population/Population.java index e171a2f..c4a0776 100644 --- a/src/jcgp/population/Population.java +++ b/src/jcgp/population/Population.java @@ -17,6 +17,10 @@ public class Population implements Iterable<Chromosome> { Parameters.getOutputs()); } } + + public Population(Chromosome ... chromosomes) { + population = chromosomes; + } @Override public Iterator<Chromosome> iterator() { |