예제 #1
0
 def eval(self, ind):
     if self.opc == 1:
         ind = bench.rastrigin(ind)
     elif self.opc == 2:
         ind = bench.himmelblau(ind)
     elif self.opc == 3:
         ind = bench.eggholder(ind)
     elif self.opc == 4:
         ind = bench.nqueens(ind)
     elif self.opc == 5:
         ind = bench.tsp(ind)
     
     self.count += 1
     
     return ind
예제 #2
0
    def eval_pop(self, population):
        for i in range(len(population)):
            if self.opc == 1:
                population[i] = bench.rastrigin(population[i])
            elif self.opc == 2:
                population[i] = bench.himmelblau(population[i])
            elif self.opc == 3:
                population[i] = bench.eggholder(population[i])
            elif self.opc == 4:
                population[i] = bench.nqueens(population[i])
            elif self.opc == 5:
                population[i] = bench.tsp(population[i])

            self.count += 1

        return population