Code Duplication    Length = 9-9 lines in 3 locations

NiaPy/algorithms/modified/hba.py 1 location

@@ 50-58 (lines=9) @@
47
        self.F = 0.5
48
        self.CR = 0.9
49
50
    def best_bat(self):
51
        i = 0
52
        j = 0
53
        for i in range(self.NP):
54
            if self.Fitness[i] < self.Fitness[j]:
55
                j = i
56
        for i in range(self.D):
57
            self.best[i] = self.Sol[j][i]
58
        self.f_min = self.Fitness[j]
59
60
    def init_bat(self):
61
        for i in range(self.D):

NiaPy/algorithms/basic/fpa.py 1 location

@@ 48-56 (lines=9) @@
45
        self.best = [0] * self.D  # best solution
46
        self.evaluations = 0  # evaluations counter
47
48
    def best_flower(self):
49
        i = 0
50
        j = 0
51
        for i in range(self.NP):
52
            if self.Fitness[i] < self.Fitness[j]:
53
                j = i
54
        for i in range(self.D):
55
            self.best[i] = self.Sol[j][i]
56
        self.f_min = self.Fitness[j]
57
58
    @classmethod
59
    def simplebounds(cls, val, lower, upper):

NiaPy/algorithms/basic/ba.py 1 location

@@ 47-55 (lines=9) @@
44
        self.best = [0] * self.D  # best solution
45
        self.evaluations = 0  # evaluations counter
46
        if callable(function):
47
            self.Fun = function
48
        else:
49
            if function == 'rastrigin':
50
                self.Fun = Rastrigin().function()
51
            elif function == 'rosenbrock':
52
                self.Fun = Rosenbrock().function()
53
            elif function == 'griewank':
54
                self.Fun = Griewank().function()
55
            elif function == 'sphere':
56
                self.Fun = Sphere().function()
57
            else:
58
                raise TypeError('Passed benchmark is not defined!')