Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonma1127 authored Apr 17, 2021
1 parent f25f15e commit 0062cf5
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,30 @@
## CODE EXAPMLE:

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

def RastriginFunc(X, D):
funsum = 0
for i in range(D):
x = X[i]
funsum += x**2-10*np.cos(2*np.pi*x)
funsum += 10*D
return funsum

def StyblinskiTangFunc(X, D):
funsum = 0
for i in range(D):
x = X[i]
funsum += (x**4) - 16*(x**2) + 5*x
funsum *= 0.5
return funsum


#FireflyAlgorithm(D, Lb, Ub, n, alpha, beta0, gamma, theta, iter_max, func)
FA = FireflyAlgorithm(2, -5, 5, 5, 1.0, 1.0, 0.01, 0.97, 50, func)
FA = FireflyAlgorithm(2, -5, 5, 5, 1.0, 1.0, 0.01, 0.97, 1000, test)
ans = FA.doRun()
print("Minimal",ans)
```

0 comments on commit 0062cf5

Please sign in to comment.