src/orion/algo/evolution_es.py
def _mutate_population(self, red_team, blue_team, rung, population_range):
        """Get the mutated population and hurdles"""
        winner_list = []
        loser_list = []

        if set(red_team) != set(blue_team):
            hurdles = 0
            for i, _ in enumerate(red_team):
                winner, loser = (
                    (red_team, blue_team)
                    if self.eves.performance[red_team[i]]
                    < self.eves.performance[blue_team[i]]
                    else (blue_team, red_team)
                )

                winner_list.append(winner[i])
                loser_list.append(loser[i])
                hurdles += self.eves.performance[winner[i]]
                self._mutate(winner[i], loser[i])

            hurdles /= len(red_team)
            self.eves.hurdles.append(hurdles)

            logger.debug("Evolution hurdles are: %s", str(self.eves.hurdles))

        points = []
        nums_all_equal = [0] * population_range
        for i in range(population_range):
            point = [0] * len(self.space)
            while True:
                point[self.eves.fidelity_index] = list(rung.values())[i][1][
                    self.eves.fidelity_index
                ]

                for j in self.search_space_remove_fidelity:
                    point[j] = self.eves.population[j][i]

                if tuple(point) in points:
                    nums_all_equal[i] += 1
                    logger.debug("find equal one, continue to mutate.")
                    self._mutate(points.index(tuple(point)), i)
                else:
                    break
                if nums_all_equal[i] > 10:
                    logger.warning(
                        "Can not Evolve any more, " "You can make an early stop."
                    )
                    break

            points.append(tuple(point))

        return points, np.array(nums_all_equal)
Get the mutated population and hurdles
Get the mutated population and hurdles
Get the mutated population and hurdles
def _mutate_population(self, red_team, blue_team, rung, population_range):
        winner_list = []
        loser_list = []
        if set(red_team) != set(blue_team):
            hurdles = 0
            for i, _ in enumerate(red_team):
                winner, loser = (
                    (red_team, blue_team)
                    if self.eves.performance[red_team[i]]
                    < self.eves.performance[blue_team[i]]
                    else (blue_team, red_team)
                )
                winner_list.append(winner[i])
                loser_list.append(loser[i])
                hurdles += self.eves.performance[winner[i]]
                self._mutate(winner[i], loser[i])
            hurdles /= len(red_team)
            self.eves.hurdles.append(hurdles)
            logger.debug("Evolution hurdles are: %s", str(self.eves.hurdles))
        points = []
        nums_all_equal = [0] * population_range
        for i in range(population_range):
            point = [0] * len(self.space)
            while True:
                point[self.eves.fidelity_index] = list(rung.values())[i][1][
                    self.eves.fidelity_index
                ]
                for j in self.search_space_remove_fidelity:
                    point[j] = self.eves.population[j][i]
                if tuple(point) in points:
                    nums_all_equal[i] += 1
                    logger.debug("find equal one, continue to mutate.")
                    self._mutate(points.index(tuple(point)), i)
                else:
                    break
                if nums_all_equal[i] > 10:
                    logger.warning(
                        "Can not Evolve any more, " "You can make an early stop."
                    )
                    break
            points.append(tuple(point))
        return points, np.array(nums_all_equal)
def _mutate_population ( self , red_team , blue_team , rung , population_range ) : winner_list = [ ] loser_list = [ ] if set ( red_team ) != set ( blue_team ) : hurdles = 0 for i , _ in enumerate ( red_team ) : winner , loser = ( ( red_team , blue_team ) if self . eves . performance [ red_team [ i ] ] < self . eves . performance [ blue_team [ i ] ] else ( blue_team , red_team ) ) winner_list . append ( winner [ i ] ) loser_list . append ( loser [ i ] ) hurdles += self . eves . performance [ winner [ i ] ] self . _mutate ( winner [ i ] , loser [ i ] ) hurdles /= len ( red_team ) self . eves . hurdles . append ( hurdles ) logger . debug ( "Evolution hurdles are: %s" , str ( self . eves . hurdles ) ) points = [ ] nums_all_equal = [ 0 ] * population_range for i in range ( population_range ) : point = [ 0 ] * len ( self . space ) while True : point [ self . eves . fidelity_index ] = list ( rung . values ( ) ) [ i ] [ 1 ] [ self . eves . fidelity_index ] for j in self . search_space_remove_fidelity : point [ j ] = self . eves . population [ j ] [ i ] if tuple ( point ) in points : nums_all_equal [ i ] += 1 logger . debug ( "find equal one, continue to mutate." ) self . _mutate ( points . index ( tuple ( point ) ) , i ) else : break if nums_all_equal [ i ] > 10 : logger . warning ( "Can not Evolve any more, " "You can make an early stop." ) break points . append ( tuple ( point ) ) return points , np . array ( nums_all_equal )
Get the mutated population and hurdles
Get the mutated population and hurdles
"""Get the mutated population and hurdles"""
self
red_team
blue_team
rung
population_range