Fix DE/best/2 implementation

Implement DE/best/1
This commit is contained in:
Fabian Becker 2013-10-29 11:42:36 +01:00
parent 35044c2a1c
commit 866f0dbd88
2 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,6 @@
package eva2.optimization.enums;
public enum DETypeEnum {
DE1_Rand_1, DE2_CurrentToBest, DE_Best_2, TrigonometricDE, DE_CurrentToRand;
DE1_Rand_1, DE2_CurrentToBest, DE_Best_1, DE_Best_2, TrigonometricDE, DE_CurrentToRand;
//", "DE2 - DE/current-to-best/1", "DE/best/2", "Trigonometric DE"};
}

View File

@ -360,6 +360,20 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
}
break;
}
case DE_Best_1: {
// DE/best/1
AbstractEAIndividual bestIndy = getBestIndy(pop);
oX = getGenotype(bestIndy);
if (parents != null) {
parents.add(bestIndy);
} // Add best instead of preselected
double[] delta1 = this.fetchDeltaRandom(pop);
double[] delta2 = this.fetchDeltaRandom(pop);
for (int i = 0; i < oX.length; i++) {
vX[i] = oX[i] + this.getCurrentF() * (delta1[i] - delta2[i]);
}
break;
}
case DE_Best_2: {
// DE/best/2
AbstractEAIndividual bestIndy = getBestIndy(pop);
@ -369,8 +383,10 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
} // Add best instead of preselected
double[] delta1 = this.fetchDeltaRandom(pop);
double[] delta2 = this.fetchDeltaRandom(pop);
double[] delta3 = this.fetchDeltaRandom(pop);
double[] delta4 = this.fetchDeltaRandom(pop);
for (int i = 0; i < oX.length; i++) {
vX[i] = oX[i] + this.getCurrentF() * (delta1[i] + delta2[i]);
vX[i] = oX[i] + this.getCurrentF() * (delta1[i] - delta2[i]) + this.getCurrentF() * (delta3[i] - delta4[i]);
}
break;
}