structopt.common.population.predators

class structopt.common.population.predators.Predators(parameters)

Bases: object

static best(fits, nkeep)

Sorts individuals by fitness and keeps the top nkeep fitnesses.

Parameters:
  • fits (dict<int, float>) – Dictionary of <individual.id, fitness> pairs.
  • nkeep (int) – The number of individuals to keep. In a GA run, corresponds to the sum of each generators number_of_individuals
static fuss(fits, nkeep, nbest=0, fusslimit=10)

Fixed uniform selection scheme. Aimed at maintaining diversity in the population. In the case where low fit is the highest fitness, selects a fitness between min(fits) and min(fits) + fusslimit, if the difference between the min(fit) and max(fit) is larger than fusslimit.

Parameters:
  • fits (dict<int, float>) – Dictionary of <individual.id, fitness> pairs.
  • nkeep (int) – The number of individuals to keep. In a GA run, corresponds to the sum of each generators number_of_individuals
  • nbest (int) – The top n individuals to always keep (default 0)
  • fusslimit (float) – Individuals that have fitness fusslimit worse than the max fitness will not be considered
kill(population, nkeep, keep_best=True)

Removes some individuals from the population.

Parameters:
  • nkeep (int) – The number of individuals to keep.
  • keep_best (bool) – If set to True, the best individual is always included in the following generation.
Returns:

Return type:

The individuals that were removed from the population.

post_processing(killed)
static rank(fits, nkeep, p_min=None)

Selection function that chooses pairs of structures based on linear ranking.

See “Grefenstette and Baker 1989 Whitley 1989”.

Parameters:
  • fits (dict<int, float>) – Dictionary of <individual.id, fitness> pairs.
  • nkeep (int) – The number of individuals to keep. In a GA run, corresponds to the sum of each generators number_of_individuals
  • p_min (float) – The probability of choosing the lowest ranked individual. Given population of size N, this should be below 1/nindiv. The probability of selecting rank N (worst) to rank 1 (best) increases from p_min to (2/N - p_min) in even, (1/N - p_min) increments. Defaults to (1/N)^2.
static roulette(fits, nkeep, T=None)

Select individuals with a probability proportional to their fitness. Fitnesses are renormalized from 0 - 1, which means minimum fitness individual is never included in in the new population.

Parameters:
  • fits (dict<int, float>) – Dictionary of <individual.id, fitness> pairs.
  • nkeep (int) – The number of individuals to keep. In a GA run, corresponds to the sum of each generators number_of_individuals
  • T (float) – If T is not None, a boltzman-like transformation is applied to all fitness values with T.
select_predator()
static tournament(fits, nkeep, tournament_size=5)

Selects individuals in seperate “tournaments”, where a subset of the population are randomly selected and the highest fitness allowed to pass. In addition to a population, their fits, and end population size, takes in a tournament size parameter.

Parameters:
  • fits (dict<int, float>) – Dictionary of <individual.id, fitness> pairs.
  • nkeep (int) – The number of individuals to keep. In a GA run, corresponds to the sum of each generators number_of_individuals
  • tournament_size (int) – The number of individuals in each tournament. If 1, tournament is the same as random selection. If len(population), corresponds to the “best” selection process