Code Duplication    Length = 20-26 lines in 3 locations

NiaPy/algorithms/basic/bea.py 1 location

@@ 54-79 (lines=26) @@
51
        Year: 2006
52
        Main reference: DT Pham, A Ghanbarzadeh, E Koc, S Otri, S Rahim, and M Zaidi. The bees algorithm-a novel tool for complex optimisation problems. In Proceedings of the 2nd Virtual International Conference on Intelligent Production Machines and Systems (IPROMS 2006), pages 454–459, 2006
53
    """
54
    @staticmethod
55
    def typeParameters():
56
        r"""Get dictionary with functions for checking values of parameters.
57
58
        Returns:
59
            Dict[str, Callable]:
60
                * NP (Callable[[int], bool]): Checks if number of bees parameter has a proper value.
61
                * m (Callable[[int], bool]): Checks if number of selected sites parameter has a proper value.
62
                * e (Callable[[int], bool]): Checks if number of elite selected sites parameter has a proper value.
63
                * nep (Callable[[int], bool]): Checks if number of elite bees parameter has a proper value.
64
                * nsp (Callable[[int], bool]): Checks if number of other bees parameter has a proper value.
65
                * ngh (Callable[[float], bool]): Checks if size of patches parameter has a proper value.
66
67
        See Also:
68
            * :func:`NiaPy.algorithms.algorithm.Algorithm.typeParameters`
69
        """
70
        d = Algorithm.typeParameters()
71
        d.update({
72
            'NP': lambda x: isinstance(x, int) and x > 0,
73
            'm': lambda x: isinstance(x, int) and x > 0,
74
            'e': lambda x: isinstance(x, int) and x > 0,
75
            'nep': lambda x: isinstance(x, int) and x > 0,
76
            'nsp': lambda x: isinstance(x, int) and x > 0,
77
            'ngh': lambda x: isinstance(x, float) and x > 0
78
        })
79
        return d
80
81
    def setParameters(self, NP=40, m=5, e=4, ngh=1, nep=4, nsp=2, **ukwargs):
82
        r"""Set the parameters of the algorithm.

NiaPy/algorithms/basic/foa.py 1 location

@@ 57-80 (lines=24) @@
54
        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.
55
    """
56
57
    @staticmethod
58
    def typeParameters():
59
        r"""Get dictionary with functions for checking values of parameters.
60
61
        Returns:
62
            Dict[str, Callable]:
63
                * lt (Callable[[int], bool]): Checks if life time parameter has a proper value.
64
                * al (Callable[[int], bool]): Checks if area limit parameter has a proper value.
65
                * lsc (Callable[[int], bool]): Checks if local seeding changes parameter has a proper value.
66
                * gsc (Callable[[int], bool]): Checks if global seeding changes parameter has a proper value.
67
                * tr (Callable[[float], bool]): Checks if transfer rate parameter has a proper value.
68
69
        See Also:
70
            * :func:`NiaPy.algorithms.algorithm.Algorithm.typeParameters`
71
        """
72
        d = Algorithm.typeParameters()
73
        d.update({
74
            'lt': lambda x: isinstance(x, int) and x > 0,
75
            'al': lambda x: isinstance(x, int) and x > 0,
76
            'lsc': lambda x: isinstance(x, int) and x > 0,
77
            'gsc': lambda x: isinstance(x, int) and x > 0,
78
            'tr': lambda x: isinstance(x, float) and 0 <= x <= 1,
79
        })
80
        return d
81
82
    def setParameters(self, NP=10, lt=3, al=10, lsc=1, gsc=1, tr=0.3, **ukwargs):
83
        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.