Code Duplication    Length = 10-22 lines in 2 locations

NiaPy/algorithms/basic/gso.py 1 location

@@ 62-83 (lines=22) @@
59
		"""
60
		return r"""Kaipa, Krishnanand N., and Debasish Ghose. Glowworm swarm optimization: theory, algorithms, and applications. Vol. 698. Springer, 2017."""
61
62
	@staticmethod
63
	def typeParameters():
64
		r"""Get dictionary with functions for checking values of parameters.
65
66
		Returns:
67
			Dict[str, Callable]:
68
				* n (Callable[[int], bool])
69
				* l0 (Callable[[Union[float, int]], bool])
70
				* nt (Callable[[Union[float, int]], bool])
71
				* rho (Callable[[Union[float, int]], bool])
72
				* gamma (Callable[[float], bool])
73
				* beta (Callable[[float], bool])
74
				* s (Callable[[float], bool])
75
		"""
76
		return {
77
			'n': lambda x: isinstance(x, int) and x > 0,
78
			'l0': lambda x: isinstance(x, (float, int)) and x > 0,
79
			'nt': lambda x: isinstance(x, (float, int)) and x > 0,
80
			'rho': lambda x: isinstance(x, float) and 0 < x < 1,
81
			'gamma': lambda x: isinstance(x, float) and 0 < x < 1,
82
			'beta': lambda x: isinstance(x, float) and x > 0,
83
			's': lambda x: isinstance(x, float) and x > 0
84
		}
85
86
	def setParameters(self, n=25, l0=5, nt=5, rho=0.4, gamma=0.6, beta=0.08, s=0.03, Distance=euclidean, **ukwargs):

NiaPy/algorithms/basic/cso.py 1 location

@@ 29-38 (lines=10) @@
26
    """
27
    Name = ['CatSwarmOptimization', 'CSO']
28
29
    @staticmethod
30
    def typeParameters(): return {
31
        'NP': lambda x: isinstance(x, int) and x > 0,
32
        'MR': lambda x: isinstance(x, (int, float)) and 0 <= x <= 1,
33
        'C1': lambda x: isinstance(x, (int, float)) and x >= 0,
34
        'SMP': lambda x: isinstance(x, int) and x > 0,
35
        'SPC': lambda x: isinstance(x, bool),
36
        'CDC': lambda x: isinstance(x, (int, float)) and 0 <= x <= 1,
37
        'SRD': lambda x: isinstance(x, (int, float)) and 0 <= x <= 1,
38
        'vMax': lambda x: isinstance(x, (int, float)) and x > 0
39
    }
40
41
    def setParameters(self, NP=30, MR=0.1, C1=2.05, SMP=3, SPC=True, CDC=0.85, SRD=0.2, vMax=1.9, **ukwargs):