From 0e34bfdb60c28a6118ec93893ddc7ceb6fa50cb5 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Tue, 4 Feb 2014 16:53:19 +0000 Subject: Started work on StandardEA, will require some modifications. --- src/jcgp/CGP.java | 9 +++------ src/jcgp/ea/StandardEA.java | 4 +--- src/jcgp/population/Population.java | 4 ++++ 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src/jcgp') 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 { Parameters.getOutputs()); } } + + public Population(Chromosome ... chromosomes) { + population = chromosomes; + } @Override public Iterator iterator() { -- cgit v1.2.3