Grey Wolf Optimizer (gwo)#

class gwo#

Grey Wolf Optimizer Algorithm.

Grey Wolf Optimizer is an optimization algorithm based on the leadership hierarchy and hunting mechanism of greywolves, proposed by Seyedali Mirjalilia, Seyed Mohammad Mirjalilib, Andrew Lewis in 2014.../../../_images/GreyWolf.gif

This algorithm is a classic example of a highly criticizable line of search that led in the first decades of our millennia to the development of an entire zoo of metaphors inspiring optimization heuristics. In our opinion they, as is the case for the grey wolf optimizer, are often but small variations of already existing heuristics rebranded with unnecessary and convoluted biological metaphors. In the case of GWO this is particularly evident as the position update rule is shockingly trivial and can also be easily seen as a product of an evolutionary metaphor or a particle swarm one. Such an update rule is also not particularly effective and results in a rather poor performance most of times. Reading the original peer-reviewed paper, where the poor algorithmic performance is hidden by the methodological flaws of the benchmark presented, one is left with a bitter opinion of the whole peer-review system.

The implementation provided for PaGMO is based on the pseudo-code provided in the original Seyedali and Andrew (2014) paper. pagmo::gwo is suitable for box-constrained single-objective continuous optimization.

See also

https://www.sciencedirect.com/science/article/pii/S0965997813001853 for the paper that introduces Grey Wolf Optimizer and the pseudo-code

Public Types

typedef std::tuple<unsigned, double, double, double> log_line_type#

Single entry of the log (gen, alpha, beta, delta)

typedef std::vector<log_line_type> log_type#

The log.

Public Functions

gwo(unsigned gen = 1u, unsigned seed = pagmo::random_device::next())#

Constructor.

Constructs a Grey Wolf Optimizer

Parameters
  • gen – number of generations.

  • seed – seed used by the internal random number generator (default is random)

population evolve(population) const#

Algorithm evolve method.

Evolves the population for a maximum number of generations, until maximum number of generations is reached.

Parameters

pop – population to be evolved

Throws
  • std::invalid_argument – if the problem is multi-objective or constrained or stochastic

  • std::invalid_argument – if the population size is not at least 3

Returns

alpha agent’s position

void set_seed(unsigned)#

Sets the seed.

Parameters

seed – the seed controlling the algorithm stochastic behaviour

inline unsigned get_seed() const#

Gets the seed.

Returns

the seed controlling the algorithm stochastic behaviour

inline void set_verbosity(unsigned level)#

Sets the algorithm verbosity.

Sets the verbosity level of the screen output and of the log returned by get_log(). level can be:

  • 0: no verbosity

  • >0: will print and log one line each level generations.

Example (verbosity 1):

Gen:      Alpha:          Beta:         Delta:
 1         5.7861        12.7206        19.6594
 2       0.404838        4.60328        9.51591
 3      0.0609075        3.83717        4.30162
 4      0.0609075       0.830047        1.77049
 5       0.040997        0.12541       0.196164
Gen, is the generation number, Alpha is the fitness score for alpha, Beta is the fitness score for beta, delta is the fitness score for delta

Parameters

level – verbosity level

inline unsigned get_verbosity() const#

Gets the verbosity level.

Returns

the verbosity level

inline unsigned get_gen() const#

Gets the generations.

Returns

the number of generations to evolve for

inline std::string get_name() const#

Algorithm name.

One of the optional methods of any user-defined algorithm (UDA).

Returns

a string containing the algorithm name

std::string get_extra_info() const#

Extra info.

One of the optional methods of any user-defined algorithm (UDA).

Returns

a string containing extra info on the algorithm

inline const log_type &get_log() const#

Get log.

A log containing relevant quantities monitoring the last call to evolve. Each element of the returned std::vector is a gwo::log_line_type containing: gen, alpha, beta, delta as described in gwo::set_verbosity

Returns

an std::vector of gwo::log_line_type containing the logged values gen, alpha, beta, delta