| @@ 52-71 (lines=20) @@ | ||
| 49 | Main reference: Yang, Xin-She. Nature-Inspired Metaheuristic Algorithms, Luniver Press, 2008. |
|
| 50 | """ |
|
| 51 | ||
| 52 | @staticmethod |
|
| 53 | def typeParameters(): |
|
| 54 | r"""TODO. |
|
| 55 | ||
| 56 | Returns: |
|
| 57 | Dict[str, Callable]: |
|
| 58 | * alpha (Callable[[Union[float, int]], bool]): TODO. |
|
| 59 | * betamin (Callable[[Union[float, int]], bool]): TODO. |
|
| 60 | * gamma (Callable[[Union[float, int]], bool]): TODO. |
|
| 61 | ||
| 62 | See Also: |
|
| 63 | * :func:`NiaPy.algorithms.Algorithm.typeParameters` |
|
| 64 | """ |
|
| 65 | d = Algorithm.typeParameters() |
|
| 66 | d.update({ |
|
| 67 | 'alpha': lambda x: isinstance(x, (float, int)) and x > 0, |
|
| 68 | 'betamin': lambda x: isinstance(x, (float, int)) and x > 0, |
|
| 69 | 'gamma': lambda x: isinstance(x, (float, int)) and x > 0, |
|
| 70 | }) |
|
| 71 | return d |
|
| 72 | ||
| 73 | def setParameters(self, NP=20, alpha=1, betamin=1, gamma=2, **ukwargs): |
|
| 74 | r"""Set the parameters of the algorithm. |
|
| @@ 255-272 (lines=18) @@ | ||
| 252 | """ |
|
| 253 | 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.""" |
|
| 254 | ||
| 255 | @staticmethod |
|
| 256 | def typeParameters(): |
|
| 257 | r"""Get dictionary with functions for checking values of parameters. |
|
| 258 | ||
| 259 | Returns: |
|
| 260 | Dict[str, Callable]: |
|
| 261 | * F (Callable[[Union[float, int]], bool]): Check for correct value of parameter. |
|
| 262 | * CR (Callable[[float], bool]): Check for correct value of parameter. |
|
| 263 | ||
| 264 | See Also: |
|
| 265 | * :func:`NiaPy.algorithms.Algorithm.typeParameters` |
|
| 266 | """ |
|
| 267 | d = Algorithm.typeParameters() |
|
| 268 | d.update({ |
|
| 269 | 'F': lambda x: isinstance(x, (float, int)) and 0 < x <= 2, |
|
| 270 | 'CR': lambda x: isinstance(x, float) and 0 <= x <= 1 |
|
| 271 | }) |
|
| 272 | return d |
|
| 273 | ||
| 274 | def setParameters(self, NP=50, F=1, CR=0.8, CrossMutt=CrossRand1, **ukwargs): |
|
| 275 | r"""Set the algorithm parameters. |
|
| @@ 52-69 (lines=18) @@ | ||
| 49 | """ |
|
| 50 | 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""" |
|
| 51 | ||
| 52 | @staticmethod |
|
| 53 | def typeParameters(): |
|
| 54 | r"""TODO. |
|
| 55 | ||
| 56 | Returns: |
|
| 57 | Dict[str, Callable]: |
|
| 58 | * G_0 (Callable[[Union[int, float]], bool]): TODO |
|
| 59 | * epsilon (Callable[[float], bool]): TODO |
|
| 60 | ||
| 61 | See Also: |
|
| 62 | * :func:`NiaPy.algorithms.algorithm.Algorithm.typeParameters` |
|
| 63 | """ |
|
| 64 | d = Algorithm.typeParameters() |
|
| 65 | d.update({ |
|
| 66 | 'G_0': lambda x: isinstance(x, (int, float)) and x >= 0, |
|
| 67 | 'epsilon': lambda x: isinstance(x, float) and 0 < x < 1 |
|
| 68 | }) |
|
| 69 | return d |
|
| 70 | ||
| 71 | def setParameters(self, NP=40, G_0=2.467, epsilon=1e-17, **ukwargs): |
|
| 72 | r"""Set the algorithm parameters. |
|
| @@ 46-63 (lines=18) @@ | ||
| 43 | """ |
|
| 44 | Name = ['FlowerPollinationAlgorithm', 'FPA'] |
|
| 45 | ||
| 46 | @staticmethod |
|
| 47 | def typeParameters(): |
|
| 48 | r"""TODO. |
|
| 49 | ||
| 50 | Returns: |
|
| 51 | Dict[str, Callable]: |
|
| 52 | * p (function): TODO |
|
| 53 | * beta (function): TODO |
|
| 54 | ||
| 55 | See Also: |
|
| 56 | * :func:`NiaPy.algorithms.Algorithm.typeParameters` |
|
| 57 | """ |
|
| 58 | d = Algorithm.typeParameters() |
|
| 59 | d.update({ |
|
| 60 | 'p': lambda x: isinstance(x, float) and 0 <= x <= 1, |
|
| 61 | 'beta': lambda x: isinstance(x, (float, int)) and x > 0, |
|
| 62 | }) |
|
| 63 | return d |
|
| 64 | ||
| 65 | def setParameters(self, NP=25, p=0.35, beta=1.5, **ukwargs): |
|
| 66 | r"""Set core parameters of FlowerPollinationAlgorithm algorithm. |
|
| @@ 60-76 (lines=17) @@ | ||
| 57 | 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. |
|
| 58 | """ |
|
| 59 | ||
| 60 | @staticmethod |
|
| 61 | def typeParameters(): |
|
| 62 | r"""Get dictionary with functions for checking values of parameters. |
|
| 63 | ||
| 64 | Returns: |
|
| 65 | Dict[str, Callable]: |
|
| 66 | * PAR (Callable[[float], bool]): Checks if partition parameter has a proper value. |
|
| 67 | * PER (Callable[[float], bool]): Checks if period parameter has a proper value. |
|
| 68 | See Also: |
|
| 69 | * :func:`NiaPy.algorithms.algorithm.Algorithm.typeParameters` |
|
| 70 | """ |
|
| 71 | d = Algorithm.typeParameters() |
|
| 72 | d.update({ |
|
| 73 | 'PAR': lambda x: isinstance(x, float) and x > 0, |
|
| 74 | 'PER': lambda x: isinstance(x, float) and x > 0 |
|
| 75 | }) |
|
| 76 | return d |
|
| 77 | ||
| 78 | def setParameters(self, NP=20, PAR=5.0 / 12.0, PER=1.2, **ukwargs): |
|
| 79 | r"""Set the parameters of the algorithm. |
|