Code Duplication    Length = 20-24 lines in 2 locations

NiaPy/algorithms/basic/foa.py 1 location

@@ 53-76 (lines=24) @@
50
    Main reference: Manizheh Ghaemi, Mohammad-Reza Feizi-Derakhshi, Forest Optimization Algorithm, Expert Systems with Applications, Volume 41, Issue 15, 2014, Pages 6676-6687, ISSN 0957-4174, https://doi.org/10.1016/j.eswa.2014.05.009.
51
    """
52
53
    @staticmethod
54
    def typeParameters():
55
        r"""Get dictionary with functions for checking values of parameters.
56
57
        Returns:
58
            Dict[str, Callable]:
59
                * lt (Callable[[int], bool]): Checks if life time parameter has a proper value.
60
                * al (Callable[[int], bool]): Checks if area limit parameter has a proper value.
61
                * lsc (Callable[[int], bool]): Checks if local seeding changes parameter has a proper value.
62
                * gsc (Callable[[int], bool]): Checks if global seeding changes parameter has a proper value.
63
                * tr (Callable[[float], bool]): Checks if transfer rate parameter has a proper value.
64
65
        See Also:
66
            * :func:`NiaPy.algorithms.algorithm.Algorithm.typeParameters`
67
        """
68
        d = Algorithm.typeParameters()
69
        d.update({
70
            'lt': lambda x: isinstance(x, int) and x > 0,
71
            'al': lambda x: isinstance(x, int) and x > 0,
72
            'lsc': lambda x: isinstance(x, int) and x > 0,
73
            'gsc': lambda x: isinstance(x, int) and x > 0,
74
            'tr': lambda x: isinstance(x, float) and 0 <= x <= 1,
75
        })
76
        return d
77
78
    def setParameters(self, NP=10, lt=3, al=10, lsc=1, gsc=1, tr=0.3, **ukwargs):
79
        r"""Set the parameters of the algorithm.

NiaPy/algorithms/basic/mke.py 1 location

@@ 98-117 (lines=20) @@
95
		"""
96
		return r"""Zhenyu Meng, Jeng-Shyang Pan, Monkey King Evolution: A new memetic evolutionary algorithm and its application in vehicle fuel consumption optimization, Knowledge-Based Systems, Volume 97, 2016, Pages 144-157, ISSN 0950-7051, https://doi.org/10.1016/j.knosys.2016.01.009."""
97
98
	@staticmethod
99
	def typeParameters():
100
		r"""Get dictionary with functions for checking values of parameters.
101
102
		Returns:
103
			Dict[str, Callable]:
104
				* F (Callable[[int], bool])
105
				* R (Callable[[Union[int, float]], bool])
106
				* C (Callable[[Union[int, float]], bool])
107
				* FC (Callable[[Union[int, float]], bool])
108
		"""
109
		d = Algorithm.typeParameters()
110
		d.update({
111
			'NP': lambda x: isinstance(x, int) and x > 0,
112
			'F': lambda x: isinstance(x, (float, int)) and x > 0,
113
			'R': lambda x: isinstance(x, (float, int)) and x > 0,
114
			'C': lambda x: isinstance(x, int) and x > 0,
115
			'FC': lambda x: isinstance(x, (float, int)) and x > 0
116
		})
117
		return d
118
119
	def setParameters(self, NP=40, F=0.7, R=0.3, C=3, FC=0.5, **ukwargs):
120
		r"""Set Monkey King Evolution v1 algorithms static parameters.