fix an issue in the global update

This commit is contained in:
Sven Czarnian
2021-12-16 10:23:40 +01:00
vanhempi cd5c21d099
commit bb6cacd898

Näytä tiedosto

@@ -110,10 +110,11 @@ class Colony:
if None == bestCandidate or candidate[0] < bestCandidate[0]:
bestCandidate = candidate
dTheta = 1.0 / ((candidate[0].total_seconds() / 60.0) or 1.0)
for i in range(1, len(candidate[1])):
update = (1.0 - self.Configuration.Epsilon) * self.PheromoneMatrix[candidate[1][i - 1], candidate[1][i]] + dTheta
self.PheromoneMatrix[candidate[1][i - 1], candidate[1][i]] = max(update, self.Configuration.ThetaZero)
if None != bestSequence:
dTheta = 1.0 / ((bestSequence[0].total_seconds() / 60.0) or 1.0)
for i in range(1, len(bestSequence[1])):
update = (1.0 - self.Configuration.Epsilon) * self.PheromoneMatrix[bestSequence[1][i - 1], bestSequence[1][i]] + self.Configuration.Epsilon * dTheta
self.PheromoneMatrix[bestSequence[1][i - 1], bestSequence[1][i]] = max(update, self.Configuration.ThetaZero)
# check if we find a new best candidate
if None != bestCandidate: