metaheuristic_designer.operators.operator_functions.differential_evolution module#

Differential evolution operator implementations.

differential_evolution_rand1(population_matrix, fitness_array, rng=None, F=0.8, Cr=0.9, **kwargs)[source]#

DE/rand/1 mutation and binomial crossover.

For each target vector, three distinct random individuals are chosen. A donor vector is formed as x_r1 + F * (x_r2 - x_r3). Components are then taken from the donor with probability Cr and from the target otherwise.

Return type:

ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool]

Parameters:
population_matrixMatrixLike

Current population, shape (N, M).

fitness_arrayVectorLike

Fitness values (used only by the /best/ variants).

rngRNGLike, optional

Random number generator.

Ffloat, optional

Scale factor (default 0.8).

Crfloat, optional

Crossover probability (default 0.9).

Returns:
MatrixLike

Trial population of the same shape.

Parameters:
  • population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])

  • fitness_array (ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool])

  • rng (int | Generator | None)

  • F (float)

  • Cr (float)

differential_evolution_best1(population_matrix, fitness_array, rng=None, F=0.8, Cr=0.9, **kwargs)[source]#

DE/best/1 mutation and binomial crossover.

The donor is formed using the best individual as the base: x_best + F * (x_r1 - x_r2) where r1 and r2 are distinct and different from best.

Return type:

ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool]

Parameters:
population_matrixMatrixLike

Current population.

fitness_arrayVectorLike

Fitness values; the index of the maximum is used as best.

rngRNGLike, optional

Random number generator.

Ffloat, optional

Scale factor (default 0.8).

Crfloat, optional

Crossover probability (default 0.9).

Returns:
MatrixLike

Trial population of the same shape.

Parameters:
  • population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])

  • fitness_array (ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool])

  • rng (int | Generator | None)

  • F (float)

  • Cr (float)

differential_evolution_rand2(population_matrix, fitness_array, rng=None, F=0.8, Cr=0.9, **kwargs)[source]#

DE/rand/2 mutation and binomial crossover.

Two difference vectors are used: x_r1 + F*(x_r2 - x_r3) + F*(x_r4 - x_r5).

Return type:

ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool]

Parameters:
population_matrixMatrixLike

Current population.

fitness_arrayVectorLike

Fitness values (unused in this variant).

rngRNGLike, optional

Random number generator.

Ffloat, optional

Scale factor (default 0.8).

Crfloat, optional

Crossover probability (default 0.9).

Returns:
MatrixLike

Trial population of the same shape.

Parameters:
  • population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])

  • fitness_array (ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool])

  • rng (int | Generator | None)

  • F (float)

  • Cr (float)

differential_evolution_best2(population_matrix, fitness_array, rng=None, F=0.8, Cr=0.9, **kwargs)[source]#

DE/best/2 mutation and binomial crossover.

The best individual is the base, and two difference vectors are added: x_best + F*(x_r1 - x_r2) + F*(x_r3 - x_r4).

Return type:

ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool]

Parameters:
population_matrixMatrixLike

Current population.

fitness_arrayVectorLike

Fitness values; the best is the one with highest fitness.

rngRNGLike, optional

Random number generator.

Ffloat, optional

Scale factor (default 0.8).

Crfloat, optional

Crossover probability (default 0.9).

Returns:
MatrixLike

Trial population of the same shape.

Parameters:
  • population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])

  • fitness_array (ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool])

  • rng (int | Generator | None)

  • F (float)

  • Cr (float)

differential_evolution_current_to_rand1(population_matrix, fitness_array, rng=None, F=0.8, Cr=0.9, **kwargs)[source]#

DE/current-to-rand/1 mutation and binomial crossover.

Each target vector x_i is combined with a random individual and a difference vector: x_i + K*(x_r1 - x_i) + F*(x_r2 - x_r3), where K is drawn uniformly in [0,1] per individual.

Return type:

ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool]

Parameters:
population_matrixMatrixLike

Current population.

fitness_arrayVectorLike

Fitness values (unused).

rngRNGLike, optional

Random number generator.

Ffloat, optional

Scale factor (default 0.8).

Crfloat, optional

Crossover probability (default 0.9).

Returns:
MatrixLike

Trial population of the same shape.

Parameters:
  • population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])

  • fitness_array (ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool])

  • rng (int | Generator | None)

  • F (float)

  • Cr (float)

differential_evolution_current_to_best1(population_matrix, fitness_array, rng=None, F=0.8, Cr=0.9, **kwargs)[source]#

DE/current-to-best/1 mutation and binomial crossover.

x_i + K*(x_best - x_i) + F*(x_r1 - x_r2).

Return type:

ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool]

Parameters:
population_matrixMatrixLike

Current population.

fitness_arrayVectorLike

Fitness values; the best is the one with highest fitness.

rngRNGLike, optional

Random number generator.

Ffloat, optional

Scale factor (default 0.8).

Crfloat, optional

Crossover probability (default 0.9).

Returns:
MatrixLike

Trial population of the same shape.

Parameters:
  • population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])

  • fitness_array (ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool])

  • rng (int | Generator | None)

  • F (float)

  • Cr (float)

differential_evolution_current_to_pbest1(population_matrix, fitness_array, rng=None, F=0.8, Cr=0.9, p=0.1, **kwargs)[source]#

DE/current-to-pbest/1 mutation and binomial crossover.

Instead of the single best, one of the top p*N individuals is randomly chosen as pbest: x_i + K*(x_pbest - x_i) + F*(x_r1 - x_r2).

Return type:

ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool]

Parameters:
population_matrixMatrixLike

Current population.

fitness_arrayVectorLike

Fitness values; the top p fraction is selected.

rngRNGLike, optional

Random number generator.

Ffloat, optional

Scale factor (default 0.8).

Crfloat, optional

Crossover probability (default 0.9).

pfloat, optional

Fraction of the population considered as elite (default 0.1).

Returns:
MatrixLike

Trial population of the same shape.

Parameters:
  • population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])

  • fitness_array (ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool])

  • rng (int | Generator | None)

  • F (float)

  • Cr (float)

  • p (float)