Code Duplication    Length = 16-16 lines in 2 locations

NiaPy/algorithms/basic/pso.py 1 location

@@ 93-108 (lines=16) @@
90
		self.C1, self.C2, self.w, self.vMin, self.vMax = C1, C2, w, vMin, vMax
91
		if ukwargs: logger.info('Unused arguments: %s' % (ukwargs))
92
93
	def repair(self, x, l, u):
94
		r"""Repair array to range.
95
96
		Args:
97
			x (numpy.ndarray): Array to repair.
98
			l (numpy.ndarray): Lower limit of allowed range.
99
			u (numpy.ndarray): Upper limit of allowed range.
100
101
		Returns:
102
			numpy.ndarray: Repaired array.
103
		"""
104
		ir = where(x < l)
105
		x[ir] = l[ir]
106
		ir = where(x > u)
107
		x[ir] = u[ir]
108
		return x
109
110
	def init(self, task):
111
		r"""Initialize dynamic arguments of Particle Swarm Optimization algorithm.

NiaPy/algorithms/basic/cso.py 1 location

@@ 81-96 (lines=16) @@
78
        d['velocities'] = self.uniform(-self.vMax, self.vMax, [len(pop), task.D])
79
        return pop, fpop, d
80
81
    def repair(self, x, l, u):
82
        r"""Repair array to range.
83
84
        Args:
85
            x (numpy.ndarray): Array to repair.
86
            l (numpy.ndarray): Lower limit of allowed range.
87
            u (numpy.ndarray): Upper limit of allowed range.
88
89
        Returns:
90
            numpy.ndarray: Repaired array.
91
        """
92
        ir = np.where(x < l)
93
        x[ir] = l[ir]
94
        ir = np.where(x > u)
95
        x[ir] = u[ir]
96
        return x
97
98
    def randomSeekTrace(self):
99
        r"""Set cats into seeking/tracing mode.