Ejemplo n.º 1
0
Archivo: CWOA.py Proyecto: zzw95/SOIO
    def select_best_neigbor(self, neighbors):
        leader = FloatSolution(self.problem.number_of_variables)
        leader.objective = float("inf")
        for i in neighbors:
            if self.swarm[i].objective < leader.objective:
                leader = self.swarm[i]

        return leader
Ejemplo n.º 2
0
    def select_best_three_neigbors(self, neighbors):
        alpha_wolf = FloatSolution(self.problem.number_of_variables)
        alpha_wolf.objective = float("inf")
        beta_wolf = FloatSolution(self.problem.number_of_variables)
        beta_wolf.objective = float("inf")
        delta_wolf = FloatSolution(self.problem.number_of_variables)
        delta_wolf.objective = float("inf")
        for i in neighbors:
            if self.swarm[i].objective < alpha_wolf.objective:
                delta_wolf = beta_wolf
                beta_wolf = alpha_wolf
                alpha_wolf = self.swarm[i]

            elif self.swarm[i].objective < beta_wolf.objective:
                delta_wolf = beta_wolf
                beta_wolf = self.swarm[i]

            elif self.swarm[i].objective < delta_wolf.objective:
                delta_wolf = self.swarm[i]
        return alpha_wolf, beta_wolf, delta_wolf
Ejemplo n.º 3
0
 def evaluate(self, solution: FloatSolution):
     self.nfes += 1
     solution.objective = self.compute(solution.variables)