aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/modules/ea/StandardEA.java
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-03-30 21:07:37 +0100
committerEduardo Pedroni <ep625@york.ac.uk>2014-03-30 21:07:37 +0100
commit04b35ccdad6e18701ede823e333118b0b22907c2 (patch)
tree0e993a5ffee4e63c4a2a6eca137da72b2453f868 /src/jcgp/modules/ea/StandardEA.java
parent2bf2d3ac2c578de481ecfd545d58be73c5628996 (diff)
Running into some issues with running the CGP loop in the background with bindings.
Diffstat (limited to 'src/jcgp/modules/ea/StandardEA.java')
-rw-r--r--src/jcgp/modules/ea/StandardEA.java79
1 files changed, 0 insertions, 79 deletions
diff --git a/src/jcgp/modules/ea/StandardEA.java b/src/jcgp/modules/ea/StandardEA.java
deleted file mode 100644
index 1d27004..0000000
--- a/src/jcgp/modules/ea/StandardEA.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package jcgp.modules.ea;
-
-import java.util.HashMap;
-
-import jcgp.JCGP.Resources;
-import jcgp.modules.mutator.Mutator;
-import jcgp.parameters.IntegerParameter;
-import jcgp.parameters.Parameter;
-import jcgp.population.Chromosome;
-import jcgp.population.Population;
-
-/**
- * (μ + λ) EA.
- *
- *
- * @author Eduardo Pedroni
- *
- */
-public class StandardEA implements EvolutionaryAlgorithm {
-
- private Chromosome fittestChromosome;
-
- private IntegerParameter parents, offspring;
- private HashMap<String, Parameter> localParameters;
-
- public StandardEA() {
- parents = new IntegerParameter(1, "Parents");
- offspring = new IntegerParameter(4, "Offspring");
-
- localParameters = new HashMap<String, Parameter>();
-
- localParameters.put("mu", parents);
- localParameters.put("lambda", offspring);
- }
-
- @Override
- public void evolve(Population population, Mutator mutator, Resources parameters) {
- // select fittest chromosome
- int fittest = 0;
-
- for (int i = 1; i < (int) parameters.get("popSize"); i++) {
- if (population.getChromosome(i).getFitness() >= population.getChromosome(fittest).getFitness()) {
- fittest = i;
- }
- }
- fittestChromosome = population.getChromosome(fittest);
- population.setBestIndividual(fittest);
- // create copies of fittest chromosome, mutate them
- Chromosome fc = population.getChromosome(fittest);
- for (int i = 0; i < (int) parameters.get("popSize"); i++) {
- if (i != fittest) {
- population.getChromosome(i).copyConnections(fc);
- mutator.mutate(population.getChromosome(i), parameters);
- }
- }
- }
-
- @Override
- public Chromosome getFittestChromosome() {
- return fittestChromosome;
- }
-
- @Override
- public void activate(Resources parameters) {
- parameters.getParameter("popSize").setManaged(true);
- }
-
- @Override
- public HashMap<String, Parameter> getLocalParameters() {
- return localParameters;
- }
-
- @Override
- public String toString() {
- return "(μ + λ)";
- }
-
-
-}