Vita
evolution.h
Go to the documentation of this file.
1
13#if !defined(VITA_EVOLUTION_H)
14#define VITA_EVOLUTION_H
15
16#include <algorithm>
17#include <csignal>
18
22#include "kernel/population.h"
23#include "utility/timer.h"
24
25namespace vita
26{
38template<class T, template<class> class ES>
40{
41public:
42 using after_generation_callback_t = std::function<void(const population<T> &,
43 const summary<T> &)>;
44
45 evolution(const problem &, evaluator<T> &);
46
47 evolution &after_generation(after_generation_callback_t);
48
49 const summary<T> &run(unsigned);
50 template<class S> const summary<T> &run(unsigned, S);
51
52 bool is_valid() const;
53
54private:
55 // *** Support methods ***
56 analyzer<T> get_stats() const;
57 void log_evolution(unsigned) const;
58 void print_progress(unsigned, unsigned, bool, timer *) const;
59 bool stop_condition(const summary<T> &) const;
60
61 // *** Data members ***
62 population<T> pop_;
63 evaluator<T> &eva_;
64 summary<T> stats_;
65 ES<T> es_;
66
67 after_generation_callback_t after_generation_callback_;
68};
69
70#include "kernel/evolution.tcc"
71
76} // namespace vita
77
78#endif // include guard
Analyzer takes a statistics snapshot of a population.
Definition: analyzer.h:44
Calculates the fitness of an individual.
Definition: evaluator.h:54
Progressively evolves a population of programs over a series of generations.
Definition: evolution.h:40
A group of individuals which may interact together (for example by mating) producing offspring.
Definition: population.h:37
Aggregates the problem-related data needed by an evolutionary program.
Definition: problem.h:24
A summary of evolution (results, statistics...).
The main namespace for the project.
value_t run(const T &ind)
A handy short-cut for one-time execution of an individual.