Population-based incremental learning: Difference between revisions

Content deleted Content added
Edaeda (talk | contribs)
No edit summary
Edaeda (talk | contribs)
Line 53:
for (int i = 0; i < ITER_COUNT; i++) {
// Creates N genotypesgenes
final boolean[][] genoTypesgenes = new boolean[N][totalBits];
for (boolean[] genoTypegene : genoTypesgenes) {
for (int k = 0; k < genoTypegene.length; k++) {
if (rand.nextDouble() < probVec[k])
genoTypegene[k] = true;
}
}
Line 65:
final double[] costs = new double[N];
for (int j = 0; j < N; j++) {
costs[j] = costFunc.cost(toRealVec(genoTypesgenes[j], domains));
}
 
// Find min and max cost genotypesgenes
boolean[] minGenoTypeminGene = null, maxGenoTypemaxGene = null;
double minCost = POSITIVE_INFINITY, maxCost = NEGATIVE_INFINITY;
for (int j = 0; j < N; j++) {
Line 75:
if (minCost > cost) {
minCost = cost;
minGenoTypeminGene = genoTypesgenes[j];
}
if (maxCost < cost) {
maxCost = cost;
maxGenoTypemaxGene = genoTypesgenes[j];
}
}
 
// Compare with the best cost genotypesgene
if (bestCost > minCost) {
bestCost = minCost;
bestGenoTypebestGene = minGenoTypeminGene;
}
 
// Update the probability vector with max and min cost genotypesgenes
for (int j = 0; j < totalBits; j++) {
if (minGenoTypeminGene[j] == maxGenoTypemaxGene[j]) {
probVec[j] = probVec[j] * (1d - learnRate) +
(minGenoTypeminGene[j] ? 1d : 0d) * learnRate;
} else {
final double learnRate2 = learnRate + negLearnRate;
probVec[j] = probVec[j] * (1d - learnRate2) +
(minGenoTypeminGene[j] ? 1d : 0d) * learnRate2;
}
}