aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jcgp/CGP.java9
-rw-r--r--src/jcgp/ea/StandardEA.java4
-rw-r--r--src/jcgp/population/Population.java4
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() {