fix an issue in the global update
This commit is contained in:
@@ -110,10 +110,11 @@ class Colony:
|
|||||||
if None == bestCandidate or candidate[0] < bestCandidate[0]:
|
if None == bestCandidate or candidate[0] < bestCandidate[0]:
|
||||||
bestCandidate = candidate
|
bestCandidate = candidate
|
||||||
|
|
||||||
dTheta = 1.0 / ((candidate[0].total_seconds() / 60.0) or 1.0)
|
if None != bestSequence:
|
||||||
for i in range(1, len(candidate[1])):
|
dTheta = 1.0 / ((bestSequence[0].total_seconds() / 60.0) or 1.0)
|
||||||
update = (1.0 - self.Configuration.Epsilon) * self.PheromoneMatrix[candidate[1][i - 1], candidate[1][i]] + dTheta
|
for i in range(1, len(bestSequence[1])):
|
||||||
self.PheromoneMatrix[candidate[1][i - 1], candidate[1][i]] = max(update, self.Configuration.ThetaZero)
|
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
|
# check if we find a new best candidate
|
||||||
if None != bestCandidate:
|
if None != bestCandidate:
|
||||||
|
|||||||
Reference in New Issue
Block a user