Code Duplication    Length = 15-18 lines in 2 locations

NiaPy/algorithms/basic/pso.py 1 location

@@ 78-95 (lines=18) @@
75
    EDITED: TODO: Tests and validation! Bug in code.
76
    """
77
78
    def __init__(self, Np, D, nFES, C1, C2, w, vMin, vMax, Lower, Upper, function):
79
        """Constructor."""
80
        self.Np = Np
81
        self.D = D
82
        self.C1 = C1
83
        self.C2 = C2
84
        self.w = w
85
        self.vMin = vMin
86
        self.vMax = vMax
87
        self.Lower = Lower
88
        self.Upper = Upper
89
        self.Swarm = []
90
        self.nFES = nFES
91
        self.FEs = 0
92
        self.Done = False
93
        Particle.FuncEval = staticmethod(function)
94
95
        self.gBest = Particle(self.D, self.Lower, self.Upper, self.vMin, self.vMax)
96
97
    def evalSwarm(self):
98
        for p in self.Swarm:

NiaPy/algorithms/basic/cs.py 1 location

@@ 58-72 (lines=15) @@
55
class CuckooSearchAlgorithm(object):
56
    # pylint: disable=too-many-instance-attributes
57
58
    def __init__(self, Np, D, nFES, Pa, Alpha, Lower, Upper, function):
59
        self.Np = Np
60
        self.D = D
61
        self.Pa = Pa
62
        self.Lower = Lower
63
        self.Upper = Upper
64
        self.Nests = []
65
        self.nFES = nFES
66
        self.FEs = 0
67
        self.Done = False
68
        self.Alpha = Alpha
69
        self.Beta = 1.5
70
        Cuckoo.FuncEval = staticmethod(function)
71
72
        self.gBest = Cuckoo(self.D, self.Lower, self.Upper)
73
74
    def evalNests(self):
75
        for c in self.Nests: