(N+1)-ES Simple Evolutionary Algorithm#

class sea#

(N+1)-ES Simple Evolutionary Algorithm


Evolutionary strategies date back to the mid 1960s when P. Bienert, I. Rechenberg, and H.-P. Schwefel at the Technical University of Berlin, Germany, developed the first bionics-inspired schemes for evolving optimal shapes of minimal drag bodies in a wind tunnel using Darwin’s evolution principle.

This c++ class represents the simplest evolutionary strategy, where a population of \( \lambda \) individuals at each generation produces one offspring by mutating its best individual uniformly at random within the bounds. Should the offspring be better than the worst individual in the population it will substitute it.

See also

Oliveto, Pietro S., Jun He, and Xin Yao. “Time complexity of evolutionary algorithms for combinatorial optimization: A decade of results.” International Journal of Automation and Computing 4.3 (2007): 281-293.


The mutation is uniform within box-bounds. Hence, unbounded problems will produce undefined behaviours.


The algorithm is not suitable for multi-objective problems, nor for constrained or stochastic optimization

Public Types

typedef std::tuple<unsigned, unsigned long long, double, double, vector_double::size_type> log_line_type#

Single entry of the log (gen, fevals, best, improvement, mutations)

typedef std::vector<log_line_type> log_type#

The log.

Public Functions

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


Constructs sea

  • gen – Number of generations to consider. Each generation will compute the objective function once

  • seed – seed used by the internal random number generator

population evolve(population) const#

Algorithm evolve method.


pop – population to be evolved


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


evolved population

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

  • 1: will only print and log when the population is improved

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

Example (verbosity 1):

Gen:        Fevals:          Best:   Improvement:     Mutations:
632           3797        1464.31        51.0203              1
633           3803        1463.23        13.4503              1
635           3815        1562.02        31.0434              3
667           4007         1481.6        24.1889              1
668           4013        1487.34        73.2677              2
Gen, is the generation number, Fevals the number of function evaluation used, Best is the best fitness function currently in the population, Improvement is the improvement made by the last mutation and Mutations is the number of mutated components of the decision vector


level – verbosity level

inline unsigned get_verbosity() const#

Gets the verbosity level.


the verbosity level

void set_seed(unsigned)#

Sets the seed.


seed – the seed controlling the algorithm stochastic behaviour

inline unsigned get_seed() const#

Gets the seed.


the seed controlling the algorithm stochastic behaviour

inline std::string get_name() const#

Algorithm name.

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


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).


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 sea::log_line_type containing: Gen, Fevals, Best, Improvement, Mutations as described in sea::set_verbosity


an std::vector of sea::log_line_type containing the logged values Gen, Fevals, Best, Improvement, Mutations