Fix DE/best/2 implementation
Implement DE/best/1
This commit is contained in:
parent
35044c2a1c
commit
866f0dbd88
@ -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"};
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user