Vita
evolution_strategy.h
Go to the documentation of this file.
1
13#if !defined(VITA_EVOLUTION_STRATEGY_H)
14#define VITA_EVOLUTION_STRATEGY_H
15
19
20namespace vita
21{
42template<class T,
43 template<class> class SS,
44 template<class> class CS,
45 template<class> class RS>
47{
48public:
50 : selection(pop, eva, *s), recombination(pop, eva, s),
51 replacement(pop, eva), pop_(pop), sum_(s)
52 {
53 Expects(s);
54 }
55
58 void log_strategy(unsigned, unsigned) const {}
59
64 static environment shape(const environment &env) { return env; }
65
67 void init() const {}
68
70 void after_generation() const {}
71
73 bool stop_condition() const { return false; }
74
75 static constexpr bool is_alps =
76 std::is_same<SS<T>, typename vita::selection::alps<T>>::value &&
77 std::is_same<RS<T>, typename vita::replacement::alps<T>>::value;
78
79 static constexpr bool is_de =
80 std::is_same<CS<T>, typename vita::recombination::de<T>>::value;
81
82public:
83 SS<T> selection;
84 CS<T> recombination;
85 RS<T> replacement;
86
87protected:
88 population<T> &pop_;
89 summary<T> *sum_;
90};
91
135template<class T, template<class> class CS>
137 selection::alps,
138 CS,
139 replacement::alps>
140{
141public:
142 using basic_alps_es::evolution_strategy::evolution_strategy;
143
144 void log_strategy(unsigned, unsigned) const;
145 void after_generation();
146
147 static environment shape(environment);
148};
149
150template<class T> using alps_es = basic_alps_es<T, recombination::base>;
151
155template<class T>
156class std_es : public evolution_strategy<T,
157 selection::tournament,
158 recombination::base,
159 replacement::tournament>
160{
161public:
162 using std_es::evolution_strategy::evolution_strategy;
163
164 bool stop_condition() const;
165
166 static environment shape(environment);
167};
168
172template<class T>
173class de_es : public evolution_strategy<T,
174 selection::random,
175 recombination::de,
176 replacement::tournament>
177{
178public:
179 using de_es::evolution_strategy::evolution_strategy;
180};
181
188template<class T>
189class de_alps_es : public basic_alps_es<T, recombination::de>
190{
191public:
192 using de_alps_es::basic_alps_es::basic_alps_es;
193};
194
195#include "kernel/evolution_strategy.tcc"
196} // namespace vita
197
198#endif // include guard
Basic ALPS strategy.
Differential evolution strategy enhanced with ALPS.
Differential evolution strategy.
Context object aggregating multiple related parameters into one structure.
Definition: environment.h:57
Calculates the fitness of an individual.
Definition: evaluator.h:54
Defines the skeleton of the evolution, deferring some steps to client subclasses.
void after_generation() const
Work to be done at the end of a generation.
bool stop_condition() const
Used to signal strategy specific stop conditions.
void log_strategy(unsigned, unsigned) const
Evolution strategy specific log function (it's called by the evolution::log method).
static environment shape(const environment &env)
Sets strategy-specific parameters.
void init() const
Initial setup performed before evolution starts.
A group of individuals which may interact together (for example by mating) producing offspring.
Definition: population.h:37
This is based on the differential evolution four members crossover.
ALPS based replacement scheme.
Alps selection as described in https://github.com/ghornby/alps (see also vita::basic_alps_es for furt...
Standard evolution strategy.
A summary of evolution (results, statistics...).
The main namespace for the project.