Code Duplication    Length = 22-23 lines in 2 locations

NiaPy/algorithms/modified/saba.py 1 location

@@ 104-126 (lines=23) @@
101
		})
102
		return d
103
104
	def initPopulation(self, task):
105
		r"""Initialize the starting population.
106
107
		Parameters:
108
			task (Task): Optimization task
109
110
		Returns:
111
			Tuple[numpy.ndarray, numpy.ndarray[float], Dict[str, Any]]:
112
				1. New population.
113
				2. New population fitness/function values.
114
				3. Additional arguments:
115
					* A (float): Loudness.
116
					* S (numpy.ndarray): TODO
117
					* Q (numpy.ndarray[float]): 	TODO
118
					* v (numpy.ndarray[float]): TODO
119
120
		See Also:
121
			* :func:`NiaPy.algorithms.Algorithm.initPopulation`
122
		"""
123
		Sol, Fitness, d = Algorithm.initPopulation(self, task)
124
		A, S, Q, v = np.full(self.NP, self.A), np.full([self.NP, task.D], 0.0), np.full(self.NP, 0.0), np.full([self.NP, task.D], 0.0)
125
		d.update({'A': A, 'S': S, 'Q': Q, 'v': v})
126
		return Sol, Fitness, d
127
128
	def localSearch(self, best, A, task, **kwargs):
129
		r"""Improve the best solution according to the Yang (2010).

NiaPy/algorithms/basic/ba.py 1 location

@@ 106-127 (lines=22) @@
103
		})
104
		return d
105
106
	def initPopulation(self, task):
107
		r"""Initialize the starting population.
108
109
		Parameters:
110
			task (Task): Optimization task
111
112
		Returns:
113
			Tuple[numpy.ndarray, numpy.ndarray[float], Dict[str, Any]]:
114
				1. New population.
115
				2. New population fitness/function values.
116
				3. Additional arguments:
117
					* S (numpy.ndarray): TODO
118
					* Q (numpy.ndarray[float]): 	TODO
119
					* v (numpy.ndarray[float]): TODO
120
121
		See Also:
122
			* :func:`NiaPy.algorithms.Algorithm.initPopulation`
123
		"""
124
		Sol, Fitness, d = Algorithm.initPopulation(self, task)
125
		S, Q, v = full([self.NP, task.D], 0.0), full(self.NP, 0.0), full([self.NP, task.D], 0.0)
126
		d.update({'S': S, 'Q': Q, 'v': v})
127
		return Sol, Fitness, d
128
129
	def localSearch(self, best, task, **kwargs):
130
		r"""Improve the best solution according to the Yang (2010).