PaGMO  1.1.5
Data Structures | Public Member Functions | Protected Member Functions | Friends
pagmo::algorithm::sga Class Reference

The Simple Genetic Algorithm (SGA) More...

#include <sga.h>

Inheritance diagram for pagmo::algorithm::sga:
Inheritance graph
[legend]

Data Structures

struct  crossover
 Crossover operator info. More...
 
struct  mutation
 Mutation operator info. More...
 
struct  selection
 Selection info. More...
 

Public Member Functions

 sga (int gen=1, const double &cr=.95, const double &m=.02, int elitism=1, mutation::type mut=mutation::GAUSSIAN, double width=0.1, selection::type sel=selection::ROULETTE, crossover::type cro=crossover::EXPONENTIAL)
 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.
 

Detailed Description

The Simple Genetic Algorithm (SGA)

Genetic algorithms are very popular algorithms used widely by people of very different backgrounds. As a consequence there are a large number of different implementations and toolboxes that are available and can be used to construct a genetic algorithm. We decided not to choose one of these and, instead, to provide only a basic implementation of the algorithm implementing a floating point encoding (not binary) and some common mutation and crossover strategies, hence the name Simple Genetic Algorithm.

Mutation is gaussian or random, crossover exponential or binomial and selection is tournament or best20 (i.e. 20% best of the population is selcted and reproduced 5 times).

The algorithm works on single objective, box constrained problems. The mutation operator acts differently on continuous and discrete variables.

Author
Dario Izzo (dario.nosp@m..izz.nosp@m.o@goo.nosp@m.glem.nosp@m.ail.c.nosp@m.om)

Definition at line 53 of file sga.h.

Constructor & Destructor Documentation

pagmo::algorithm::sga::sga ( int  gen = 1,
const double &  cr = .95,
const double &  m = .02,
int  elitism = 1,
mutation::type  mut = mutation::GAUSSIAN,
double  width = 0.1,
selection::type  sel = selection::ROULETTE,
crossover::type  cro = crossover::EXPONENTIAL 
)

Constructor.

Allows to specify in detail all the parameters of the algorithm.

Parameters
[in]genNumber of generations to evolve.
[in]crCrossover probability (of each allele if binomial crossover)
[in]mMutation probability (of each allele)
[in]elitismThe best individual is reinserted in the population each elitism generations
[in]mutMutation type. One of sga::mutation::GAUSSIAN, sga::mutation::RANDOM
[in]widthMutation width. When gaussian mutation is selected is the width of the mutation
[in]selSelection type. One of sga::selection::BEST20, sga::selection::ROULETTE
[in]croCrossover type. One of sga::crossover::BINOMIAL, sga::crossover::EXPONENTIAL
Exceptions
value_errorif gen is negative, crossover probability is not $ \in [0,1]$, mutation probability is not $ \in [0,1]$, elitism is <=0

Definition at line 59 of file sga.cpp.

Member Function Documentation

void pagmo::algorithm::sga::evolve ( population pop) const
virtual

Evolve implementation.

Run the simple genetic algorithm for the number of generations specified in the constructors. At each improvment velocity is also updated.

Parameters
[in,out]popinput/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 94 of file sga.cpp.

std::string pagmo::algorithm::sga::human_readable_extra ( ) const
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 368 of file sga.cpp.


The documentation for this class was generated from the following files: