delo.SHADE

class delo.SHADE(population_size, p_best_rate=0.2, use_archive=True, archive_size=50, history_size=100, restart_eps_x=None, restart_eps_y=None, initial_M_CR=0.5, initial_M_F=0.5, logger=None, **logger_kwargs)

Optimization algorithm from Differential Evolution family. F and CR parameters are adjusted through optimizing using sucess history. Utilized mutation strategy: p-best. Succesful members from past will be stored in archive. Restart condition: minimum relative dispersion across dimension.

Example

>>> # Optimize quadratic function in 2D
>>> import delo
>>> import numpy as np
>>>
>>> def square(x):
...     return np.sum(x ** 2, axis=1)
>>>
>>> described_function = delo.DescribedFunction(square, dimension=2, domain_lower_limit=-10, domain_upper_limit=10)
>>> algorithm = delo.SHADE(100)
>>>
>>> solution, best_f_value = algorithm.optimize(described_function)
>>> print(solution, best_f_value)
0.0, 0.0
__init__(population_size, p_best_rate=0.2, use_archive=True, archive_size=50, history_size=100, restart_eps_x=None, restart_eps_y=None, initial_M_CR=0.5, initial_M_F=0.5, logger=None, **logger_kwargs)

Succcess-History based parameter Adaptation for Differential Evolution

Initialise the algorithm, but not run in yet (see optimize).

Parameters
  • population_size (positive int) –

  • p_best_rate (float from (0,1]) – fraction of members chosen in p_best mutation strategy

  • restart_eps_x (float, optional) – Minimal acceptable absolute distance between members. If smaller, a restart occurs. If None, restarting will never occur.

  • restart_eps_y (float, optional) – Minimal acceptable absolute difference between function values. If smaller, a restart occurs. If None, this will be same as restart_eps_x.

  • initial_M_F (float from [0, 1]) –

  • initial_M_CR (float from [0, 1]) –

Methods

__init__(population_size[, p_best_rate, ...])

Succcess-History based parameter Adaptation for Differential Evolution

get_solution()

Get solution found during optimization process

optimize(described_function[, max_f_evals, ...])

Optimize the described function.

get_solution()

Get solution found during optimization process

Returns

solution (member with lowest f-value), best_f_value.

Return type

Tuple

optimize(described_function, max_f_evals=1000, print_every=None, restarts_handled_externally=False, rng_seed=None)

Optimize the described function.

Pass the target function and start the optimization process.

Parameters
  • described_function (DescribedFunction) – Function to be optimized with attributes.

  • max_f_evals (int) – Number of times that algorithm is allowed to evaluate function. When exceeded, the optimization process is terminated and the found minimum is returned.

  • print_every (int, optional) – Info about verbosity. Every print_every generation information about state of optimization will be printed on console. If print_every is omitted, no information will be printed.

  • restarts_handled_externally (bool) – If True and restarting conditions are met, the algorithm ends. If False and restarting conditions are met, the algorithm restarts.

  • rng_seed (int, optional) – seed to be used in pseudorandom number generation. Same seed leads to same run for the algorithm.

Returns

solution (member with lowest f-value), best_f_value.

Return type

Tuple