Vita
environment.h
Go to the documentation of this file.
1
13#if !defined(VITA_ENVIRONMENT_H)
14#define VITA_ENVIRONMENT_H
15
16#include <cmath>
17#include <filesystem>
18#include <string>
19
20#include "tinyxml2/tinyxml2.h"
21
22#include "kernel/alps.h"
24#include "kernel/log.h"
25#include "kernel/range.h"
26#include "kernel/symbol_set.h"
27#include "kernel/trilean.h"
28
29#include "utility/facultative.h"
30
31namespace vita
32{
33
34namespace out
35{
37enum print_format_t {list_f, // default value
38 dump_f, graphviz_f, in_line_f, tree_f,
39 language_f,
40 c_language_f = language_f + symbol::c_format,
41 cpp_language_f = language_f + symbol::cpp_format,
42 mql_language_f = language_f + symbol::mql_format,
43 python_language_f = language_f + symbol::python_format};
44}
45
57{
58public:
59 // Constructor and support functions
60 explicit environment();
61
62 void xml(tinyxml2::XMLDocument *) const;
64
65 // Serialization
66 //bool load(std::istream &) {}
67 //bool save(std::ostream &) const;
68
69 bool is_valid(bool) const;
70
72 {
80 std::size_t code_length = 0;
81
86 std::size_t patch_length = 0;
87 } mep;
88
98 unsigned layers = 0;
99
103 unsigned individuals = 0;
104
111 unsigned min_individuals = 0;
112
116 trilean elitism = trilean::unknown;
117
132 double p_mutation = -1.0;
133
137 double p_cross = -1.0;
138
157 // - `1` is the standard recombination (perform 1 crossover);
158 // - larger values enable the brood recombination method (more than one
159 // crossover).
161
172 unsigned tournament_size = 0;
173
182 facultative<unsigned> dss = {};
183
197 unsigned mate_zone = 0;
198
202 unsigned generations = 0;
203
208 facultative<unsigned, 0> max_stuck_time = {};
209
217 facultative<unsigned> validation_percentage = {};
218
220 unsigned cache_size = 16;
221
223 {
226 std::string serialization_file = "";
227 } misc;
228
230 {
234 std::filesystem::path dir = {};
235
238 std::filesystem::path dynamic_file = {};
239
242 std::filesystem::path layers_file = {};
243
248 std::filesystem::path population_file = {};
249
252 std::filesystem::path summary_file = {};
253
256 std::filesystem::path test_file = {};
257
260 } stat;
261
267
269
271 {
279 } de;
280
282 {
285 unsigned individuals = 3;
286 } team;
287}; // class environment
288
289} // namespace vita
290
291#endif // include guard
Dynamic training Subset Selection.
Definition: dss.h:38
Context object aggregating multiple related parameters into one structure.
Definition: environment.h:57
model_measurements threshold
Used to identify successfully learned (matched, classified, resolved...) examples.
Definition: environment.h:266
unsigned individuals
Number of individuals in a layer of the population.
Definition: environment.h:103
bool is_valid(bool) const
Definition: environment.cc:127
void xml(tinyxml2::XMLDocument *) const
Saves the environment in XML format.
Definition: environment.cc:69
facultative< unsigned, 0 > max_stuck_time
Used by some evolution strategies to stop a run when there aren't improvements within max_stuck_time ...
Definition: environment.h:208
unsigned mate_zone
This is used for the trivial geography scheme.
Definition: environment.h:197
unsigned generations
Maximun number of generations allowed before terminate a run.
Definition: environment.h:202
unsigned cache_size
2^cache_size is the number of elements of the cache.
Definition: environment.h:220
facultative< unsigned > validation_percentage
How much data should be reserved for the validation set? validation_percentage is the fraction of the...
Definition: environment.h:217
double p_mutation
Mutation rate probability.
Definition: environment.h:132
double p_cross
Crossover probability.
Definition: environment.h:137
unsigned min_individuals
Minimum number of individuals in a layer of the population.
Definition: environment.h:111
unsigned layers
Number of layers for the population.
Definition: environment.h:98
trilean elitism
An elitist algorithm is one that ALWAYS retains in the population the best individual found so far.
Definition: environment.h:116
environment()
Class constructor.
Definition: environment.cc:22
unsigned tournament_size
Size of the tournament to choose the parents from.
Definition: environment.h:172
environment & init()
Initialises the undefined parameters with "common" values.
Definition: environment.cc:43
unsigned brood_recombination
This parameter controls the brood recombination/selection level (1 to turn it off).
Definition: environment.h:160
A collection of cooperating individuals used as a member of vita::population.
Definition: team.h:54
print_format_t
Rendering format used to print an individual.
Definition: environment.h:37
Contains support functions for the ALPS algorithm.
Contains flags and manipulators to control the output format of individuals.
The main namespace for the project.
std::pair< T, T > range_t
Right-open interval.
Definition: range.h:25
trilean
Three-valued logic enum.
Definition: trilean.h:37
Parameters for the Age-Layered Population Structure (ALPS) paradigm.
Definition: alps.h:27
range_t< double > weight
Weighting factor range (aka differential factor range).
Definition: environment.h:278
std::size_t code_length
The number of genes (maximum length of an evolved program in the population).
Definition: environment.h:80
std::size_t patch_length
The number of symbols in the patch section (the tail section of the genome containing only terminals)...
Definition: environment.h:86
std::string serialization_file
Filename used for persistance.
Definition: environment.h:226
std::filesystem::path population_file
Name of the log file used to save population-specific information.
Definition: environment.h:248
std::filesystem::path dir
A base common path for the log files.
Definition: environment.h:234
std::filesystem::path dynamic_file
Name of the log file used to save real-time information.
Definition: environment.h:238
std::filesystem::path layers_file
Name of the log file used to save layer-specific information.
Definition: environment.h:242
std::filesystem::path summary_file
Name of the log file used to save a summary report.
Definition: environment.h:252
out::print_format_t ind_format
Default rendering format used to print an individual.
Definition: environment.h:259
unsigned individuals
0 is auto-tune; ‍1 means team mode.
Definition: environment.h:285
A collection of measurements.