PaGMO
1.1.5
|
Base algorithm class. More...
#include <base.h>
Public Member Functions | |
base () | |
Default constructor. More... | |
virtual void | evolve (population &p) const =0 |
Evolve method. More... | |
virtual base_ptr | clone () const =0 |
Clone method. More... | |
virtual | ~base () |
Trivial destructor. More... | |
std::string | human_readable () const |
Return human readable representation of the algorithm. More... | |
virtual std::string | get_name () const |
Get algorithm's name. More... | |
virtual std::string | human_readable_extra () const |
Extra information in human readable format. More... | |
void | set_screen_output (const bool p) |
Setter-Getter for protected m_screen_output data. More... | |
bool | get_screen_output () const |
Gets screen output. More... | |
void | reset_rngs (const unsigned int) const |
Resets the seed of the internal rngs using a user-provided seed. More... | |
Protected Attributes | |
bool | m_screen_output |
Indicates to the derived class whether to print stuff on screen. | |
rng_double | m_drng |
Random number generator for double-precision floating point values. | |
rng_uint32 | m_urng |
Random number generator for unsigned integer values. | |
unsigned int | m_fevals |
A counter for the number of function evaluations. | |
Friends | |
class | boost::serialization::access |
Base algorithm class.
All algorithms implemented in PaGMO must derive from this base class. This base class provides each algorithm with one pagmo::rng_double and one pagmo::rng_uint32 random number generators. Each algorithm must implement the base::evolve() method.
The algorithm classes are serialized for the purpose of being transmitted over a distributed environment. Serializing a derived algorithm requires that the needed serialization libraries be declared in their header of the derived class. Virtually all the derived algorithm classes need to have the following declared in the header files:
friend class boost::serialization::access; template<class Archive>
Each derived class must implement implicitly, in its header file, the serialize method, which must contain the pointer to the base class like:
ar & boost::serialization::base_object<base>(*this);
and the rest of the attributes simply as archive members:
ar & attribute_name;
In order to be able to identify the dervied class from a base_pointer the derived class needs to be registered. This is done by registering the class in the "pagmo/src/algorithms.h", in the REGISTER_ALGORITHM_SERIALIZATIONS() routine. Notes:
Definition at line 81 of file algorithm/base.h.
pagmo::algorithm::base::base | ( | ) |
Default constructor.
Will initialise the internal random number generators using seeds provided by the thread-safe pagmo::static_rng_uint32.
Definition at line 42 of file algorithm/base.cpp.
|
virtual |
|
pure virtual |
Clone method.
Provided that the derived algorithm implements properly the copy constructor, virtually all implementations of this method will look like this:
return base_ptr(new derived_algorithm(*this));
@return algorithm::base_ptr to a copy of this.
Implemented in pagmo::algorithm::cstrs_immune_system, pagmo::algorithm::sga, pagmo::algorithm::vega, pagmo::algorithm::spea2, pagmo::algorithm::mbh, pagmo::algorithm::cstrs_co_evolution, pagmo::algorithm::pso, pagmo::algorithm::de, pagmo::algorithm::sga_gray, pagmo::algorithm::moead, pagmo::algorithm::pade, pagmo::algorithm::snopt, pagmo::algorithm::ipopt, pagmo::algorithm::nlopt_slsqp, pagmo::algorithm::jde, pagmo::algorithm::cs, pagmo::algorithm::ihs, pagmo::algorithm::mde_pbx, pagmo::algorithm::cstrs_core, pagmo::algorithm::firefly, pagmo::algorithm::inverover, pagmo::algorithm::ms, pagmo::algorithm::nlopt_mma, pagmo::algorithm::nspso, pagmo::algorithm::cstrs_self_adaptive, pagmo::algorithm::nlopt_aug_lag_eq, pagmo::algorithm::bee_colony, pagmo::algorithm::de_1220, pagmo::algorithm::sa_corana, pagmo::algorithm::nlopt_aug_lag, pagmo::algorithm::sea, pagmo::algorithm::nlopt_sbplx, pagmo::algorithm::pso_generational, pagmo::algorithm::nsga2, pagmo::algorithm::cmaes, pagmo::algorithm::sms_emoa, pagmo::algorithm::nn_tsp, pagmo::algorithm::gsl_bfgs, pagmo::algorithm::gsl_bfgs2, pagmo::algorithm::gsl_fr, pagmo::algorithm::gsl_pr, pagmo::algorithm::monte_carlo, pagmo::algorithm::null, pagmo::algorithm::pso_generational_racing, pagmo::algorithm::gsl_nm, pagmo::algorithm::gsl_nm2, pagmo::algorithm::gsl_nm2rand, pagmo::algorithm::nlopt_bobyqa, and pagmo::algorithm::nlopt_cobyla.
|
pure virtual |
Evolve method.
The purpose of this method is to take a pagmo::population as input and evolve it towards the solution of the problem.
[in,out] | p | population to be evolved. |
Implemented in pagmo::algorithm::cstrs_immune_system, pagmo::algorithm::sga, pagmo::algorithm::vega, pagmo::algorithm::spea2, pagmo::algorithm::cstrs_co_evolution, pagmo::algorithm::mbh, pagmo::algorithm::pso, pagmo::algorithm::de, pagmo::algorithm::sga_gray, pagmo::algorithm::moead, pagmo::algorithm::pade, pagmo::algorithm::snopt, pagmo::algorithm::ipopt, pagmo::algorithm::cstrs_core, pagmo::algorithm::jde, pagmo::algorithm::cs, pagmo::algorithm::ihs, pagmo::algorithm::mde_pbx, pagmo::algorithm::cstrs_self_adaptive, pagmo::algorithm::firefly, pagmo::algorithm::inverover, pagmo::algorithm::ms, pagmo::algorithm::nspso, pagmo::algorithm::base_nlopt, pagmo::algorithm::bee_colony, pagmo::algorithm::de_1220, pagmo::algorithm::sa_corana, pagmo::algorithm::sea, pagmo::algorithm::pso_generational, pagmo::algorithm::gsl_gradient, pagmo::algorithm::nsga2, pagmo::algorithm::sms_emoa, pagmo::algorithm::cmaes, pagmo::algorithm::gsl_derivative_free, pagmo::algorithm::nn_tsp, pagmo::algorithm::monte_carlo, pagmo::algorithm::null, and pagmo::algorithm::pso_generational_racing.
|
virtual |
Get algorithm's name.
Default implementation will return the algorithm's mangled C++ name.
Reimplemented in pagmo::algorithm::cstrs_immune_system, pagmo::algorithm::sga, pagmo::algorithm::vega, pagmo::algorithm::pso, pagmo::algorithm::spea2, pagmo::algorithm::cstrs_co_evolution, pagmo::algorithm::mbh, pagmo::algorithm::de, pagmo::algorithm::sga_gray, pagmo::algorithm::snopt, pagmo::algorithm::moead, pagmo::algorithm::pade, pagmo::algorithm::ipopt, pagmo::algorithm::cstrs_core, pagmo::algorithm::jde, pagmo::algorithm::nlopt_slsqp, pagmo::algorithm::cs, pagmo::algorithm::ihs, pagmo::algorithm::mde_pbx, pagmo::algorithm::cstrs_self_adaptive, pagmo::algorithm::firefly, pagmo::algorithm::inverover, pagmo::algorithm::ms, pagmo::algorithm::nspso, pagmo::algorithm::nlopt_mma, pagmo::algorithm::bee_colony, pagmo::algorithm::de_1220, pagmo::algorithm::nlopt_aug_lag_eq, pagmo::algorithm::sa_corana, pagmo::algorithm::nlopt_aug_lag, pagmo::algorithm::sea, pagmo::algorithm::pso_generational, pagmo::algorithm::nlopt_sbplx, pagmo::algorithm::nsga2, pagmo::algorithm::sms_emoa, pagmo::algorithm::cmaes, pagmo::algorithm::nn_tsp, pagmo::algorithm::monte_carlo, pagmo::algorithm::null, pagmo::algorithm::gsl_bfgs, pagmo::algorithm::gsl_bfgs2, pagmo::algorithm::gsl_fr, pagmo::algorithm::gsl_pr, pagmo::algorithm::pso_generational_racing, pagmo::algorithm::gsl_nm, pagmo::algorithm::gsl_nm2, pagmo::algorithm::gsl_nm2rand, pagmo::algorithm::nlopt_bobyqa, and pagmo::algorithm::nlopt_cobyla.
Definition at line 56 of file algorithm/base.cpp.
bool pagmo::algorithm::base::get_screen_output | ( | ) | const |
Gets screen output.
Gets screen output boolean variable. When True the algorithm may print stuff on screen (careful, in multithreading this can mess up things)
return boolean value associated to the screen output option
Definition at line 76 of file algorithm/base.cpp.
std::string pagmo::algorithm::base::human_readable | ( | ) | const |
Return human readable representation of the algorithm.
Will return a formatted string containing the algorithm name from get_name(). The output of human_readable_extra() will be appended at the end of the string.
Definition at line 96 of file algorithm/base.cpp.
|
virtual |
Extra information in human readable format.
Default implementation returns an empty string.
Reimplemented in pagmo::algorithm::cstrs_immune_system, pagmo::algorithm::sga, pagmo::algorithm::vega, pagmo::algorithm::snopt, pagmo::algorithm::cstrs_co_evolution, pagmo::algorithm::spea2, pagmo::algorithm::pso, pagmo::algorithm::mbh, pagmo::algorithm::cmaes, pagmo::algorithm::de, pagmo::algorithm::moead, pagmo::algorithm::pade, pagmo::algorithm::cstrs_core, pagmo::algorithm::sga_gray, pagmo::algorithm::ipopt, pagmo::algorithm::jde, pagmo::algorithm::de_1220, pagmo::algorithm::cs, pagmo::algorithm::cstrs_self_adaptive, pagmo::algorithm::ihs, pagmo::algorithm::mde_pbx, pagmo::algorithm::ms, pagmo::algorithm::inverover, pagmo::algorithm::firefly, pagmo::algorithm::nspso, pagmo::algorithm::bee_colony, pagmo::algorithm::nlopt_aug_lag_eq, pagmo::algorithm::sa_corana, pagmo::algorithm::base_nlopt, pagmo::algorithm::nlopt_aug_lag, pagmo::algorithm::sea, pagmo::algorithm::pso_generational, pagmo::algorithm::nsga2, pagmo::algorithm::sms_emoa, pagmo::algorithm::gsl_gradient, pagmo::algorithm::gsl_derivative_free, and pagmo::algorithm::pso_generational_racing.
Definition at line 113 of file algorithm/base.cpp.
void pagmo::algorithm::base::reset_rngs | ( | const unsigned int | p | ) | const |
Resets the seed of the internal rngs using a user-provided seed.
Resets the random number generators.
Resets the seed of the internal random number generators to p
[in] | p | the new seed. It will be used to instantiate both drng and urng |
Definition at line 84 of file algorithm/base.cpp.
void pagmo::algorithm::base::set_screen_output | ( | const bool | p | ) |
Setter-Getter for protected m_screen_output data.
Sets screen output.
Sets screen output boolean variable. When True the algorithm may print stuff on screen (careful, in multithreading this can mess up things)
[in] | p | true or false |
Definition at line 67 of file algorithm/base.cpp.