aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/modules/es/MuPlusLambda.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/backend/modules/es/MuPlusLambda.java')
-rw-r--r--src/jcgp/backend/modules/es/MuPlusLambda.java22
1 files changed, 3 insertions, 19 deletions
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};
}