PaGMO
1.1.5
|
The Simple Genetic Algorithm with gray encoding (sga_gray) More...
#include <sga_gray.h>
Data Structures | |
struct | crossover |
Crossover operator info. More... | |
struct | mutation |
Mutation operator info. More... | |
struct | selection |
Selection info. More... | |
Public Member Functions | |
sga_gray (int gen=1, const double &cr=.95, const double &m=.02, int elitism=1, mutation::type mut=mutation::UNIFORM, selection::type sel=selection::ROULETTE, crossover::type cro=crossover::SINGLE_POINT) | |
Constructor. More... | |
base_ptr | clone () const |
Clone method. | |
void | evolve (population &) const |
Evolve implementation. More... | |
std::string | get_name () const |
Algorithm name. | |
Public Member Functions inherited from pagmo::algorithm::base | |
base () | |
Default constructor. More... | |
virtual | ~base () |
Trivial destructor. More... | |
std::string | human_readable () const |
Return human readable representation of the algorithm. 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 Member Functions | |
std::string | human_readable_extra () const |
Extra human readable algorithm info. More... | |
Friends | |
class | boost::serialization::access |
Additional Inherited Members | |
Protected Attributes inherited from pagmo::algorithm::base | |
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. | |
The Simple Genetic Algorithm with gray encoding (sga_gray)
Simple Genetic algorithms are very popular algorithms used widely by people of very different backgrounds. Contrary to PAGMO::SGA, this implementation uses a binary encoding and some common mutation and crossover strategies.
Mutation is random, crossover uniform and selection is roulette or best20 (i.e. 20% best of the population is selected and reproduced 5 times).
The algorithm works on single objective, box constrained problems.
Definition at line 50 of file sga_gray.h.
pagmo::algorithm::sga_gray::sga_gray | ( | int | gen = 1 , |
const double & | cr = .95 , |
||
const double & | m = .02 , |
||
int | elitism = 1 , |
||
mutation::type | mut = mutation::UNIFORM , |
||
selection::type | sel = selection::ROULETTE , |
||
crossover::type | cro = crossover::SINGLE_POINT |
||
) |
Constructor.
Allows to specify in detail all the parameters of the algorithm.
[in] | gen | Number of generations to evolve. |
[in] | cr | Crossover probability (of each individual) |
[in] | m | Mutation probability (of each encoded bit) |
[in] | elitism | the best individual is reinserted in the population each elitism generations. If a elitism of 0 is set, then the elitism is avoided. |
[in] | mut | Mutation type. sga_gray::mutation::UNIFORM |
[in] | sel | Selection type. One of sga_gray::selection::BEST20, sga_gray::selection::ROULETTE |
[in] | cro | Crossover type. One of sga_gray::crossover::SINGLE_POINT |
value_error | if gen is negative, crossover probability is not , mutation probability is not , elitism is <=0 |
Definition at line 59 of file sga_gray.cpp.
|
virtual |
Evolve implementation.
Run the simple genetic algorithm for the number of generations specified in the constructors. At each improvment velocity is also updated.
[in,out] | pop | input/output pagmo::population to be evolved. |
We now set the cleared pop. cur_x is the best_x, re-evaluated with new seed.
Implements pagmo::algorithm::base.
Definition at line 92 of file sga_gray.cpp.
|
protectedvirtual |
Extra human readable algorithm info.
Will return a formatted string displaying the parameters of the algorithm.
Reimplemented from pagmo::algorithm::base.
Definition at line 233 of file sga_gray.cpp.