Skip to content

Commit ece95f1

Browse files
authored
Update FireflyAlgorithm.py
1 parent 0062cf5 commit ece95f1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

FireflyAlgorithm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
import random as rand
33
import math
4+
import time
45

56
class FireflyAlgorithm():
67

@@ -40,6 +41,7 @@ def update(self, i, j):
4041
self.functionArray[i] = self.func(self.tmpArray, self.D)
4142

4243
def doRun(self):
44+
start = time.time()
4345
self.init_FA()
4446
for gen in range(self.iter_max):
4547
print("Generation ", gen+1)
@@ -49,4 +51,6 @@ def doRun(self):
4951
self.update(i,j)
5052
print(self.populationArray)
5153
print(self.functionArray)
54+
end = time.time()
55+
print("執行時間:%f 秒" % (end - start))
5256
return self.functionArray.min()

0 commit comments

Comments
 (0)