Skip to content

Commit 0062cf5

Browse files
authored
Update README.md
1 parent f25f15e commit 0062cf5

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,30 @@
33
## CODE EXAPMLE:
44

55
```python
6-
def func(x1, x2):
6+
def test(X, D):
7+
x1 = X[0]
8+
x2 = X[1]
79
return x1**2 - x1*x2 + x2**2 + 2*x1 + 4*x2 + 3
810

11+
def RastriginFunc(X, D):
12+
funsum = 0
13+
for i in range(D):
14+
x = X[i]
15+
funsum += x**2-10*np.cos(2*np.pi*x)
16+
funsum += 10*D
17+
return funsum
18+
19+
def StyblinskiTangFunc(X, D):
20+
funsum = 0
21+
for i in range(D):
22+
x = X[i]
23+
funsum += (x**4) - 16*(x**2) + 5*x
24+
funsum *= 0.5
25+
return funsum
26+
27+
928
#FireflyAlgorithm(D, Lb, Ub, n, alpha, beta0, gamma, theta, iter_max, func)
10-
FA = FireflyAlgorithm(2, -5, 5, 5, 1.0, 1.0, 0.01, 0.97, 50, func)
29+
FA = FireflyAlgorithm(2, -5, 5, 5, 1.0, 1.0, 0.01, 0.97, 1000, test)
1130
ans = FA.doRun()
1231
print("Minimal",ans)
1332
```

0 commit comments

Comments
 (0)