Multi-Objective Memetic Evolutionary Strategy (UDA)
-
class momes4cgp
Multi-Objective, Memetic Evolutionary Strategy for a Cartesian Genetic Program.
Symbolic regression tasks seek for good mathematical models to represent input data. By increasing the model complexity it is always (theoretically) possible to find almost perfect fits of any input data. As a consequence, the model complexity must be traded off with its accuracy so that symbolic regression is, ultimately, a two-objectives optimization problem.
In this C++ class we offer an UDA (User Defined Algorithm for the pagmo optimization suite) which extends :class:
dcgp::mes4cgp
for a multiobjective problem. The resulting algorithm, is outlined by the following pseudo-algorithm:> Start from a population (pop) of dimension N > while i < gen > > Mutation: create a new population pop2 mutating N times the best individual (only the integer part is affected) > > Life long learning: apply a one step of a second order Newton method to each individual (only the continuous part is affected) > > Reinsertion: set pop to contain the best N individuals taken from pop and pop2 according to non dominated sorting.
Public Types
-
typedef std::tuple<unsigned, unsigned long long, double, unsigned long long, double> log_line_type
Single entry of the log (gen, fevals, best loss, ndf size, max. complexity)
-
typedef std::vector<log_line_type> log_type
The log.
Public Functions
-
inline momes4cgp(unsigned gen = 1u, unsigned max_mut = 4u, double ftol = 0., unsigned seed = random_device::next())
Constructor.
Constructs a multi-objective memetic evolutionary strategy algorithm for use with a :class:
dcgp::symbolic_regression
UDP.- Parameters
gen – number of generations.
max_mut – maximum number of active genes to be mutated. The minimum is 0 as to allow multiple steps of Newton descent.
ftol – a stopping criterion on the achieved loss.
seed – seed used by the internal random number generator (default is random).
- Throws
std::invalid_argument – if mut_n is 0
-
inline pagmo::population evolve(pagmo::population pop) const
Algorithm evolve method.
Evolves the population for a maximum number of generations
- Parameters
pop – population to be evolved
- Throws
std::invalid_argument – if a :class:
dcgp::symbolic_regression
cannot be extracted from the problemstd::invalid_argument – if the population size is smaller than 2.
std::invalid_argument – if the number of objectives is smaller than 2.
- Returns
evolved population
-
inline void set_seed(unsigned seed)
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 10):
Gen is the generation number, Fevals the number of function evaluation used, Best loss is the best loss in the population, Ndf size is the size of the non dominated front (i.e. the number of models that are optimal) and compl. is the complexity of the lowest loss model.Gen: Fevals: Best loss: Ndf size: Compl.: 0 0 6.07319 3 92 10 1000 2.15419 5 10 20 2000 1.92403 8 33 30 3000 0.373663 12 72 40 4000 0.36954 13 72 50 5000 0.235749 16 73 60 6000 0.235749 12 73 70 7000 0.235749 13 73 80 8000 0.217968 12 75 90 9000 0.217968 12 75 100 10000 0.217968 12 75 110 11000 0.217968 14 75 120 12000 0.217968 14 75 130 13000 0.217968 13 75 140 14000 0.162293 12 52
- Parameters
level – verbosity level
-
inline unsigned get_verbosity() const
Gets the verbosity level.
- Returns
the verbosity level
-
inline std::string get_name() const
Algorithm name.
- Returns
a string containing the algorithm name
-
inline std::string get_extra_info() const
Extra info.
- 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 momes4cgp::log_line_type containing: Gen, Fevals, Best loss, Ndf size and Complexity described in momes4cgp::set_verbosity().- Returns
an
std::vector
of momes4cgp::log_line_type containing the logged values Gen, Fevals, Best loss, Ndf size * * and Complexity
-
typedef std::tuple<unsigned, unsigned long long, double, unsigned long long, double> log_line_type