LoveBrains  1.0.0
ga_config.h
1 /*
2 ** i_config.h for GAEngine in /home/robin_f/Programming/Git/CPP/GAEngine
3 **
4 ** Made by Guillaume ROBIN
5 ** Login <robin_f@epitech.eu>
6 **
7 ** Started on Tue Jul 21 13:02:43 2015 Guillaume ROBIN
8 ** Last update Fri Aug 21 16:55:48 2015 Guillaume ROBIN
9 */
10 
11 #ifndef GA_CONFIG_H_
12 # define GA_CONFIG_H_
13 
14 # include <list>
15 
16 # include "GA/i_generator.h"
17 
18 namespace GA
19 {
24  class GAConfig
25  {
26  public:
27  /*
28  ** Typedef.
29  */
30 
34  typedef void (*FEvaluate)(std::list<IDNA *>&);
38  typedef void (*DNAFitness)(IDNA *, double *);
42  typedef bool (*DNACompare)(const IDNA *, const IDNA *);
46  typedef IDNA *(*DNACrossover)(const IDNA *, const IDNA *);
50  typedef void (*DNAMutate)(IDNA *);
51 
55  GAConfig(void);
59  ~GAConfig(void);
60 
61  GAConfig& operator=(GAConfig const& config);
62 
68  bool isEvaluated(void) const;
74  bool isValid(void) const;
75 
80  void setEvaluation(FEvaluate function);
85  void setGenerator(IGenerator *generator);
90  void setDNAFitness(DNAFitness function);
95  void setDNACompare(DNACompare function);
100  void setDNACrossover(DNACrossover function);
105  void setDNAMutate(DNAMutate function);
106 
111  FEvaluate getEvaluation(void) const;
116  IGenerator *getGenerator(void) const;
121  DNAFitness getDNAFitness(void) const;
126  DNACompare getDNACompare(void) const;
131  DNACrossover getDNACrossover(void) const;
136  DNAMutate getDNAMutate(void) const;
137 
138  private:
139  FEvaluate _evaluate;
140  IGenerator *_generator;
141  DNAFitness _fitness;
142  DNACompare _compare;
143  DNACrossover _crossover;
144  DNAMutate _mutate;
145  };
146 }
147 
148 #endif /* !GA_CONFIG_H_ */
void setDNACrossover(DNACrossover function)
Set the crossover function pointer.
Definition: ga_config.cc:89
bool isValid(void) const
Return if the configuration is valid.
Definition: ga_config.cc:51
DNAFitness getDNAFitness(void) const
Get the function pointer to evaluate the fitness.
Definition: ga_config.cc:112
DNACrossover getDNACrossover(void) const
Get the function pointer to cross two IDNA.
Definition: ga_config.cc:122
Define the interface that will be used to create an supported individual for the GAEngine.
Definition: i_dna.h:22
Define the interface that allow to define a new generator of individual for the GAEngine.
Definition: i_generator.h:22
Contains the objects that define the GAEngine.
void setDNACompare(DNACompare function)
Set the function pointer to compare two IDNA.
Definition: ga_config.cc:84
void setGenerator(IGenerator *generator)
Set the generator.
Definition: ga_config.cc:74
GAConfig(void)
Constructor.
Definition: ga_config.cc:20
void setDNAFitness(DNAFitness function)
Set the fitness function pointer.
Definition: ga_config.cc:79
void setDNAMutate(DNAMutate function)
Set the mutation function pointer.
Definition: ga_config.cc:94
Define the configuration of the GAEngine.
Definition: ga_config.h:24
~GAConfig(void)
Destructor.
Definition: ga_config.cc:25
void(* DNAFitness)(IDNA *, double *)
Function pointer that define the evaluation of an AI.
Definition: ga_config.h:38
DNAMutate getDNAMutate(void) const
Get the function pointer to mutate an IDNA object.
Definition: ga_config.cc:127
bool isEvaluated(void) const
Return if the function pointer, setted in order to evaluate the population, is not NULL...
Definition: ga_config.cc:46
void setEvaluation(FEvaluate function)
Set the evaluation function pointer.
Definition: ga_config.cc:69
IGenerator * getGenerator(void) const
Get the generator member.
Definition: ga_config.cc:107
bool(* DNACompare)(const IDNA *, const IDNA *)
Function pointer that define how to compare two IDNA.
Definition: ga_config.h:42
void(* DNAMutate)(IDNA *)
Function pointer that define how to mutate a IDNA.
Definition: ga_config.h:50
IDNA *(* DNACrossover)(const IDNA *, const IDNA *)
Function pointer that define how to cross two IDNA.
Definition: ga_config.h:46
DNACompare getDNACompare(void) const
Get the function pointer to compare two IDNA.
Definition: ga_config.cc:117
void(* FEvaluate)(std::list< IDNA * > &)
Function pointer to evaluate the population.
Definition: ga_config.h:34
FEvaluate getEvaluation(void) const
Get the evaluation function pointer.
Definition: ga_config.cc:102