LoveBrains  1.0.0
ga_engine.h
1 /*
2 ** ga_engine.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:02:16 2015 Guillaume ROBIN
8 ** Last update Fri Aug 21 17:13:25 2015 Guillaume ROBIN
9 */
10 
11 #ifndef GA_ENGINE_H_
12 # define GA_ENGINE_H_
13 
14 # include "GA/ga_engine_exception.h"
15 # include "GA/population.h"
16 # include "GA/a_observer.h"
17 
18 namespace GA
19 {
24  class GAEngine : public AObserver
25  {
26  public:
27  /*
28  ** Constructor & Destructor.
29  */
30 
34  GAEngine(void) throw();
38  ~GAEngine(void) throw();
39 
40  /*
41  ** Getters.
42  */
43 
48  Population const& getPopulation(void) const throw();
53  Population& getPopulation(void) throw();
58  double getMutationRate(void) const throw();
63  double getSelectionRate(void) const throw();
68  unsigned int getPoolSize(void) const throw();
73  GA::GAConfig::FEvaluate getEvaluation(void) const throw();
78  int getMaxEpochs(void) const throw();
83  unsigned int getReportInterval(void) const throw();
88  unsigned int getNumberOfThread(void) const throw();
93  double getExpectedFitness(void) const throw();
94 
95  /*
96  ** Setters.
97  */
98 
103  void setMaxEpochs(int max) throw();
108  void setExpectedFitness(double fitness) throw();
113  void setNumberOfThreads(unsigned int nb) throw();
118  void setReportInterval(unsigned int nb) throw();
124  void setMutationRate(double rate);
130  void setSelectionRate(double rate);
136  void setPoolSize(unsigned int size);
137 
138  /*
139  ** Overload.
140  */
141  GAEngine& operator=(GAEngine const& engine);
142 
143  /*
144  ** Methods : CreatePopulation.
145  */
146 
153  void CreatePopulation(GAConfig const& config, unsigned int size);
160  unsigned int Evolve(bool report);
161 
162  private:
163  GA::GAConfig::FEvaluate _evaluate;
164  int _max_epochs;
165  unsigned int _report_interval;
166  unsigned int _nb_threads;
167  double _expected_fitness;
168  Population _pop;
169  };
170 }
171 
172 #endif /* !GA_ENGINE_H_ */
void setNumberOfThreads(unsigned int nb)
Set the number of threads used to evaluate the population.
Definition: ga_engine.cc:100
void setExpectedFitness(double fitness)
Set the expected fitness.
Definition: ga_engine.cc:95
void CreatePopulation(GAConfig const &config, unsigned int size)
Create a new population in terms of the configuration.
Definition: ga_engine.cc:165
GA::GAConfig::FEvaluate getEvaluation(void) const
Get the evaluation function pointer.
Definition: ga_engine.cc:62
Define what is a population for the GAEngine.
Definition: population.h:26
Contains the objects that define the GAEngine.
GAEngine(void)
Constructor.
Definition: ga_engine.cc:21
void setMaxEpochs(int max)
Set the maximum epochs.
Definition: ga_engine.cc:90
Manage the evolution of a population composed of IDNA objects.
Definition: ga_engine.h:24
unsigned int getReportInterval(void) const
Get the interval between each report.
Definition: ga_engine.cc:72
double getSelectionRate(void) const
Get the selection rate member.
Definition: ga_engine.cc:52
Population const & getPopulation(void) const
Get the GA::Population member.
Definition: ga_engine.cc:37
Define the configuration of the GAEngine.
Definition: ga_config.h:24
double getExpectedFitness(void) const
Get the expected fitness member.
Definition: ga_engine.cc:82
void setSelectionRate(double rate)
Set the selection rate.
Definition: ga_engine.cc:124
unsigned int getPoolSize(void) const
Get the pool size member.
Definition: ga_engine.cc:57
void setReportInterval(unsigned int nb)
Set the interval between each report.
Definition: ga_engine.cc:105
unsigned int Evolve(bool report)
Run the evolution of the population.
Definition: ga_engine.cc:185
void setMutationRate(double rate)
Set the mutation rate.
Definition: ga_engine.cc:112
Define the abstract class that allow to be an observer.
Definition: a_observer.h:20
unsigned int getNumberOfThread(void) const
Get the number of threads used to evaluate the population.
Definition: ga_engine.cc:77
int getMaxEpochs(void) const
Get the maximum epochs member.
Definition: ga_engine.cc:67
void(* FEvaluate)(std::list< IDNA * > &)
Function pointer to evaluate the population.
Definition: ga_config.h:34
double getMutationRate(void) const
Get the mutation rate member.
Definition: ga_engine.cc:47
~GAEngine(void)
Destructor.
Definition: ga_engine.cc:30
void setPoolSize(unsigned int size)
Set the pool size for the tournament.
Definition: ga_engine.cc:136