From 09872a6aeaf70195d6e56efaa4d278a3f240bd5e Mon Sep 17 00:00:00 2001 From: zStupan <48752988+zStupan@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:53:45 +0100 Subject: [PATCH 1/9] Fix typos --- fireflyalgorithm/problems.py | 4 ++-- tests/test_problems.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fireflyalgorithm/problems.py b/fireflyalgorithm/problems.py index 20a412d..580cac7 100644 --- a/fireflyalgorithm/problems.py +++ b/fireflyalgorithm/problems.py @@ -124,7 +124,7 @@ def powell(x): return np.sum(term1 + term2 + term3 + term4) -def quing(x): +def qing(x): dim = len(x) return np.sum(np.power(x**2 - np.arange(1, dim + 1), 2)) @@ -245,7 +245,7 @@ def zakharov(x): "perm2": perm2, "pinter": pinter, "powell": powell, - "quing": quing, + "qing": qing, "quintic": quintic, "rastrigin": rastrigin, "rosenbrock": rosenbrock, diff --git a/tests/test_problems.py b/tests/test_problems.py index 7ced6bb..c28c47b 100644 --- a/tests/test_problems.py +++ b/tests/test_problems.py @@ -56,7 +56,7 @@ def test_problem_factory(self): self.assertEqual(get_problem("perm2"), perm2) self.assertEqual(get_problem("pinter"), pinter) self.assertEqual(get_problem("powell"), powell) - self.assertEqual(get_problem("quing"), quing) + self.assertEqual(get_problem("qing"), qing) self.assertEqual(get_problem("quintic"), quintic) self.assertEqual(get_problem("rastrigin"), rastrigin) self.assertEqual(get_problem("rosenbrock"), rosenbrock) @@ -135,7 +135,7 @@ def test_powell(self): x = np.zeros(5) self.assertAlmostEqual(powell(x), 0.0) - def test_quing(self): + def test_qing(self): x = np.sqrt(np.arange(1, 6)) self.assertAlmostEqual(quing(x), 0.0) From f55809e6a684b67a80d46a39cf71ac243c3e4a1d Mon Sep 17 00:00:00 2001 From: zStupan <48752988+zStupan@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:56:04 +0100 Subject: [PATCH 2/9] fix typos --- tests/test_problems.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_problems.py b/tests/test_problems.py index c28c47b..4f5c93f 100644 --- a/tests/test_problems.py +++ b/tests/test_problems.py @@ -137,7 +137,7 @@ def test_powell(self): def test_qing(self): x = np.sqrt(np.arange(1, 6)) - self.assertAlmostEqual(quing(x), 0.0) + self.assertAlmostEqual(qing(x), 0.0) def test_quintic(self): x = np.full(5, -1) From 3b414d19f357938caca01c14967d238c9198164a Mon Sep 17 00:00:00 2001 From: zStupan <48752988+zStupan@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:57:13 +0100 Subject: [PATCH 3/9] fix typos --- tests/test_problems.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_problems.py b/tests/test_problems.py index 4f5c93f..e00e479 100644 --- a/tests/test_problems.py +++ b/tests/test_problems.py @@ -17,7 +17,7 @@ perm2, pinter, powell, - quing, + qing, quintic, rastrigin, rosenbrock, From dd8f1a18812a0460882c8c534813c579a131de7f Mon Sep 17 00:00:00 2001 From: zStupan Date: Tue, 7 Nov 2023 15:42:21 +0100 Subject: [PATCH 4/9] added test problem definitions --- Problems.md | 389 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 389 insertions(+) create mode 100644 Problems.md diff --git a/Problems.md b/Problems.md new file mode 100644 index 0000000..84e1e95 --- /dev/null +++ b/Problems.md @@ -0,0 +1,389 @@ +# Test Functions + +Bellow You'll find the definitions of all the test functions implemented in this package. + +## Ackley +***Function name:*** `ackley` + +```math +f(x) = -20 e^{-0.2 \sqrt{\frac{1}{D} \sum_{i=1}^D x_i^2}} - e^{\frac{1}{D} \sum_{i=1}^D \cos(2 \pi x_i)} + 20 + e +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Alpine 1 +***Function name:*** `alpine1` + +```math +f(x) = \sum_{i=1}^{D} \lvert {x_i \sin \left( x_i \right) + 0.1 x_i} \rvert +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Alpine 2 +***Function name:*** `alpine2` + +```math +f(x) = \prod_{i=1}^{D} \sqrt{x_i} \sin(x_i) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 2.808^D`$ for $`x_i^* = 7.917`$ + +## Cigar +***Function name:*** `cigar` + +```math +f(x) = x_1^2 + 10^6\sum_{i=2}^{D} x_i^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Cosine Mixture +***Function name:*** `cosine_mixture` + +```math +f(x) = -0.1 \sum_{i=1}^D \cos (5 \pi x_i) - \sum_{i=1}^D x_i^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = -0.1 D`$ for $`x_i^* = 0`$ + +## Csendes +***Function name:*** `csendes` + +```math +f(x) = \sum_{i=1}^D x_i^6 \left( 2 + \sin \frac{1}{x_i}\right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Dixon-Price +***Function name:*** `dixon_price` + +```math +f(x) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 2^{- \frac{(2^i - 2)}{2^i}}`$ + +## Griewank +***Function name:*** `griewank` + +```math +f(x) = \sum_{i=1}^D \frac{x_i^2}{4000} - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Katsuura +***Function name:*** `katsuura` + +```math +\prod_{i=1}^D \left(1 + i \sum_{j=1}^{32} \frac{\lvert 2^j x_i - round\left(2^j x_i \right) \rvert}{2^j} \right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 1`$ for $`x_i^* = 0`$ + +## Levy +***Function name:*** `levy` + +```math + \begin{gather} + \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)),\,\text{where}\\ + w_i = 1 + \frac{x_i - 1}{4},\, \text{for all } i = 1, \ldots, D + \end{gather} + +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 1`$ + +## Michalewicz +***Function name:*** `michalewicz` + +```math +f(x) = - \sum_{i = 1}^{D} \sin(x_i) \sin^{2m}\left( \frac{ix_i^2}{\pi} \right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`\text{at } D=2,\,f(x^*) = -1.8013`$ for $`x^* = (2.20, 1.57)`$ + +## Perm 1 +***Function name:*** `perm1` + +```math +f(x) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j^i + \beta) \left( \left(\frac{x_j}{j}\right)^i - 1 \right) \right)^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = i`$ + +## Perm 2 +***Function name:*** `perm2` + +```math +f(x) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = \frac{1}{i}`$ + +## Pinter +***Function name:*** `pinter` + +```math +\begin{equation} +f(\mathbf{x}) = +\sum_{i=1}^D ix_i^2 + \sum_{i=1}^D 20i \sin^2 A + \sum_{i=1}^D i \log_{10} (1 + iB^2),\, \text{where} +\end{equation} + +\begin{align} +A &= (x_{i-1}\sin(x_i)+\sin(x_{i+1})) \\ +B &= (x_{i-1}^2 - 2x_i + 3x_{i+1} - \cos(x_i) + 1) +\end{align} +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Powell +***Function name:*** `powell` + +```math +f(x) = \sum_{i = 1}^{D/4} \left[ (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right] +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Qing +***Function name:*** `qing` + +```math +f(x) = \sum_{i=1}^D \left(x_i^2 - i\right)^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = \pm \sqrt{i}`$ + +## Quintic +***Function name:*** `quintic` + +```math +f(x) = \sum_{i=1}^D \left| x_i^5 - 3x_i^4 + 4x_i^3 + 2x_i^2 - 10x_i - 4\right| +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = -1\quad \text{or} \quad x_i^* = 2`$ + +## Rastrigin +***Function name:*** `rastrigin` + +```math +f(x) = 10D + \sum_{i=1}^D \left[x_i^2 -10\cos(2\pi x_i)\right] +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Rosenbrock +***Function name:*** `rosenbrock` + +```math +f(x) = \sum_{i=1}^{D-1} \left[100 (x_{i+1} - x_i^2)^2 + (x_i - 1)^2 \right] +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 1`$ + +## Salomon +***Function name:*** `salomon` + +```math +f(x) = 1 - \cos\left(2\pi\sqrt{\sum_{i=1}^D x_i^2} \right)+ 0.1 \sqrt{\sum_{i=1}^D x_i^2} +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Schaffer 2 +***Function name:*** `schaffer2` + +```math +f(x) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left[ 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right]^2 } +``` + +**Dimensions:** 2 + +**Global optimum:** $`f(x^*) = 0`$ for $`x^* = (0, 0)`$ + +## Schaffer 4 +***Function name:*** `schaffer4` + +```math +f(x) = 0.5 + \frac{ \cos^2 \left( \sin \left( \vert x_1^2 - x_2^2\vert \right) \right)- 0.5 }{ \left[ 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right]^2 } +``` + +**Dimensions:** 2 + +**Global optimum:** $`f(x^*) = 0.292579`$ for $`x^* = (0, \pm 1.25313) \text{or} (\pm 1.25313, 0)`$ + +## Schwefel +***Function name:*** `schwefel` + +```math +f(x) = 418.9829D - \sum_{i=1}^{D} x_i \sin(\sqrt{\lvert x_i \rvert}) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 420.9687`$ + +## Schwefel 2.21 +***Function name:*** `schwefel221` + +```math +f(x) = \max_{1 \leq i \leq D} \vert x_i\vert +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Schwefel 2.22 +***Function name:*** `schwefel222` + +```math +f(x) = \sum_{i=1}^{D} \lvert x_i \rvert +\prod_{i=1}^{D} \lvert x_i \rvert +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Sphere +***Function name:*** `sphere` + +```math +f(x) = \sum_{i=1}^D x_i^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Step +***Function name:*** `step` + +```math +f(x) = \sum_{i=1}^D \left( \lfloor \lvert x_i \rvert \rfloor \right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Step 2 +***Function name:*** `step2` + +```math +f(x) = \sum_{i=1}^D \left( \lfloor x_i + 0.5 \rfloor \right)^2 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = -0.5`$ + +## Styblinski-Tang +***Function name:*** `styblinski_tang` + +```math + +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = -39.16599 D`$ for $`x_i^* = -2.903534`$ + +## Trid +***Function name:*** `trid` + +```math +f(x) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1} +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = \frac{-D (D + 4) (D - 1)}{6}`$ for $`x_i^* = i (d + 1 - i)`$ + +## Weierstrass +***Function name:*** `weierstrass` + +```math +f(x) = \sum_{i=1}^D \left[ \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right] - D \sum_{k=0}^{k_{max}} a^k \cos \left(\pi b^k \right) +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + +## Whitley +***Function name:*** `whitley` + +```math +f(x) = \sum_{i=1}^D \sum_{j=1}^D \left[\frac{(100(x_i^2-x_j)^2 + (1-x_j)^2)^2}{4000} - \cos(100(x_i^2-x_j)^2 + (1-x_j)^2)+1\right] +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 1`$ + +## Zakharov +***Function name:*** `zakharov` + +```math +f(x) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4 +``` + +**Dimensions:** $D$ + +**Global optimum:** $`f(x^*) = 0`$ for $`x_i^* = 0`$ + + +# References + +[1] P. Ernesto and U. Diliman, [“MVF–Multivariate Test Functions Library in C for Unconstrained Global Optimization,”](http://www.geocities.ws/eadorio/mvf.pdf) University of the Philippines Diliman, Quezon City, 2005. + +[2] M. Jamil and X.-S. Yang, [“A literature survey of benchmark functions for global optimisation problems,”](https://arxiv.org/abs/1308.4008) International Journal of Mathematical Modelling and Numerical Optimisation, vol. 4, no. 2, p. 150, Jan. 2013, doi: 10.1504/ijmmno.2013.055204. + +[3] J. J. Liang, B. Y. Qu, and P. N. Suganthan, [“Problem definitions and evaluation criteria for the CEC 2014 special session and competition on single objective real-parameter numerical optimization,”](http://bee22.com/manual/tf_images/Liang%20CEC2014.pdf) Computational Intelligence Laboratory, Zhengzhou University, Zhengzhou China and Technical Report, Nanyang Technological University, Singapore, vol. 635, no. 2, 2013. + +[4] S. Surjanovic and D. Bingham, Virtual Library of Simulation Experiments: Test Functions and Datasets. Retrieved November 7, 2023, from https://www.sfu.ca/~ssurjano/. From 19d9807c61485f25dc1aa3c591ad106fca4a3724 Mon Sep 17 00:00:00 2001 From: zStupan Date: Tue, 7 Nov 2023 16:10:02 +0100 Subject: [PATCH 5/9] fix pinter formula --- Problems.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/Problems.md b/Problems.md index 84e1e95..d19d0df 100644 --- a/Problems.md +++ b/Problems.md @@ -153,10 +153,8 @@ f(x) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1} ***Function name:*** `pinter` ```math -\begin{equation} f(\mathbf{x}) = \sum_{i=1}^D ix_i^2 + \sum_{i=1}^D 20i \sin^2 A + \sum_{i=1}^D i \log_{10} (1 + iB^2),\, \text{where} -\end{equation} \begin{align} A &= (x_{i-1}\sin(x_i)+\sin(x_{i+1})) \\ From 89f02903bc602c3c48ce6b703bb8a40b6fb65905 Mon Sep 17 00:00:00 2001 From: zStupan <48752988+zStupan@users.noreply.github.com> Date: Tue, 7 Nov 2023 16:40:31 +0100 Subject: [PATCH 6/9] Update Problems.md - There were some rendering issues when doing \sqrt{\sum....} in ackley and salomon. Using \sum\nolimits instead. - Pinter was formatted wrong --- Problems.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Problems.md b/Problems.md index d19d0df..7bb3ef6 100644 --- a/Problems.md +++ b/Problems.md @@ -6,7 +6,7 @@ Bellow You'll find the definitions of all the test functions implemented in this ***Function name:*** `ackley` ```math -f(x) = -20 e^{-0.2 \sqrt{\frac{1}{D} \sum_{i=1}^D x_i^2}} - e^{\frac{1}{D} \sum_{i=1}^D \cos(2 \pi x_i)} + 20 + e +f(x) = -20 e^{-0.2 \sqrt{D^{-1} \sum\nolimits_{i=1}^D x_i^2}} - e^{D^{-1} \sum\nolimits_{i=1}^D \cos(2 \pi x_i)} + 20 + e ``` **Dimensions:** $D$ @@ -153,9 +153,9 @@ f(x) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1} ***Function name:*** `pinter` ```math -f(\mathbf{x}) = -\sum_{i=1}^D ix_i^2 + \sum_{i=1}^D 20i \sin^2 A + \sum_{i=1}^D i \log_{10} (1 + iB^2),\, \text{where} - +f(x) = \sum_{i=1}^D ix_i^2 + \sum_{i=1}^D 20i \sin^2 A + \sum_{i=1}^D i \log_{10} (1 + iB^2),\, \text{where} +``` +```math \begin{align} A &= (x_{i-1}\sin(x_i)+\sin(x_{i+1})) \\ B &= (x_{i-1}^2 - 2x_i + 3x_{i+1} - \cos(x_i) + 1) @@ -225,7 +225,7 @@ f(x) = \sum_{i=1}^{D-1} \left[100 (x_{i+1} - x_i^2)^2 + (x_i - 1)^2 \right] ***Function name:*** `salomon` ```math -f(x) = 1 - \cos\left(2\pi\sqrt{\sum_{i=1}^D x_i^2} \right)+ 0.1 \sqrt{\sum_{i=1}^D x_i^2} +f(x) = 1 - \cos\left(2\pi\sqrt{\sum\nolimits_{i=1}^D x_i^2} \right)+ 0.1 \sqrt{\sum\nolimits_{i=1}^D x_i^2} ``` **Dimensions:** $D$ From 582aeded15ac472d67cfe9987b98acea0f0a62e4 Mon Sep 17 00:00:00 2001 From: zStupan Date: Tue, 7 Nov 2023 16:42:37 +0100 Subject: [PATCH 7/9] minor fixes --- fireflyalgorithm/problems.py | 14 +++++++------- tests/test_problems.py | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/fireflyalgorithm/problems.py b/fireflyalgorithm/problems.py index 580cac7..c0718cc 100644 --- a/fireflyalgorithm/problems.py +++ b/fireflyalgorithm/problems.py @@ -55,9 +55,9 @@ def griewank(x): def katsuura(x): dim = len(x) k = np.atleast_2d(np.arange(1, 33)).T - i = np.arange(0, dim * 1) + i = np.arange(1, dim + 1) inner = np.round(2**k * x) * (2.0 ** (-k)) - return np.prod(np.sum(inner, axis=0) * (i + 1) + 1) + return np.prod(np.sum(inner, axis=0) * i + 1) def levy(x): @@ -158,7 +158,7 @@ def schaffer2(x): def schaffer4(x): return ( 0.5 - + (np.cos(np.sin(x[0] ** 2 - x[1] ** 2)) ** 2 - 0.5) + + (np.cos(np.sin(abs(x[0] ** 2 - x[1] ** 2))) ** 2 - 0.5) / (1 + 0.001 * (x[0] ** 2 + x[1] ** 2)) ** 2 ) @@ -170,11 +170,11 @@ def schwefel(x): ) -def schwefel21(x): +def schwefel221(x): return np.amax(np.abs(x)) -def schwefel22(x): +def schwefel222(x): return np.sum(np.abs(x)) + np.prod(np.abs(x)) @@ -253,8 +253,8 @@ def zakharov(x): "schaffer2": schaffer2, "schaffer4": schaffer4, "schwefel": schwefel, - "schwefel21": schwefel21, - "schwefel22": schwefel22, + "schwefel221": schwefel221, + "schwefel222": schwefel222, "sphere": sphere, "step": step, "step2": step2, diff --git a/tests/test_problems.py b/tests/test_problems.py index e00e479..c91fed9 100644 --- a/tests/test_problems.py +++ b/tests/test_problems.py @@ -25,8 +25,8 @@ schaffer2, schaffer4, schwefel, - schwefel21, - schwefel22, + schwefel221, + schwefel222, sphere, step, step2, @@ -64,8 +64,8 @@ def test_problem_factory(self): self.assertEqual(get_problem("schaffer2"), schaffer2) self.assertEqual(get_problem("schaffer4"), schaffer4) self.assertEqual(get_problem("schwefel"), schwefel) - self.assertEqual(get_problem("schwefel21"), schwefel21) - self.assertEqual(get_problem("schwefel22"), schwefel22) + self.assertEqual(get_problem("schwefel221"), schwefel221) + self.assertEqual(get_problem("schwefel222"), schwefel222) self.assertEqual(get_problem("sphere"), sphere) self.assertEqual(get_problem("step"), step) self.assertEqual(get_problem("step2"), step2) @@ -175,11 +175,11 @@ def test_schwefel(self): def test_schwefel21(self): x = np.zeros(5) - self.assertAlmostEqual(schwefel21(x), 0.0) + self.assertAlmostEqual(schwefel221(x), 0.0) def test_schwefel22(self): x = np.zeros(5) - self.assertAlmostEqual(schwefel22(x), 0.0) + self.assertAlmostEqual(schwefel222(x), 0.0) def test_sphere(self): x = np.zeros(5) @@ -190,8 +190,8 @@ def test_step(self): self.assertAlmostEqual(step(x), 0.0) def test_step2(self): - x = np.full(5, 0.5) - self.assertAlmostEqual(step(x), 0.0) + x = np.full(5, -0.5) + self.assertAlmostEqual(step2(x), 0.0) def test_styblinski_tang(self): x = np.full(5, -2.903534018185960) From 1397b1e6a55c3c85fece1c1baeabaa317ea40a4a Mon Sep 17 00:00:00 2001 From: zStupan Date: Tue, 7 Nov 2023 17:01:45 +0100 Subject: [PATCH 8/9] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 8516155..9fcb701 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,19 @@ best = FA.run(function=sphere, dim=10, lb=-5, ub=5, max_evals=10000) print(best) ``` +### Test functions + +In the `fireflyalgorithm.problems` module, you can find the implementations of 33 popular optimization test problems. Additionally, the module provides a utility function, `get_problem`, that allows you to retrieve a specific optimization problem function by providing its name as a string: + +```python +from fireflyalgorithm.problems import get_problem + +# same as from fireflyalgorithm.problems import rosenbrock +rosenbrock = get_problem('rosenbrock') +``` + +For more information about the implemented test functions, [click here](Problems.md) + ### Command line interface The package also comes with a simple command line interface which allows you to evaluate the algorithm on several From d380dd5705578045beef75e24efff039a607571d Mon Sep 17 00:00:00 2001 From: Iztok Fister Jr Date: Fri, 10 Nov 2023 09:36:33 +0100 Subject: [PATCH 9/9] bump version --- fireflyalgorithm/__init__.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fireflyalgorithm/__init__.py b/fireflyalgorithm/__init__.py index 627a2d6..35ed0d4 100644 --- a/fireflyalgorithm/__init__.py +++ b/fireflyalgorithm/__init__.py @@ -2,4 +2,4 @@ __all__ = ["FireflyAlgorithm"] -__version__ = "0.4.0" +__version__ = "0.4.1" diff --git a/pyproject.toml b/pyproject.toml index 9476ee2..3fdb198 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fireflyalgorithm" -version = "0.4.0" +version = "0.4.1" description = "Implementation of Firefly Algorithm in Python" authors = ["Iztok Fister Jr. ", "Luka Pečnik ", "Žiga Stupan "] license = "MIT"