Skip to content

Evolution Strategy

Introduction

Evolution strategy mutates and combines the best individuals of a population across a number of generations without transforming them into an array of bits (like genetic algorithms) but uses the real values of the positions.

Example

from gradient_free_optimizers import EvolutionStrategyOptimizer

...

opt = EvolutionStrategyOptimizer(search_space, population=15)
opt.search(objective_function, n_iter=100)

About the implementation

The mutation part of the evolution strategy optimizer is a regular hill climbing iteration step. The idea of a mutation corresponds to small changes of the current position of the optimizer. The crossover works by randomly combining the positions of some of the two best individuals in the population to get a new position. The individuals with the worst scores are removed to preserve the number of individuals in the population.

The mutation_rate and crossover_rate are weights that correspond to the probability of choosing one method. The algorithm decides what method to use in the following way:

\[ R = \text{random-float} (0 ... \text{total-rate}) \]

where:

\[ \text{total-rate} = \text{mutation-rate} + \text{crossover-rate} \]
if R <= mutation-rate:
    do mutation
else:
    do crossover

Parameters

population

Size of the population for population-based optimization algorithms. A member of the population is called single optimizer, individual or particle depending on the type of algorithm. Each member of the population is a separate optimizer class with information about the positions and scores of the optimizer and all methods to perform the iteration and evaluation steps.

All population based optimizers in this package calculate the new positions one member at a time. So if the optimizer performs 10 iterations and has a population size of 10, then each member of the population would move once to a new position.

  • type: int
  • default: 10
  • typical range: 4 ... 25

mutation_rate

Probability of an individual in the population to perform an hill climbing step.

  • type: float
  • default: 0.7
  • typical range: 0.1 ... 0.9

crossover_rate

Probability of an individual to perform a crossover with the best individual in the population.

  • type: float
  • default: 0.3
  • typical range: 0.1 ... 0.9

rand_rest_p

Probability for the optimization algorithm to jump to a random position in an iteration step. It is set to 0 per default. The idea of this parameter is to give the possibility to inject randomness into algorithms that don't normally support it.

  • type: float
  • default: 0
  • typical range: 0.01 ... 0.1