DE update: the meaning of k was inverted w.r.t. literature, this is now changed.

This commit is contained in:
Marcel Kronfeld 2010-09-17 13:06:45 +00:00
parent 53d9762da5
commit 33dc1be0bf

View File

@ -305,7 +305,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
} }
double[] nX, vX, oX; double[] nX, vX, oX;
oX = esIndy.getDoubleData(); oX = esIndy.getDoubleData();
vX = esIndy.getDoubleData(); vX = oX.clone();
nX = new double[oX.length]; nX = new double[oX.length];
switch (this.m_DEType) { switch (this.m_DEType) {
case DE1_Rand_1: { case DE1_Rand_1: {
@ -387,13 +387,14 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
break; break;
} }
} }
int k=RNG.randomInt(oX.length); // at least one position is changed
for (int i =0; i < oX.length; i++) { for (int i =0; i < oX.length; i++) {
if (RNG.flipCoin(this.getCurrentK())) { if ((i==k) || RNG.flipCoin(this.getCurrentK())) {
// it remains the same
nX[i] = oX[i];
} else {
// it is altered // it is altered
nX[i] = vX[i]; nX[i] = vX[i];
} else {
// it remains the same
nX[i] = oX[i];
} }
} }
// setting the new genotype and fitness // setting the new genotype and fitness