src/orion/algo/evolution_es.py
def compute_budgets(
    min_resources, max_resources, reduction_factor, nums_population, pairs
):
    """Compute the budgets used for each execution of hyperband"""
    budgets_eves = []
    if reduction_factor == 1:
        for i in range(min_resources, max_resources + 1):
            if i == min_resources:
                budgets_eves.append([(nums_population, i)])
            else:
                budgets_eves[0].append((pairs * 2, i))
    else:
        num_brackets = int(np.log(max_resources) / np.log(reduction_factor))
        budgets = []
        budgets_tab = {}  # just for display consideration
        for bracket_id in range(0, num_brackets + 1):
            bracket_budgets = []
            num_trials = int(
                np.ceil(
                    int((num_brackets + 1) / (num_brackets - bracket_id + 1))
                    * (reduction_factor ** (num_brackets - bracket_id))
                )
            )

            min_resources = max_resources / reduction_factor ** (
                num_brackets - bracket_id
            )
            for i in range(0, num_brackets - bracket_id + 1):
                n_i = int(num_trials / reduction_factor ** i)
                min_i = int(min_resources * reduction_factor ** i)
                bracket_budgets.append((n_i, min_i))

                if budgets_tab.get(i):
                    budgets_tab[i].append((n_i, min_i))
                else:
                    budgets_tab[i] = [(n_i, min_i)]

            budgets.append(bracket_budgets)

        for i in range(len(budgets[0])):
            if i == 0:
                budgets_eves.append([(nums_population, budgets[0][i][1])])
            else:
                budgets_eves[0].append((pairs * 2, budgets[0][i][1]))

    return budgets_eves
Compute the budgets used for each execution of hyperband
Compute the budgets used for each execution of hyperband
Compute the budgets used for each execution of hyperband
def compute_budgets(
    min_resources, max_resources, reduction_factor, nums_population, pairs
):
    budgets_eves = []
    if reduction_factor == 1:
        for i in range(min_resources, max_resources + 1):
            if i == min_resources:
                budgets_eves.append([(nums_population, i)])
            else:
                budgets_eves[0].append((pairs * 2, i))
    else:
        num_brackets = int(np.log(max_resources) / np.log(reduction_factor))
        budgets = []
        budgets_tab = {}  
        for bracket_id in range(0, num_brackets + 1):
            bracket_budgets = []
            num_trials = int(
                np.ceil(
                    int((num_brackets + 1) / (num_brackets - bracket_id + 1))
                    * (reduction_factor ** (num_brackets - bracket_id))
                )
            )
            min_resources = max_resources / reduction_factor ** (
                num_brackets - bracket_id
            )
            for i in range(0, num_brackets - bracket_id + 1):
                n_i = int(num_trials / reduction_factor ** i)
                min_i = int(min_resources * reduction_factor ** i)
                bracket_budgets.append((n_i, min_i))
                if budgets_tab.get(i):
                    budgets_tab[i].append((n_i, min_i))
                else:
                    budgets_tab[i] = [(n_i, min_i)]
            budgets.append(bracket_budgets)
        for i in range(len(budgets[0])):
            if i == 0:
                budgets_eves.append([(nums_population, budgets[0][i][1])])
            else:
                budgets_eves[0].append((pairs * 2, budgets[0][i][1]))
    return budgets_eves
def compute_budgets ( min_resources , max_resources , reduction_factor , nums_population , pairs ) : budgets_eves = [ ] if reduction_factor == 1 : for i in range ( min_resources , max_resources + 1 ) : if i == min_resources : budgets_eves . append ( [ ( nums_population , i ) ] ) else : budgets_eves [ 0 ] . append ( ( pairs * 2 , i ) ) else : num_brackets = int ( np . log ( max_resources ) / np . log ( reduction_factor ) ) budgets = [ ] budgets_tab = { } for bracket_id in range ( 0 , num_brackets + 1 ) : bracket_budgets = [ ] num_trials = int ( np . ceil ( int ( ( num_brackets + 1 ) / ( num_brackets - bracket_id + 1 ) ) * ( reduction_factor ** ( num_brackets - bracket_id ) ) ) ) min_resources = max_resources / reduction_factor ** ( num_brackets - bracket_id ) for i in range ( 0 , num_brackets - bracket_id + 1 ) : n_i = int ( num_trials / reduction_factor ** i ) min_i = int ( min_resources * reduction_factor ** i ) bracket_budgets . append ( ( n_i , min_i ) ) if budgets_tab . get ( i ) : budgets_tab [ i ] . append ( ( n_i , min_i ) ) else : budgets_tab [ i ] = [ ( n_i , min_i ) ] budgets . append ( bracket_budgets ) for i in range ( len ( budgets [ 0 ] ) ) : if i == 0 : budgets_eves . append ( [ ( nums_population , budgets [ 0 ] [ i ] [ 1 ] ) ] ) else : budgets_eves [ 0 ] . append ( ( pairs * 2 , budgets [ 0 ] [ i ] [ 1 ] ) ) return budgets_eves
Compute the budgets used for each execution of hyperband
Compute the budgets used for each execution of hyperband
"""Compute the budgets used for each execution of hyperband""" # just for display consideration
min_resources
max_resources
reduction_factor
nums_population
pairs