Skip to content

Commit cfafa7d

Browse files
Merge pull request #317 from KernelTuner/firefly-negation-intensity
Change Firefly algorithm to use negation instead of division
2 parents 486eed9 + 9a00aa0 commit cfafa7d

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

kernel_tuner/strategies/firefly_algorithm.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __init__(self, bounds):
9494
"""Create Firefly at random position within bounds."""
9595
super().__init__(bounds)
9696
self.bounds = bounds
97-
self.intensity = 1 / self.score
97+
self.intensity = -self.score
9898

9999
def distance_to(self, other):
100100
"""Return Euclidian distance between self and other Firefly."""
@@ -103,10 +103,7 @@ def distance_to(self, other):
103103
def compute_intensity(self, fun):
104104
"""Evaluate cost function and compute intensity at this position."""
105105
self.evaluate(fun)
106-
if self.score == sys.float_info.max:
107-
self.intensity = -sys.float_info.max
108-
else:
109-
self.intensity = 1 / self.score
106+
self.intensity = -self.score
110107

111108
def move_towards(self, other, beta, alpha):
112109
"""Move firefly towards another given beta and alpha values."""

0 commit comments

Comments
 (0)