73 auto *root(d->RootElement());
75 auto *e_environment(d->NewElement(
"environment"));
76 root->InsertEndChild(e_environment);
77 set_text(e_environment,
"layers",
layers);
78 set_text(e_environment,
"individuals",
individuals);
80 set_text(e_environment,
"code_length", mep.
code_length);
81 set_text(e_environment,
"patch_length", mep.
patch_length);
82 set_text(e_environment,
"elitism", as_integer(
elitism));
83 set_text(e_environment,
"mutation_rate",
p_mutation);
84 set_text(e_environment,
"crossover_rate",
p_cross);
87 set_text(e_environment,
"dss", *
dss);
89 set_text(e_environment,
"mating_zone",
mate_zone);
90 set_text(e_environment,
"max_generations",
generations);
94 set_text(e_environment,
"cache_bits",
cache_size);
96 auto *e_alps(d->NewElement(
"alps"));
97 e_environment->InsertEndChild(e_alps);
98 set_text(e_alps,
"age_gap",
alps.age_gap);
99 set_text(e_alps,
"p_same_layer",
alps.p_same_layer);
101 auto *e_team(d->NewElement(
"team"));
102 e_environment->InsertEndChild(e_team);
103 set_text(e_team,
"individuals",
team.individuals);
105 auto *e_statistics(d->NewElement(
"statistics"));
106 e_environment->InsertEndChild(e_statistics);
107 set_text(e_statistics,
"directory", stat.
dir);
108 set_text(e_statistics,
"save_dynamics", stat.
dynamic_file);
109 set_text(e_statistics,
"save_layers", stat.
layers_file);
111 set_text(e_statistics,
"save_summary", stat.
summary_file);
112 set_text(e_statistics,
"save_test", stat.test_file);
113 set_text(e_statistics,
"individual_format", stat.
ind_format);
115 auto *e_misc(d->NewElement(
"misc"));
116 e_environment->InsertEndChild(e_misc);
133 vitaERROR <<
"Undefined code_length data member";
139 vitaERROR <<
"Undefined patch_length data member";
143 if (
elitism == trilean::unknown)
145 vitaERROR <<
"Undefined elitism data member";
151 vitaERROR <<
"Undefined p_mutation data member";
157 vitaERROR <<
"Undefined p_cross data member";
163 vitaERROR <<
"Undefined brood_recombination data member";
169 vitaERROR <<
"Undefined layers data member";
175 vitaERROR <<
"Undefined `individuals` data member";
181 vitaERROR <<
"Undefined `min_individuals` data member";
187 vitaERROR <<
"Undefined tournament_size data member";
193 vitaERROR <<
"Undefined mate_zone data member";
199 vitaERROR <<
"Undefined generations data member";
205 vitaERROR <<
"Undefined max_stuck_time data member";
211 vitaERROR <<
"Undefined age_gap parameter";
215 if (
alps.p_same_layer < 0.0)
217 vitaERROR <<
"Undefined p_same_layer parameter";
221 if (!
team.individuals)
223 vitaERROR <<
"Undefined team size parameter";
230 vitaERROR <<
"`code_length` is too short";
237 vitaERROR <<
"`patch_length` must be shorter than `code_length`";
243 vitaERROR <<
"`p_mutation` out of range";
249 vitaERROR <<
"`p_cross` out of range";
255 vitaERROR <<
"`validation_percentage` out of range";
259 if (
dss.has_value() && *
dss == 0)
261 vitaERROR <<
"`dss` out of range";
265 if (
alps.p_same_layer > 1.0)
267 vitaERROR <<
"`p_same_layer` out of range";
273 vitaERROR <<
"At least 2 individuals for layer";
279 vitaERROR <<
"Too few individuals";
286 <<
") cannot be greater than population size ("
294 <<
") cannot be greater than `mate_zone` (" <<
mate_zone
299 if (stat.
dir.has_filename())
301 vitaERROR <<
"`stat.dir` must contain a directory, not a file ("
308 vitaERROR <<
"`stat.dynamic_file` must specify a file ("
315 vitaERROR <<
"`stat.layers_file` must specify a file ("
322 vitaERROR <<
"`stat.population_file` must specify a file ("
329 vitaERROR <<
"`stat.summary_file` must specify a file ("
334 if (!stat.test_file.empty() && !stat.test_file.has_filename())
336 vitaERROR <<
"`stat.test_file` must specify a file ("
337 << stat.test_file <<
")";
Dynamic training Subset Selection.
Context object aggregating multiple related parameters into one structure.
unsigned individuals
Number of individuals in a layer of the population.
bool is_valid(bool) const
void xml(tinyxml2::XMLDocument *) const
Saves the environment in XML format.
facultative< unsigned, 0 > max_stuck_time
Used by some evolution strategies to stop a run when there aren't improvements within max_stuck_time ...
unsigned mate_zone
This is used for the trivial geography scheme.
unsigned generations
Maximun number of generations allowed before terminate a run.
unsigned cache_size
2^cache_size is the number of elements of the cache.
facultative< unsigned > validation_percentage
How much data should be reserved for the validation set? validation_percentage is the fraction of the...
double p_mutation
Mutation rate probability.
double p_cross
Crossover probability.
unsigned min_individuals
Minimum number of individuals in a layer of the population.
unsigned layers
Number of layers for the population.
trilean elitism
An elitist algorithm is one that ALWAYS retains in the population the best individual found so far.
environment()
Class constructor.
unsigned tournament_size
Size of the tournament to choose the parents from.
environment & init()
Initialises the undefined parameters with "common" values.
unsigned brood_recombination
This parameter controls the brood recombination/selection level (1 to turn it off).
A collection of cooperating individuals used as a member of vita::population.
Contains support functions for the ALPS algorithm.
The main namespace for the project.
std::size_t code_length
The number of genes (maximum length of an evolved program in the population).
std::size_t patch_length
The number of symbols in the patch section (the tail section of the genome containing only terminals)...
std::string serialization_file
Filename used for persistance.
std::filesystem::path population_file
Name of the log file used to save population-specific information.
std::filesystem::path dir
A base common path for the log files.
std::filesystem::path dynamic_file
Name of the log file used to save real-time information.
std::filesystem::path layers_file
Name of the log file used to save layer-specific information.
std::filesystem::path summary_file
Name of the log file used to save a summary report.
out::print_format_t ind_format
Default rendering format used to print an individual.