Code Duplication    Length = 5-5 lines in 2 locations

NiaPy/algorithms/modified/jde.py 1 location

@@ 159-163 (lines=5) @@
156
            jrand = int(rnd.random() * self.Np)
157
158
            for j in range(self.D):
159
                if rnd.random() < newSolution.CR or j == jrand:
160
                    newSolution.Solution[j] = Population[r[0]].Solution[j] + newSolution.F * (
161
                        Population[r[1]].Solution[j] - Population[r[2]].Solution[j])
162
                else:
163
                    newSolution.Solution[j] = Population[i].Solution[j]
164
            newSolution.repair()
165
            self.tryEval(newSolution)
166

NiaPy/algorithms/basic/de.py 1 location

@@ 115-119 (lines=5) @@
112
    def generationStep(self, Population):
113
        """Implement main generation step."""
114
115
        newPopulation = []
116
        for i in range(self.Np):
117
            newSolution = SolutionDE(self.D, self.Lower, self.Upper)
118
119
            r = rnd.sample(range(0, self.Np), 3)
120
            while i in r:
121
                r = rnd.sample(range(0, self.Np), 3)
122
            jrand = int(rnd.random() * self.Np)