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