def diversify_population(self, pop):
        """
        Introduce diversity in the population by replacing a percentage of individuals.
        :param pop: Population to diversify
        :return: Diversified population
        """
        # find indices to be replaced (introduce diversity)
        I = np.where(np.random.random(len(pop)) < self.PERC_DIVERSITY)[0]
        # replace with randomly sampled individuals
        pop[I] = self.initialization.sampling(self.problem, len(I))
        return pop

        Introduce diversity in the population by replacing a percentage of individuals.
        :param pop: Population to diversify
        :return: Diversified population
        
pymoo/algorithms/moo/kgb.py