Code Duplication    Length = 16-16 lines in 2 locations

NiaPy/algorithms/basic/bea.py 1 location

@@ 146-161 (lines=16) @@
143
144
        return BeesPosition, BeesCost, {'ngh': self.ngh}
145
146
    def repair(self, x, lower, upper):
147
        r"""Truncate exceeded dimensions to the limits.
148
149
        Args:
150
            x (numpy.ndarray): Individual to repair.
151
            lower (numpy.ndarray): Lower limits for dimensions.
152
            upper (numpy.ndarray): Upper limits for dimensions.
153
154
        Returns:
155
            numpy.ndarray: Repaired individual.
156
        """
157
        ir = where(x < lower)
158
        x[ir] = lower[ir]
159
        ir = where(x > upper)
160
        x[ir] = upper[ir]
161
        return x
162
163
    def runIteration(self, task, BeesPosition, BeesCost, xb, fxb, ngh, **dparams):
164
        r"""Core function of Forest Optimization Algorithm.

NiaPy/algorithms/basic/mbo.py 1 location

@@ 89-104 (lines=16) @@
86
        if ukwargs:
87
            logger.info('Unused arguments: %s' % (ukwargs))
88
89
    def repair(self, x, lower, upper):
90
        r"""Truncate exceeded dimensions to the limits.
91
92
        Args:
93
            x (numpy.ndarray): Individual to repair.
94
            lower (numpy.ndarray): Lower limits for dimensions.
95
            upper (numpy.ndarray): Upper limits for dimensions.
96
97
        Returns:
98
            numpy.ndarray: Repaired individual.
99
        """
100
        ir = where(x < lower)
101
        x[ir] = lower[ir]
102
        ir = where(x > upper)
103
        x[ir] = upper[ir]
104
        return x
105
106
    def levy(self, step_size, D):
107
        r"""Calculate levy flight.