-
Notifications
You must be signed in to change notification settings - Fork 11
Adding elements to the generator component
Dominik Drexler edited this page Sep 1, 2021
·
6 revisions
The generator component is capable of automatically generating features by exhaustively stacking the elements of the core components. The generator accepts a set of states such that newly generated features are pruned if its state evaluations are identical to those of a feature that was generated before. Adding new features to the generator is a simple two-step procedure.
// src/generator/feature_generator.h
private:
void generate_equal_boolean(const States& states, int iteration, FeatureCollection& feature_collection);// src/generator/feature_generator.cpp
void FeatureGenerator::generate_equal_boolean(const States& states, int iteration, FeatureCollection& feature_collection) {
for (int i = 1; i < iteration; ++i) {
int j = iteration - i;
for (const auto& boolean_left : m_boolean_elements_by_complexity[i]) {
for (const auto& boolean_right : m_boolean_elements_by_complexity[j]) {
if (reached_limit()) return;
else add_boolean(states, m_factory->make_equal_boolean(boolean_left, boolean_right), feature_collection);
}
}
// Add construction over pairs of Numerical, etc.
// ...
}
}// src/generator/feature_generator.cpp
void FeatureGenerator::generate_inductively(const States& states, FeatureCollection& feature_collection) {
for (int i = 1; i < iteration; ++i) {
// ...
generate_equal_boolean(states, iteration, feature_collection);
// ...
}
}