aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/modules/ea
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/modules/ea')
-rw-r--r--src/jcgp/modules/ea/EvolutionaryAlgorithm.java15
-rw-r--r--src/jcgp/modules/ea/MuPlusLambda.java80
-rw-r--r--src/jcgp/modules/ea/TournamentSelection.java54
3 files changed, 0 insertions, 149 deletions
diff --git a/src/jcgp/modules/ea/EvolutionaryAlgorithm.java b/src/jcgp/modules/ea/EvolutionaryAlgorithm.java
deleted file mode 100644
index 3bc7fcf..0000000
--- a/src/jcgp/modules/ea/EvolutionaryAlgorithm.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package jcgp.modules.ea;
-
-import jcgp.JCGP.Resources;
-import jcgp.modules.Module;
-import jcgp.modules.mutator.Mutator;
-import jcgp.population.Chromosome;
-import jcgp.population.Population;
-
-public interface EvolutionaryAlgorithm extends Module {
-
- public abstract void evolve(Population population, Mutator mutator, Resources parameters);
-
- public abstract Chromosome getFittestChromosome();
-
-}
diff --git a/src/jcgp/modules/ea/MuPlusLambda.java b/src/jcgp/modules/ea/MuPlusLambda.java
deleted file mode 100644
index 94900ca..0000000
--- a/src/jcgp/modules/ea/MuPlusLambda.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package jcgp.modules.ea;
-
-import java.util.HashMap;
-
-import jcgp.JCGP.Resources;
-import jcgp.modules.ModuleStatus;
-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 MuPlusLambda implements EvolutionaryAlgorithm {
-
- private Chromosome fittestChromosome;
-
- private IntegerParameter parents, offspring;
-
- private HashMap<String, Parameter> localParameters;
-
- public MuPlusLambda() {
- 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 < parameters.getInt("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 < parameters.getInt("popSize"); i++) {
- if (i != fittest) {
- population.getChromosome(i).copyConnections(fc);
- mutator.mutate(population.getChromosome(i), parameters);
- }
- }
- }
-
- @Override
- public Chromosome getFittestChromosome() {
- return fittestChromosome;
- }
-
- @Override
- public HashMap<String, Parameter> getLocalParameters() {
- return localParameters;
- }
-
- @Override
- public String toString() {
- return "(μ + λ)";
- }
-
- @Override
- public ModuleStatus getStatus(Resources resources) {
- return ModuleStatus.READY;
- }
-
-}
diff --git a/src/jcgp/modules/ea/TournamentSelection.java b/src/jcgp/modules/ea/TournamentSelection.java
deleted file mode 100644
index c2915a5..0000000
--- a/src/jcgp/modules/ea/TournamentSelection.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package jcgp.modules.ea;
-
-import java.util.HashMap;
-
-import jcgp.JCGP.Resources;
-import jcgp.modules.ModuleStatus;
-import jcgp.modules.mutator.Mutator;
-import jcgp.parameters.IntegerParameter;
-import jcgp.parameters.Parameter;
-import jcgp.population.Chromosome;
-import jcgp.population.Population;
-
-public class TournamentSelection implements EvolutionaryAlgorithm {
-
- private Chromosome fittestChromosome;
-
- private IntegerParameter tournament;
- private HashMap<String, Parameter> localParameters;
-
- public TournamentSelection() {
- tournament = new IntegerParameter(1, "Tournament size");
-
- localParameters = new HashMap<String, Parameter>();
- localParameters.put("tournament", tournament);
- }
-
- @Override
- public HashMap<String, Parameter> getLocalParameters() {
- return localParameters;
- }
-
- @Override
- public void evolve(Population population, Mutator mutator,
- Resources parameters) {
-
- // TODO implement this
-
- }
-
- @Override
- public Chromosome getFittestChromosome() {
- return fittestChromosome;
- }
-
- @Override
- public String toString() {
- return "Tournament";
- }
-
- @Override
- public ModuleStatus getStatus(Resources resources) {
- return null;
- }
-}