(self, parameters, results, lower_is_better)
return trial
Continues the top 80% of the generation, resamples the rest from the
        top 20% and perturbs.

        Returns
            dict: parameter dictionary.
Continues the top 80% of the generation, resamples the rest from the
        top 20% and perturbs.
Continues the top 80% of the generation resamples the rest from the top 20% and perturbs .
def _truncation_selection(self, parameters, results, lower_is_better):
        """
        Continues the top 80% of the generation, resamples the rest from the
        top 20% and perturbs.

        Returns
            dict: parameter dictionary.
        """
        # Select correct generation and sort generation members
        completed = results.loc[results['Status'] == 'COMPLETED', :]


        if (self.count - 1) % self.population_size / self.population_size < 0.8:
            # Go through top 80% of generation
            generation_df = completed.loc[(completed.generation
                                           == self.generation - 1), :] \
                                     .sort_values(by='Objective',
                                                  ascending=lower_is_better)
            d = generation_df.iloc[(self.count - 1) % self.population_size].to_dict()
        else:
            # For the rest, sample from top 20% of the last generation
            target_generations = [self.generation - 1]
            generation_df = completed.loc[(completed.generation.isin(
                target_generations)), :] \
                                     .sort_values(by='Objective',
                                                  ascending=lower_is_better)
            idx = sherpa_rng.randint(low=0, high=self.population_size*len(target_generations)//5)
            d = generation_df.iloc[idx].to_dict()
            d = self._perturb(candidate=d, parameters=parameters)
        trial = {param.name: d[param.name] for param in parameters}
        for key in ['load_from', 'save_to', 'lineage']:
            trial[key] = d[key]
        return trial
def _truncation_selection ( self , parameters , results , lower_is_better ) : # Select correct generation and sort generation members completed = results . loc [ results [ 'Status' ] == 'COMPLETED' , : ] if ( self . count - 1 ) % self . population_size / self . population_size < 0.8 : # Go through top 80% of generation generation_df = completed . loc [ ( completed . generation == self . generation - 1 ) , : ] . sort_values ( by = 'Objective' , ascending = lower_is_better ) d = generation_df . iloc [ ( self . count - 1 ) % self . population_size ] . to_dict ( ) else : # For the rest, sample from top 20% of the last generation target_generations = [ self . generation - 1 ] generation_df = completed . loc [ ( completed . generation . isin ( target_generations ) ) , : ] . sort_values ( by = 'Objective' , ascending = lower_is_better ) idx = sherpa_rng . randint ( low = 0 , high = self . population_size * len ( target_generations ) // 5 ) d = generation_df . iloc [ idx ] . to_dict ( ) d = self . _perturb ( candidate = d , parameters = parameters ) trial = { param . name : d [ param . name ] for param in parameters } for key in [ 'load_from' , 'save_to' , 'lineage' ] : trial [ key ] = d [ key ] return trial