diff options
Diffstat (limited to 'src/jcgp/backend/modules/es')
-rw-r--r-- | src/jcgp/backend/modules/es/EvolutionaryStrategy.java | 4 | ||||
-rw-r--r-- | src/jcgp/backend/modules/es/MuPlusLambda.java | 22 | ||||
-rw-r--r-- | src/jcgp/backend/modules/es/TournamentSelection.java | 8 |
3 files changed, 4 insertions, 30 deletions
diff --git a/src/jcgp/backend/modules/es/EvolutionaryStrategy.java b/src/jcgp/backend/modules/es/EvolutionaryStrategy.java index 1117e99..8ab287d 100644 --- a/src/jcgp/backend/modules/es/EvolutionaryStrategy.java +++ b/src/jcgp/backend/modules/es/EvolutionaryStrategy.java @@ -8,7 +8,5 @@ import jcgp.backend.resources.Resources; public interface EvolutionaryStrategy extends Module { public abstract void evolve(Population population, Mutator mutator, Resources resources); - - public abstract int getFittestChromosome(); - + } diff --git a/src/jcgp/backend/modules/es/MuPlusLambda.java b/src/jcgp/backend/modules/es/MuPlusLambda.java index 67236f9..6a3883b 100644 --- a/src/jcgp/backend/modules/es/MuPlusLambda.java +++ b/src/jcgp/backend/modules/es/MuPlusLambda.java @@ -17,8 +17,6 @@ import jcgp.backend.resources.parameters.ParameterStatus; */ public class MuPlusLambda implements EvolutionaryStrategy { - private int fittestChromosome; - private IntegerParameter parents, offspring; private BooleanParameter report; @@ -62,22 +60,13 @@ public class MuPlusLambda implements EvolutionaryStrategy { @Override public void evolve(Population population, Mutator mutator, Resources resources) { // select fittest chromosomes - fittestChromosome = 0; - - if (report.get()) resources.reportln("[ES] Selecting fittest chromosome..."); - for (int i = 0; i < resources.populationSize(); i++) { - if (report.get()) resources.reportln("[ES] Chromosome " + i + ", fitness: " + population.getChromosome(i).getFitness()); - if (population.getChromosome(i).getFitness() >= population.getChromosome(fittestChromosome).getFitness()) { - fittestChromosome = i; - } - } - if (report.get()) resources.reportln("[ES] Selected chromosome: " + fittestChromosome); + if (report.get()) resources.reportln("[ES] Selected chromosome: " + population.getFittestIndex()); // create copies of fittest chromosome, mutate them for (int i = 0; i < resources.populationSize(); i++) { - if (i != fittestChromosome) { + if (i != population.getFittestIndex()) { if (report.get()) resources.reportln("[ES] Copying fittest chromosome to population position " + i); - population.copyChromosome(fittestChromosome, i); + population.copyChromosome(population.getFittestIndex(), i); if (report.get()) resources.reportln("[ES] Mutating copied chromosome"); mutator.mutate(population.getChromosome(i), resources); } @@ -88,11 +77,6 @@ public class MuPlusLambda implements EvolutionaryStrategy { } @Override - public int getFittestChromosome() { - return fittestChromosome; - } - - @Override public Parameter<?>[] getLocalParameters() { return new Parameter[] {parents, offspring, report}; } diff --git a/src/jcgp/backend/modules/es/TournamentSelection.java b/src/jcgp/backend/modules/es/TournamentSelection.java index 8286101..4070468 100644 --- a/src/jcgp/backend/modules/es/TournamentSelection.java +++ b/src/jcgp/backend/modules/es/TournamentSelection.java @@ -8,8 +8,6 @@ import jcgp.backend.resources.parameters.Parameter; public class TournamentSelection implements EvolutionaryStrategy { - private int fittestChromosome; - private IntegerParameter tournament; public TournamentSelection() { @@ -30,15 +28,9 @@ public class TournamentSelection implements EvolutionaryStrategy { public void evolve(Population population, Mutator mutator, Resources parameters) { tournament.set(tournament.get() + 1); - fittestChromosome = 0; // TODO implement this } - - @Override - public int getFittestChromosome() { - return fittestChromosome; - } @Override public String toString() { |