Code Duplication    Length = 20-26 lines in 3 locations

NiaPy/algorithms/basic/mke.py 1 location

@@ 97-116 (lines=20) @@
94
		"""
95
		return r"""Zhenyu Meng, Jeng-Shyang Pan, Monkey King Evolution: A new memetic evolutionary algorithm and its application in vehicle fuel consumption optimization, Knowledge-Based Systems, Volume 97, 2016, Pages 144-157, ISSN 0950-7051, https://doi.org/10.1016/j.knosys.2016.01.009."""
96
97
	@staticmethod
98
	def typeParameters():
99
		r"""Get dictionary with functions for checking values of parameters.
100
101
		Returns:
102
			Dict[str, Callable]:
103
				* F (Callable[[int], bool])
104
				* R (Callable[[Union[int, float]], bool])
105
				* C (Callable[[Union[int, float]], bool])
106
				* FC (Callable[[Union[int, float]], bool])
107
		"""
108
		d = Algorithm.typeParameters()
109
		d.update({
110
			'NP': lambda x: isinstance(x, int) and x > 0,
111
			'F': lambda x: isinstance(x, (float, int)) and x > 0,
112
			'R': lambda x: isinstance(x, (float, int)) and x > 0,
113
			'C': lambda x: isinstance(x, int) and x > 0,
114
			'FC': lambda x: isinstance(x, (float, int)) and x > 0
115
		})
116
		return d
117
118
	def setParameters(self, NP=40, F=0.7, R=0.3, C=3, FC=0.5, **ukwargs):
119
		r"""Set Monkey King Evolution v1 algorithms static parameters.

NiaPy/algorithms/basic/bea.py 1 location

@@ 58-83 (lines=26) @@
55
		"""
56
		return r"""DT Pham, A Ghanbarzadeh, E Koc, S Otri, S Rahim, and M Zaidi. The bees algorithm-a novel tool for complex optimisation problems. In Proceedings of the 2nd Virtual International Conference on Intelligent Production Machines and Systems (IPROMS 2006), pages 454–459, 2006"""
57
58
	@staticmethod
59
	def typeParameters():
60
		r"""Get dictionary with functions for checking values of parameters.
61
62
		Returns:
63
			 Dict[str, Callable]:
64
				  * NP (Callable[[int], bool]): Checks if number of bees parameter has a proper value.
65
				  * m (Callable[[int], bool]): Checks if number of selected sites parameter has a proper value.
66
				  * e (Callable[[int], bool]): Checks if number of elite selected sites parameter has a proper value.
67
				  * nep (Callable[[int], bool]): Checks if number of elite bees parameter has a proper value.
68
				  * nsp (Callable[[int], bool]): Checks if number of other bees parameter has a proper value.
69
				  * ngh (Callable[[float], bool]): Checks if size of patches parameter has a proper value.
70
71
		See Also:
72
			 * :func:`NiaPy.algorithms.algorithm.Algorithm.typeParameters`
73
		"""
74
		d = Algorithm.typeParameters()
75
		d.update({
76
			'NP': lambda x: isinstance(x, int) and x > 0,
77
			'm': lambda x: isinstance(x, int) and x > 0,
78
			'e': lambda x: isinstance(x, int) and x > 0,
79
			'nep': lambda x: isinstance(x, int) and x > 0,
80
			'nsp': lambda x: isinstance(x, int) and x > 0,
81
			'ngh': lambda x: isinstance(x, float) and x > 0
82
		})
83
		return d
84
85
	def setParameters(self, NP=40, m=5, e=4, ngh=1, nep=4, nsp=2, **ukwargs):
86
		r"""Set the parameters of the algorithm.

NiaPy/algorithms/basic/foa.py 1 location

@@ 59-82 (lines=24) @@
56
		"""
57
		return r"""Manizheh Ghaemi, Mohammad-Reza Feizi-Derakhshi, Forest Optimization Algorithm, Expert Systems with Applications, Volume 41, Issue 15, 2014, Pages 6676-6687, ISSN 0957-4174, https://doi.org/10.1016/j.eswa.2014.05.009."""
58
59
	@staticmethod
60
	def typeParameters():
61
		r"""Get dictionary with functions for checking values of parameters.
62
63
		Returns:
64
			 Dict[str, Callable]:
65
				  * lt (Callable[[int], bool]): Checks if life time parameter has a proper value.
66
				  * al (Callable[[int], bool]): Checks if area limit parameter has a proper value.
67
				  * lsc (Callable[[int], bool]): Checks if local seeding changes parameter has a proper value.
68
				  * gsc (Callable[[int], bool]): Checks if global seeding changes parameter has a proper value.
69
				  * tr (Callable[[float], bool]): Checks if transfer rate parameter has a proper value.
70
71
		See Also:
72
			 * :func:`NiaPy.algorithms.algorithm.Algorithm.typeParameters`
73
		"""
74
		d = Algorithm.typeParameters()
75
		d.update({
76
			'lt': lambda x: isinstance(x, int) and x > 0,
77
			'al': lambda x: isinstance(x, int) and x > 0,
78
			'lsc': lambda x: isinstance(x, int) and x > 0,
79
			'gsc': lambda x: isinstance(x, int) and x > 0,
80
			'tr': lambda x: isinstance(x, float) and 0 <= x <= 1,
81
		})
82
		return d
83
84
	def setParameters(self, NP=10, lt=3, al=10, lsc=1, gsc=1, tr=0.3, **ukwargs):
85
		r"""Set the parameters of the algorithm.