| @@ 53-72 (lines=20) @@ | ||
| 50 | Main reference: Yang, Xin-She. Nature-Inspired Metaheuristic Algorithms, Luniver Press, 2008. |
|
| 51 | """ |
|
| 52 | ||
| 53 | @staticmethod |
|
| 54 | def typeParameters(): |
|
| 55 | r"""TODO. |
|
| 56 | ||
| 57 | Returns: |
|
| 58 | Dict[str, Callable]: |
|
| 59 | * alpha (Callable[[Union[float, int]], bool]): TODO. |
|
| 60 | * betamin (Callable[[Union[float, int]], bool]): TODO. |
|
| 61 | * gamma (Callable[[Union[float, int]], bool]): TODO. |
|
| 62 | ||
| 63 | See Also: |
|
| 64 | * :func:`NiaPy.algorithms.Algorithm.typeParameters` |
|
| 65 | """ |
|
| 66 | d = Algorithm.typeParameters() |
|
| 67 | d.update({ |
|
| 68 | 'alpha': lambda x: isinstance(x, (float, int)) and x > 0, |
|
| 69 | 'betamin': lambda x: isinstance(x, (float, int)) and x > 0, |
|
| 70 | 'gamma': lambda x: isinstance(x, (float, int)) and x > 0, |
|
| 71 | }) |
|
| 72 | return d |
|
| 73 | ||
| 74 | def setParameters(self, NP=20, alpha=1, betamin=1, gamma=2, **ukwargs): |
|
| 75 | r"""Set the parameters of the algorithm. |
|
| @@ 256-273 (lines=18) @@ | ||
| 253 | """ |
|
| 254 | return r"""Storn, Rainer, and Kenneth Price. "Differential evolution - a simple and efficient heuristic for global optimization over continuous spaces." Journal of global optimization 11.4 (1997): 341-359.""" |
|
| 255 | ||
| 256 | @staticmethod |
|
| 257 | def typeParameters(): |
|
| 258 | r"""Get dictionary with functions for checking values of parameters. |
|
| 259 | ||
| 260 | Returns: |
|
| 261 | Dict[str, Callable]: |
|
| 262 | * F (Callable[[Union[float, int]], bool]): Check for correct value of parameter. |
|
| 263 | * CR (Callable[[float], bool]): Check for correct value of parameter. |
|
| 264 | ||
| 265 | See Also: |
|
| 266 | * :func:`NiaPy.algorithms.Algorithm.typeParameters` |
|
| 267 | """ |
|
| 268 | d = Algorithm.typeParameters() |
|
| 269 | d.update({ |
|
| 270 | 'F': lambda x: isinstance(x, (float, int)) and 0 < x <= 2, |
|
| 271 | 'CR': lambda x: isinstance(x, float) and 0 <= x <= 1 |
|
| 272 | }) |
|
| 273 | return d |
|
| 274 | ||
| 275 | def setParameters(self, NP=50, F=1, CR=0.8, CrossMutt=CrossRand1, **ukwargs): |
|
| 276 | r"""Set the algorithm parameters. |
|
| @@ 53-70 (lines=18) @@ | ||
| 50 | """ |
|
| 51 | return r"""Esmat Rashedi, Hossein Nezamabadi-pour, Saeid Saryazdi, GSA: A Gravitational Search Algorithm, Information Sciences, Volume 179, Issue 13, 2009, Pages 2232-2248, ISSN 0020-0255""" |
|
| 52 | ||
| 53 | @staticmethod |
|
| 54 | def typeParameters(): |
|
| 55 | r"""TODO. |
|
| 56 | ||
| 57 | Returns: |
|
| 58 | Dict[str, Callable]: |
|
| 59 | * G_0 (Callable[[Union[int, float]], bool]): TODO |
|
| 60 | * epsilon (Callable[[float], bool]): TODO |
|
| 61 | ||
| 62 | See Also: |
|
| 63 | * :func:`NiaPy.algorithms.algorithm.Algorithm.typeParameters` |
|
| 64 | """ |
|
| 65 | d = Algorithm.typeParameters() |
|
| 66 | d.update({ |
|
| 67 | 'G_0': lambda x: isinstance(x, (int, float)) and x >= 0, |
|
| 68 | 'epsilon': lambda x: isinstance(x, float) and 0 < x < 1 |
|
| 69 | }) |
|
| 70 | return d |
|
| 71 | ||
| 72 | def setParameters(self, NP=40, G_0=2.467, epsilon=1e-17, **ukwargs): |
|
| 73 | r"""Set the algorithm parameters. |
|
| @@ 47-64 (lines=18) @@ | ||
| 44 | """ |
|
| 45 | Name = ['FlowerPollinationAlgorithm', 'FPA'] |
|
| 46 | ||
| 47 | @staticmethod |
|
| 48 | def typeParameters(): |
|
| 49 | r"""TODO. |
|
| 50 | ||
| 51 | Returns: |
|
| 52 | Dict[str, Callable]: |
|
| 53 | * p (function): TODO |
|
| 54 | * beta (function): TODO |
|
| 55 | ||
| 56 | See Also: |
|
| 57 | * :func:`NiaPy.algorithms.Algorithm.typeParameters` |
|
| 58 | """ |
|
| 59 | d = Algorithm.typeParameters() |
|
| 60 | d.update({ |
|
| 61 | 'p': lambda x: isinstance(x, float) and 0 <= x <= 1, |
|
| 62 | 'beta': lambda x: isinstance(x, (float, int)) and x > 0, |
|
| 63 | }) |
|
| 64 | return d |
|
| 65 | ||
| 66 | def setParameters(self, NP=25, p=0.35, beta=1.5, **ukwargs): |
|
| 67 | r"""Set core parameters of FlowerPollinationAlgorithm algorithm. |
|
| @@ 61-77 (lines=17) @@ | ||
| 58 | Main reference: Wang, Gai-Ge & Deb, Suash & Cui, Zhihua. (2015). Monarch Butterfly Optimization. Neural Computing and Applications. 10.1007/s00521-015-1923-y. , https://www.researchgate.net/publication/275964443_Monarch_Butterfly_Optimization. |
|
| 59 | """ |
|
| 60 | ||
| 61 | @staticmethod |
|
| 62 | def typeParameters(): |
|
| 63 | r"""Get dictionary with functions for checking values of parameters. |
|
| 64 | ||
| 65 | Returns: |
|
| 66 | Dict[str, Callable]: |
|
| 67 | * PAR (Callable[[float], bool]): Checks if partition parameter has a proper value. |
|
| 68 | * PER (Callable[[float], bool]): Checks if period parameter has a proper value. |
|
| 69 | See Also: |
|
| 70 | * :func:`NiaPy.algorithms.algorithm.Algorithm.typeParameters` |
|
| 71 | """ |
|
| 72 | d = Algorithm.typeParameters() |
|
| 73 | d.update({ |
|
| 74 | 'PAR': lambda x: isinstance(x, float) and x > 0, |
|
| 75 | 'PER': lambda x: isinstance(x, float) and x > 0 |
|
| 76 | }) |
|
| 77 | return d |
|
| 78 | ||
| 79 | def setParameters(self, NP=20, PAR=5.0 / 12.0, PER=1.2, **ukwargs): |
|
| 80 | r"""Set the parameters of the algorithm. |
|