GeneticAlgoithm
Implementation of the genetic algorithm
Public Member Functions | Private Attributes | List of all members
GeneticAlgorithm Class Reference

Class imlementing the Genetic Algorithm. More...

#include <GeneticAlgorithm.h>

Collaboration diagram for GeneticAlgorithm:
Collaboration graph
[legend]

Public Member Functions

 GeneticAlgorithm ()
 
 ~GeneticAlgorithm ()
 
IModeloptimize (IPopulation *population)
 
void initialize (IPopulation *population)
 
bool nextGeneration ()
 
int getCurrentGeneration ()
 
void setNGenerationsMax (int generationsMax)
 
void setPopulationSize (int populationSize)
 

Private Attributes

int m_generationsMax
 Stores the maximum number of generations.
 
int m_populationSize
 Stores the desired population size.
 
int m_currentGeneration
 Stores the number of the current generation.
 
IPopulationm_population
 Stores a pointer to the population being optimized.
 

Detailed Description

Class imlementing the Genetic Algorithm.

There is no need to derive from this class: the implementation is built on top of the IModel, IFigureOfMerit and IPopulation interfaces.

The algorithm flow is as follows:

Definition at line 23 of file GeneticAlgorithm.h.

Constructor & Destructor Documentation

◆ GeneticAlgorithm()

GeneticAlgorithm::GeneticAlgorithm ( )

Default Constructor

Definition at line 6 of file GeneticAlgorithm.cxx.

◆ ~GeneticAlgorithm()

GeneticAlgorithm::~GeneticAlgorithm ( )

Destructor

Definition at line 12 of file GeneticAlgorithm.cxx.

Member Function Documentation

◆ optimize()

IModel * GeneticAlgorithm::optimize ( IPopulation population)

Finds the best solution given a population of models.

Parameters
populationPopulation of models to optimize.
Returns
Best fitted model after optimization.

Definition at line 20 of file GeneticAlgorithm.cxx.

◆ initialize()

void GeneticAlgorithm::initialize ( IPopulation population)

Initialize the algorithm before the optimization loop starts.

This function is provided so that the user have the option to control the optimization loop and possibly execute some code before/after each iteration. This can be useful for example to implement tests that need to monitor the progress of the optimization.

Parameters
populationPopulation of models to optimize.

Definition at line 37 of file GeneticAlgorithm.cxx.

◆ nextGeneration()

bool GeneticAlgorithm::nextGeneration ( )

Perform one iteration of the optimization loop: creates next generation of models.

This function is provided so that the user have the option to control the optimization loop and possibly execute some code before/after each iteration. This can be useful for example to implement tests that need to monitor the progress of the optimization.

Returns
true if more generations are needed, false if optimal solution has been reached.

Definition at line 53 of file GeneticAlgorithm.cxx.

◆ getCurrentGeneration()

int GeneticAlgorithm::getCurrentGeneration ( )

Returns the current generation number.

Returns
Number of the current generation.

Definition at line 75 of file GeneticAlgorithm.cxx.

◆ setNGenerationsMax()

void GeneticAlgorithm::setNGenerationsMax ( int  generationsMax)

Sets the maximum number of generations before giving up.

Parameters
Desiredmaximum number of iterations.

Definition at line 83 of file GeneticAlgorithm.cxx.

◆ setPopulationSize()

void GeneticAlgorithm::setPopulationSize ( int  populationSize)

Sets the population size

Parameters
Desiredpopulation size.

Definition at line 92 of file GeneticAlgorithm.cxx.


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