Code Duplication    Length = 21-28 lines in 2 locations

NiaPy/algorithms/basic/ca.py 1 location

@@ 159-186 (lines=28) @@
156
		"""
157
		return r'''Ali, Ramzy. (2016). Novel Optimization Algorithm Inspired by Camel Traveling Behavior. Iraq J. Electrical and Electronic Engineering. 12. 167-177.'''
158
159
	@staticmethod
160
	def typeParameters():
161
		r"""Get dictionary with functions for checking values of parameters.
162
163
		Returns:
164
			Dict[str, Callable]:
165
				* omega (Callable[[Union[int, float]], bool])
166
				* mu (Callable[[float], bool])
167
				* alpha (Callable[[float], bool])
168
				* S_init (Callable[[Union[float, int]], bool])
169
				* E_init (Callable[[Union[float, int]], bool])
170
				* T_min (Callable[[Union[float, int], bool])
171
				* T_max (Callable[[Union[float, int], bool])
172
173
		See Also:
174
			* :func:`NiaPy.algorithms.Algorithm.typeParameters`
175
		"""
176
		d = Algorithm.typeParameters()
177
		d.update({
178
			'omega': lambda x: isinstance(x, (float, int)),
179
			'mu': lambda x: isinstance(x, float) and 0 <= x <= 1,
180
			'alpha': lambda x: isinstance(x, float) and 0 <= x <= 1,
181
			'S_init': lambda x: isinstance(x, (float, int)) and x > 0,
182
			'E_init': lambda x: isinstance(x, (float, int)) and x > 0,
183
			'T_min': lambda x: isinstance(x, (float, int)) and x > 0,
184
			'T_max': lambda x: isinstance(x, (float, int)) and x > 0
185
		})
186
		return d
187
188
	def setParameters(self, NP=50, omega=0.25, mu=0.5, alpha=0.5, S_init=10, E_init=10, T_min=-10, T_max=10, **ukwargs):
189
		r"""Set the arguments of an algorithm.

NiaPy/algorithms/modified/saba.py 1 location

@@ 229-249 (lines=21) @@
226
		"""
227
		return r"""Fister Jr., Iztok and Fister, Dusan and Yang, Xin-She. "A Hybrid Bat Algorithm". Elektrotehniski vestnik, 2013. 1-7."""
228
229
	@staticmethod
230
	def typeParameters():
231
		r"""Get dictionary with functions for checking values of parameters.
232
233
		Returns:
234
			Dict[str, Callable]: TODO
235
236
		See Also:
237
			* :func:`NiaPy.algorithms.basic.BatAlgorithm.typeParameters`
238
		"""
239
		d = AdaptiveBatAlgorithm.typeParameters()
240
		d.pop('A', None), d.pop('r', None)
241
		d.update({
242
			'A_l': lambda x: isinstance(x, (float, int)) and x >= 0,
243
			'A_u': lambda x: isinstance(x, (float, int)) and x >= 0,
244
			'r_l': lambda x: isinstance(x, (float, int)) and x >= 0,
245
			'r_u': lambda x: isinstance(x, (float, int)) and x >= 0,
246
			'tao_1': lambda x: isinstance(x, (float, int)) and 0 <= x <= 1,
247
			'tao_2': lambda x: isinstance(x, (float, int)) and 0 <= x <= 1
248
		})
249
		return d
250
251
	def setParameters(self, A_l=0.9, A_u=1.0, r_l=0.001, r_u=0.1, tao_1=0.1, tao_2=0.1, **ukwargs):
252
		r"""Set core parameters of HybridBatAlgorithm algorithm.