def solve(self) -> Nest:
    nest_indices = np.array(range(len(self.__nests)))
    best_nest = deepcopy(min(self.__nests, key=(lambda nest: nest.value)))
    (positions, abandoned) = zip(*[(nest.position, nest.abandoned) for nest in self.__nests])
    self.__visualizer.add_data(positions=positions, best_position=best_nest.position, abandoned=abandoned)
    LOGGER.info('Iteration 0 best solution="%s" at position="%s"', best_nest.value, best_nest.position)
    for iteration in range(self.__max_generations):
        new_cuckoo_pos = [np.clip(cuckoo.levy_flight(nest.position, self.__alpha, self.__lambda), a_min=self.__lower_boundary, a_max=self.__upper_boundary) for nest in self.__nests]
        np.random.shuffle(nest_indices)
        for (index, pos) in zip(nest_indices, new_cuckoo_pos):
            self.__nests[index].update_pos(pos)
        for nest in self.__nests:
            if (np.random.random_sample() < self.__p_a):
                nest.abandon()
        current_best = min(self.__nests, key=(lambda nest: nest.value))
        if (current_best.value < best_nest.value):
            best_nest = deepcopy(current_best)
            LOGGER.info('Iteration %i Found new best solution="%s" at position="%s"', (iteration + 1), best_nest.value, best_nest.position)
        (positions, abandoned) = zip(*[(nest.position, nest.abandoned) for nest in self.__nests])
        self.__visualizer.add_data(positions=positions, best_position=current_best.position, abandoned=abandoned)
    LOGGER.info('Last best solution="%s" at position="%s"', best_nest.value, best_nest.position)
    return best_nest
def solve(self) -> Nest:
    nest_indices = np.array(range(len(self.__nests)))
    best_nest = deepcopy(min(self.__nests, key=(lambda nest: nest.value)))
    (positions, abandoned) = zip(*[(nest.position, nest.abandoned) for nest in self.__nests])
    self.__visualizer.add_data(positions=positions, best_position=best_nest.position, abandoned=abandoned)
    LOGGER.info('Iteration 0 best solution="%s" at position="%s"', best_nest.value, best_nest.position)
    for iteration in range(self.__max_generations):
        new_cuckoo_pos = [np.clip(cuckoo.levy_flight(nest.position, self.__alpha, self.__lambda), a_min=self.__lower_boundary, a_max=self.__upper_boundary) for nest in self.__nests]
        np.random.shuffle(nest_indices)
        for (index, pos) in zip(nest_indices, new_cuckoo_pos):
            self.__nests[index].update_pos(pos)
        for nest in self.__nests:
            if (np.random.random_sample() < self.__p_a):
                nest.abandon()
        current_best = min(self.__nests, key=(lambda nest: nest.value))
        if (current_best.value < best_nest.value):
            best_nest = deepcopy(current_best)
            LOGGER.info('Iteration %i Found new best solution="%s" at position="%s"', (iteration + 1), best_nest.value, best_nest.position)
        (positions, abandoned) = zip(*[(nest.position, nest.abandoned) for nest in self.__nests])
        self.__visualizer.add_data(positions=positions, best_position=current_best.position, abandoned=abandoned)
    LOGGER.info('Last best solution="%s" at position="%s"', best_nest.value, best_nest.position)
    return best_nest