LoveBrains  1.0.0
population.h
1 /*
2 ** population.h for GAEngine in /home/robin_f/Programming/Git/CPP/GANNEngine/include/GA
3 **
4 ** Made by Guillaume ROBIN
5 ** Login <robin_f@epitech.eu>
6 **
7 ** Started on Wed Jul 8 14:00:38 2015 Guillaume ROBIN
8 ** Last update Fri Aug 21 22:41:24 2015 Guillaume ROBIN
9 */
10 
11 #ifndef POPULATION_H_
12 # define POPULATION_H_
13 
14 # include <vector>
15 # include <iostream>
16 
17 # include "GA/ga_config.h"
18 # include "GA/population_exception.h"
19 
20 namespace GA
21 {
26  class Population
27  {
28  public:
29  /*
30  ** Constructor & Destructor.
31  */
35  Population(void) throw();
42  Population(GAConfig const& config, unsigned int size);
46  ~Population(void) throw();
47 
48  /*
49  ** Overload.
50  */
51  Population& operator=(Population const& pop) throw();
52 
53  /*
54  ** Initializer.
55  */
56 
61  void Generate(void);
62 
63  /*
64  ** Getters.
65  */
66 
71  unsigned int getSize(void) const throw();
76  unsigned int getPoolSize(void) const throw();
81  double getMutationRate(void) const throw();
86  double getSelectionRate(void) const throw();
91  double getBestFitness(void) const throw();
96  double getAverageFitness(void) const throw();
101  GAConfig const& getConfig(void) const throw();
106  std::list<IDNA *> const& get(void) const throw();
111  std::list<IDNA *> & get(void) throw();
112 
113  /*
114  ** Setters.
115  */
116 
121  void setSize(unsigned int size);
126  void setPoolSize(unsigned int size);
131  void setMutationRate(double rate);
136  void setSelectionRate(double rate);
141  void setConfig(GAConfig const& config);
142 
143  /*
144  ** Genetic.
145  */
146 
152  void Evaluate(unsigned int nbThread);
156  void Selection(void) throw();
161  void Crossover(void);
166  void Mutation(void) throw();
167 
168  private:
169  unsigned int _size;
170  unsigned int _pool_size;
171  double _mutation_rate;
172  double _selection_rate;
173  double _best_fitness;
174  double _avg_fitness;
175  GAConfig _config;
176  std::list<IDNA *> _samples;
177  std::vector<IDNA *> _parents;
178  };
179 
180  std::ostream& operator<<(std::ostream& flux, Population const& p);
181 }
182 
183 #endif /* !POPULATION_H_ */
unsigned int getSize(void) const
Get the population size member.
Definition: population.cc:86
Population(void)
Constructor.
Definition: population.cc:24
void setConfig(GAConfig const &config)
Set the GAEngine's configuration.
Definition: population.cc:162
void Crossover(void)
Do te crossover of the population.
Definition: population.cc:289
Define what is a population for the GAEngine.
Definition: population.h:26
void Evaluate(unsigned int nbThread)
Evaluate the population.
Definition: population.cc:172
void setSelectionRate(double rate)
Set the selection rate.
Definition: population.cc:155
Contains the objects that define the GAEngine.
void Generate(void)
Generator the entire population.
Definition: population.cc:70
void setMutationRate(double rate)
Set the mutation rate.
Definition: population.cc:148
unsigned int getPoolSize(void) const
Get the pool size member.
Definition: population.cc:91
void Selection(void)
Do the selection of the population in order to generate the next population.
Definition: population.cc:247
Define the configuration of the GAEngine.
Definition: ga_config.h:24
double getBestFitness(void) const
Get the best fitness contained in the population.
Definition: population.cc:106
double getMutationRate(void) const
Get the mutation rate member.
Definition: population.cc:96
double getAverageFitness(void) const
Get the average fitness of the population.
Definition: population.cc:111
~Population(void)
Destructor.
Definition: population.cc:42
double getSelectionRate(void) const
Get the selection rate member.
Definition: population.cc:101
void setPoolSize(unsigned int size)
Set the pool size.
Definition: population.cc:141
void Mutation(void)
Do the mutation of the population.
Definition: population.cc:335
GAConfig const & getConfig(void) const
Get the configuration of the GAEngine.
Definition: population.cc:116
void setSize(unsigned int size)
Set the population size.
Definition: population.cc:134