Code Duplication    Length = 7-18 lines in 3 locations

NiaPy/algorithms/basic/hs.py 1 location

@@ 59-74 (lines=16) @@
56
		"""
57
		return r"""Yang, Xin-She. "Harmony search as a metaheuristic algorithm." Music-inspired harmony search algorithm. Springer, Berlin, Heidelberg, 2009. 1-14."""
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
							 * HMS (Callable[[int], bool])
66
							 * r_accept (Callable[[float], bool])
67
							 * r_pa (Callable[[float], bool])
68
							 * b_range (Callable[[float], bool])
69
		"""
70
		return {
71
			"HMS": lambda x: isinstance(x, int) and x > 0,
72
			"r_accept": lambda x: isinstance(x, float) and 0 < x < 1,
73
			"r_pa": lambda x: isinstance(x, float) and 0 < x < 1,
74
			"b_range": lambda x: isinstance(x, (int, float)) and x > 0
75
		}
76
77
	def setParameters(self, HMS=30, r_accept=0.7, r_pa=0.35, b_range=1.42, **ukwargs):

NiaPy/algorithms/basic/fwa.py 1 location

@@ 157-163 (lines=7) @@
154
		"""
155
		return r"""Tan, Ying. "Firework Algorithm: A Novel Swarm Intelligence Optimization Method." (2015)."""
156
157
	@staticmethod
158
	def typeParameters(): return {
159
			'N': lambda x: isinstance(x, int) and x > 0,
160
			'm': lambda x: isinstance(x, int) and x > 0,
161
			'a': lambda x: isinstance(x, (int, float)) and x > 0,
162
			'b': lambda x: isinstance(x, (int, float)) and x > 0,
163
			'epsilon': lambda x: isinstance(x, float) and 0 < x < 1
164
	}
165
166
	def setParameters(self, N=40, m=40, a=1, b=2, A=40, epsilon=1e-31, **ukwargs):

NiaPy/algorithms/basic/es.py 1 location

@@ 67-84 (lines=18) @@
64
	"""
65
	Name = ['EvolutionStrategy1p1', 'EvolutionStrategy(1+1)', 'ES(1+1)']
66
67
	@staticmethod
68
	def typeParameters():
69
		r"""Get dictionary with functions for checking values of parameters.
70
71
		Returns:
72
			Dict[str, Callable]:
73
				* mu (Callable[[int], bool])
74
				* k (Callable[[int], bool])
75
				* c_a (Callable[[Union[float, int]], bool])
76
				* c_r (Callable[[Union[float, int]], bool])
77
				* epsilon (Callable[[float], bool])
78
		"""
79
		return {
80
			'mu': lambda x: isinstance(x, int) and x > 0,
81
			'k': lambda x: isinstance(x, int) and x > 0,
82
			'c_a': lambda x: isinstance(x, (float, int)) and x > 1,
83
			'c_r': lambda x: isinstance(x, (float, int)) and 0 < x < 1,
84
			'epsilon': lambda x: isinstance(x, float) and 0 < x < 1
85
		}
86
87
	def setParameters(self, mu=1, k=10, c_a=1.1, c_r=0.5, epsilon=1e-20, **ukwargs):