From 0062cf551b95fa092bcac0a62724c4cd1eab9fc7 Mon Sep 17 00:00:00 2001 From: jasonma1127 <33441316+jasonma1127@users.noreply.github.com> Date: Sat, 17 Apr 2021 17:46:30 +0800 Subject: [PATCH] Update README.md --- README.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c90ac34..0771c25 100644 --- a/README.md +++ b/README.md @@ -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) ```