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

@@ 210-230 (lines=21) @@
207
		"""
208
		return r"""Fister Jr., Iztok and Fister, Dusan and Yang, Xin-She. "A Hybrid Bat Algorithm". Elektrotehniski vestnik, 2013. 1-7."""
209
210
	@staticmethod
211
	def typeParameters():
212
		r"""Get dictionary with functions for checking values of parameters.
213
214
		Returns:
215
			Dict[str, Callable]: TODO
216
217
		See Also:
218
			* :func:`NiaPy.algorithms.basic.BatAlgorithm.typeParameters`
219
		"""
220
		d = AdaptiveBatAlgorithm.typeParameters()
221
		d.pop('A_s', None), d.pop('A_min', None)
222
		d.update({
223
			'A_l': lambda x: isinstance(x, (float, int)) and x >= 0,
224
			'A_u': lambda x: isinstance(x, (float, int)) and x >= 0,
225
			'r_l': lambda x: isinstance(x, (float, int)) and x >= 0,
226
			'r_u': lambda x: isinstance(x, (float, int)) and x >= 0,
227
			'tao_1': lambda x: isinstance(x, (float, int)) and 0 <= x <= 1,
228
			'tao_2': lambda x: isinstance(x, (float, int)) and 0 <= x <= 1
229
		})
230
		return d
231
232
	def setParameters(self, A_l=0.001, A_u=0.1, r_l=0.1, r_u=0.9, tao_1=0.5, tao_2=0.5, **ukwargs):
233
		r"""Set core parameters of HybridBatAlgorithm algorithm.