Code Duplication    Length = 7-18 lines in 3 locations

NiaPy/algorithms/basic/es.py 1 location

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

NiaPy/algorithms/basic/hs.py 1 location

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

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